[64bit] undefined references to _setjmp and _longjmp

Ken Brown kbrown@cornell.edu
Tue Apr 23 09:52:00 GMT 2013


/usr/include/machine/setjmp.h, which is included by 
/usr/include/setjmp.h, declares _setjmp and _longjmp, but ld reports 
"undefined reference":

$ cat test_setjmp.c
#include <setjmp.h>

int
main ()
{
   jmp_buf j;
   if (! _setjmp (j))
     _longjmp (j, 1);
   return 0;
}

$ gcc test_setjmp.c
/tmp/cciCClqa.o:test_setjmp.c:(.text+0x1d): undefined reference to `_setjmp'
/tmp/cciCClqa.o:test_setjmp.c:(.text+0x1d): relocation truncated to fit: 
R_X86_64_PC32 against undefined symbol `_setjmp'
/tmp/cciCClqa.o:test_setjmp.c:(.text+0x32): undefined reference to 
`_longjmp'
/tmp/cciCClqa.o:test_setjmp.c:(.text+0x32): relocation truncated to fit: 
R_X86_64_PC32 against undefined symbol `_longjmp'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.0/../../../../x86_64-pc-cygwin/bin/ld: 
/tmp/cciCClqa.o: bad reloc address 0x0 in section `.pdata'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.0/../../../../x86_64-pc-cygwin/bin/ld: 
final link failed: Invalid operation
collect2: error: ld returned 1 exit status

Ken



More information about the Cygwin-apps mailing list