flat assembler
Message board for the users of flat assembler.

Index > Linux > Linking to libc problem

Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
How the hell should i link to libc?

Hi, i have problem with linking to libc on linux. I make object file, link it this way:
Code:
ld -e main -lc file.o fasmlib.o -o file    


but then when i try to run it:
Code:
./file    


i get:
Code:
-bash: ./file: No such file or directory    


I found out that this is some kind of problem with finding dynamic library. Using "readelf -l" i found out that "Requesting program interpreter: /usr/lib/libc.so.1". I don't have "lib/libc.so.1" on my system.

Same interpreter is set when i link directly to "lib/libc.so.6" instead of using "-lc".

Anyone knows solution?
Post 01 Mar 2007, 23:43
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
by the way, this is last thing i need to solve before releasing FASMLIB 0.5, so please help Wink
Post 01 Mar 2007, 23:46
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Post 02 Mar 2007, 00:25
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
allright, it works. For someone who will hit this thread with searching:

needed switches for "ld":
Code:
-dynamic-linker lib/ld-linux.so.2   ;set program loader
-lc    ;link C runtime
-e entry ;entry point symbol
-o output ;output file name
file1.o
file2.o
...
    


thanks.

by the way i found last problem, it was not bug in FASMLIB, but in example file using it. I was comparing speed of FASMLIB and libc, and mixed up their memory managers, which both use brk() Smile
Post 02 Mar 2007, 08:37
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.