Mail Archives: cygwin/2008/02/10/18:40:57
Hello,
I am in working on porting some code to cygwin but I am stuck. I need it to be compiled as a dll but gcc gives me a linking error.
This code triggers the error:
extern int num;
int foo() {
extern int num;
num = 5;
}
the error is:
hello.c:(.text+0x5): undefined reference to `_num'
And this is how I call gcc: "gcc -shared hello.c"
Interestingly, the code above does work on my ubuntu installation (ubuntu 7.10 gcc 4.1.3)
Any help is appreciated
Regards
Fernando
Here is the complete verbose output of gcc:
$ gcc -shared hello.c -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir
=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77
,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --dis
able-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disab
le-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
/usr/lib/gcc/i686-pc-cygwin/3.4.4/cc1.exe -quiet -v -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gc
c/i686-pc-cygwin/3.4.4/../../../../include/w32api -idirafter /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/../.
./include/w32api hello.c -quiet -dumpbase hello.c -mtune=pentiumpro -auxbase hello -version -o /cygdrive/c/DOCUME~1/Fernando/LOCAL
S~1/Temp/ccnyF2Hy.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/include"
ignoring duplicate directory "/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include search starts here:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include
/usr/include
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api
End of search list.
GNU C version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) (i686-pc-cygwin)
compiled by GNU C version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/as.exe -o /cygdrive/c/DOCUME~1/Fernando/LOCALS~1/Temp/ccE2Mh41.o
/cygdrive/c/DOCUME~1/Fernando/LOCALS~1/Temp/ccnyF2Hy.s
/usr/lib/gcc/i686-pc-cygwin/3.4.4/collect2.exe --shared -Bdynamic -e __cygwin_dll_entry AT 12 --dll-search-prefix=cyg -L/usr/lib/gcc
/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../.. /cygdrive/c/DOCUME~1/Fernando/LOCALS~1/Temp/ccE2Mh41.o -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc
/cygdrive/c/DOCUME~1/Fernando/LOCALS~1/Temp/ccE2Mh41.o:hello.c:(.text+0x5): undefined reference to `_num'
collect2: ld returned 1 exit status
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -