Search code examples
c++g++cygwin

Cygwin G++ linker (ld.exe) on Windows 7 cannot find libc.so.6 and other library files


I am using g++ in a cygwin terminal to link several c object files and c++ object files together into a single shared executable. The linker tells me that there are several libraries it cannot find. However, I can list them, using the locations where the linker states that it is looking for them:

g++ -g -o myProg.so *.o -shared c:/cygwin/bin/../lib/gcc/x86_64-vityan-linux-gnu/4.6.0/../../../../x86_64-vityan-linux-gnu/bin/ld.exe: *cannot find /lib/libc.so.6* c:/cygwin/bin/../lib/gcc/x86_64-vityan-linux-gnu/4.6.0/../../../../x86_64-vityan-linux-gnu/bin/ld.exe: *cannot find /x86_64-vityan-linux-gnu/lib/libc_nonshared.a* c:/cygwin/bin/../lib/gcc/x86_64-vityan-linux-gnu/4.6.0/../../../../x86_64-vityan-linux-gnu/bin/ld.exe: *cannot find /lib/ld-linux-x86-64.so.2* collect2: ld returned 1 exit status $ ls /lib/libc.so.6 /lib/libc.so.6

$ ls /x86_64-vityan-linux-gnu/lib/libc_nonshared.a /x86_64-vityan-linux-gnu/lib/libc_nonshared.a

$ ls /lib/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2

I have tried renaming the .so files to .dll with no success.

I have tried to use the g++ switch '--sysroot' ( --sysroot=/cygdrive/c/cygwin/) with no success.

I have tried adding the g++ switch '-B /cygdrive/c/cygwin/lib/' with no success.

The thing that's really got me confused is that I did this same thing on a similar project about 6 months ago - no issues. And, the system clearly shows that the libraries are there.

What is missing that ld.exe needs to find these files?


Solution

  • I ran a quick analysis of what packages I had installed in Cygwin. I had several of the mingw g++ toolchain packages as well (which don't get used), and a bunch of other stuff. I only use Cygwin for a few specific projects, so I reinstalled: removed all of the other g++ toolchain items, and just installed the cygwin gcc 64 bit toolchain packages. Project now compiles without issue. Closing question.