LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   /usr/bin/ld: cannot find -lfoo when trying to compile (https://www.linuxquestions.org/questions/linux-software-2/usr-bin-ld-cannot-find-lfoo-when-trying-to-compile-837890/)

Philmac 10-13-2010 04:21 PM

/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.

Any ideas?

Thanks in advance

unSpawn 10-13-2010 06:52 PM

Quote:

Originally Posted by Philmac (Post 4126447)
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?

Philmac 10-14-2010 09:06 AM

Quote:

Originally Posted by unSpawn (Post 4126541)
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


unSpawn 10-14-2010 03:15 PM

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?

Philmac 10-15-2010 10:56 AM

Quote:

Originally Posted by unSpawn (Post 4127585)
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.

Philmac 10-18-2010 09:22 AM

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.


All times are GMT -5. The time now is 03:31 AM.