Search code examples
gcccygwinld

ld cannot find cannot find -luser32 (from Eclipse)


I am trying do CPP development from Eclipse..

I've installed cgywin.. and when try to compile, link any simple Hello World App, I got the following while linking ...

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -luser32
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lkernel32
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -ladvapi32
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lshell32

Full output:

***Build of configuration Debug for project testcpp***
make all 
Building target: testcpp.exe
Invoking: Cygwin C++ Linker
g++  -o "testcpp.exe"  ./src/testcpp.o   
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -luser32
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lkernel32
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -ladvapi32
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lshell32
collect2: ld returned 1 exit status
make: *** [testcpp.exe] Error 1

**** Build Finished ****

I think the above libs required by ld is win specific ...

I've tried find / -name *user32*, the result were ..

.....
/usr/i686-pc-mingw32/sys-root/mingw/lib/libuser32.a
......

Is this can help?


Solution

  • From the notice above:

    I've tried find / -name *user32*, the result were ..
    
    .....
    /usr/i686-pc-mingw32/sys-root/mingw/lib/libuser32.a
    ......
    
    Is this can help?
    

    It really helped me..

    The required libs are included under mingw but I am using cygwin in eclipse .. so, under the directory of cygwin which is: /usr/i686-pc-cygwin, I've did the following: ln -sf ../i686-pc-mingw32/sys-root/mingw/lib lib; So, now cgywin have the required libraries ...