Linux - Software This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
10-15-2004, 11:13 AM
|
#1
|
LQ Newbie
Registered: Oct 2004
Location: Maryland
Posts: 2
Rep:
|
Problems with GNU linker ld
I am trying to compile some C code using GNU tools, gcc and ld. I have created a makefile and compiled my soruces to .o successfully. I then linked the object files to a executable file and seems to work. WHen I try to run the executable file I get an error message - /usr/lib/libc.o.1:Bad ELF interpreter: No such file or directory. The error message is correct, there is no /usr/lib/libc.o.1 file. In my makefile, in the line to link (ld) I have the option -lc. Remove this and I cannot compile due to the linker not finding the lib files for items like malloc, send,put,etc. I have tried all different ways to make the linker find the correct lib files but with no success. DOes anybody know if this file /usr/lib/libc.o.1 is suppose to exist? I installed Red Hat Linux on my PC. Here is another issue. If I create 1 dummy C file, compile just that file, and link to an executable with -lc, I don't get the ELF error. This problem only happens when I link multipule object files.
Does anybody out there know anything about this? THis problems pertains to my job and I need to get this software working ASAP.
|
|
|
10-15-2004, 11:53 AM
|
#2
|
Senior Member
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577
Rep:
|
well, I have a libc.so
just edit the MAKEFILE and make it libc.so OR libc.so.1
|
|
|
10-15-2004, 12:14 PM
|
#3
|
Senior Member
Registered: Jun 2004
Posts: 2,553
Rep:
|
gcc links to libc automatically for you
you need to show us exactly the commands you are using or show us the makefile
before we can know what is going on
|
|
|
10-15-2004, 02:24 PM
|
#4
|
LQ Newbie
Registered: Oct 2004
Location: Maryland
Posts: 2
Original Poster
Rep:
|
Parts of my makefile that do the linking
FULLSIM: $(OBJFILES)
$(LD) -o FULLSIM -r ($LD_FILES)
$(LD) -o fullsim.out FULLSIM -lc
Just a simple snapshoot of my makefile Link portion
|
|
|
10-15-2004, 04:41 PM
|
#5
|
Senior Member
Registered: Jun 2004
Posts: 2,553
Rep:
|
i really can't make heads or tails out of that
but is there any reason you can't eliminate the -r relocatable option and just do
$(LD) -o FULLSIM ($LD_FILES) -lc
all in one line ?
or better yet as i said before if you just use gcc instead of ld all you need is
$(CC) (if that's gcc) and assuming ($LD_FILES) are object files compiled with gcc -c
if your programm contains any c++ code use g++ instead of gcc
$(CC) -o FULLSIM ($LD_FILES)
this will produce a properly linked executable
also with what you have there your executable in the end is fullsim.out not FULLSIM yes
if you are trying to run FULLSIM then the runtime trouble obvoiusly is it -r (is just partially linked)
might just reverse the two like
$(LD) -o fullsim.out -r ($LD_FILES)
$(LD) -o FULLSIM fullsim.out -lc
|
|
|
10-15-2004, 04:46 PM
|
#6
|
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290
|
Usually you just want to let gcc invoke ld for you. It automatically adds some extra command lineoptions that actually make things work correctly (I think if you invoke gcc in verbose mode, you can see what they are). Invoking ld by hand (rather than through gcc) is generally only done when you need to invoke some really special linker magic, or at least that's been my experience.
|
|
|
All times are GMT -5. The time now is 03:06 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|