[SOLVED] /usr/bin/ld: cannot find -lfoo when trying to compile
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
/usr/bin/ld: cannot find -lfoo when trying to compile
Hello,
I'm trying to compile a program in Fedora 9 2.6.27.25-78.2.56.fc9.x86_64 and I get the following errors:
Code:
g++ -o"test" ./sample1.o -lfoo -lbar
/usr/bin/ld: skipping incompatible /usr/local/lib/libfoo.a when searching for -lfoo
/usr/bin/ld: cannot find -lfoo
collect2: ld returned 1 exit status
make: *** [test] Error 1
I've tried to compile in both Eclipse and using the makefile I was provided and I get the exact same errors both ways. libfoo.a and libbar.a do exist and are in /usr/local/lib/ and I have executed ranlib on both of them. I also don't know what to make of "skipping incompatible"; I'm new to Linux and am not a programmer by trade so I am completely unfamiliar with this type of error. After some Googeling I found solutions ranging from "just ignore it, it doesn't matter" to needing to install missing devel packages.
I also don't know what to make of "skipping incompatible"; (..) After some Googeling I found solutions ranging from "just ignore it, it doesn't matter" to needing to install missing devel packages.
I think it expects to find compatible libs in /usr/local/lib64/. Maybe explicitly using "-L/usr/local/lib64" may help if you have got your x86_64 library versions there?
I think it expects to find compatible libs in /usr/local/lib64/. Maybe explicitly using "-L/usr/local/lib64" may help if you have got your x86_64 library versions there?
Thanks for the response unSpawn. I copied the libraries to .../lib64 but I get the same errors, although the compiler complains about the libraries in /lib64 now. What's strange about this is that before I installed the libraries in .../lib(64) the compiler complained about missing definitions, now that the libraries are installed the compiler complains about not being able to find the libraries.
Code:
g++ -o"test" ./sample1.o -lfoo -lbar
/usr/bin/ld: skipping incompatible /usr/local/lib64/libfoo.a when searching for -lfoo
/usr/bin/ld: skipping incompatible /usr/local/lib/libfoo.a when searching for -lfoo
/usr/bin/ld: cannot find -lfoo
collect2: ld returned 1 exit status
make: *** [test] Error 1
Sorry if I'm stating the obvious but as it still is skipping the incompatible /usr/local/lib64/libfoo.a I wonder if you've got the right version? Just moving it to another directory doesn't turn a ELF32 object into a ELF64 one. Did you build the libraries yourself? If not, did you install from a x86_64 package? Could I suggest you revisit all development tools you installed as you might not have all required multilib / or x86_64 development packages?
Sorry if I'm stating the obvious but as it still is skipping the incompatible /usr/local/lib64/libfoo.a I wonder if you've got the right version? Just moving it to another directory doesn't turn a ELF32 object into a ELF64 one. Did you build the libraries yourself? If not, did you install from a x86_64 package? Could I suggest you revisit all development tools you installed as you might not have all required multilib / or x86_64 development packages?
I was provided with the .a files and do not have the source. According to the vendor, only 32 bit architecture is supported, does that mean it's impossible for me to compile on my 64 bit OS? I tried compiling on another computer running RHEL3 32 bit and got the error "undefined reference to __ctype_b", which I fixed using the solution outlined in comment #8 here: http://oss.sgi.com/bugzilla/show_bug.cgi?id=243 (not sure if this actually fixes the problem), so now it compiles but when I try to run the program I get a segmentation fault error. On the PC running Fedora 64 bit I have the most recent versions of Eclipse and gcc.
Solved this issue (albeit revealing yet another issue) using make -n and manually entering the gcc commands and adding the -m32 switch. For some reason adding the -m32 flag did not work in Eclipse.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.