LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-20-2007, 12:47 PM   #1
flauser
LQ Newbie
 
Registered: Dec 2007
Location: In west Mexico
Distribution: mandriva 2006, looking to upgrade to Mandriva 2008
Posts: 8

Rep: Reputation: 0
Question newbie with a problem using ld


I have both version 4.0.1 and 4.2.2 of gcc installed in my computer just in case that matters. I'm trying to link a small test program to learn to use the linker, but the linker can't seem to find the library, even under the indication to look for it under the current directory.

I had already obtained similar errors in past ocassions, that is to say, the linker doesn't find any libs even when I think I'm indicating both the correct name and the path using the -l and -L flags, respectively.

I've read the man files for both gcc and for ld, and I still can't pinpoint the error. I would really appreciate if anyone could help me out.

Code:
*** here are the files in the folder I am linking in

[prompt]$ ls

app.c
app.o
linker_error
temp_file.c
temp_file.o
test.c
testlib.a
test.o

*** here is the line that I used to link and the error I got:

[prompt]$ gcc -o app app.o -L. -ltest 

/usr/bin/ld: cannot find -ltest
collect2: ld returned 1 exit status
 
Old 12-20-2007, 12:57 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
When using the -l option the linker surrounds the name with "lib" and ".a ". This mean it looks for a file called libtest.a. If the library you're trying to link is testlib.a, you have to rename it as libtest.a.
 
Old 12-20-2007, 01:09 PM   #3
flauser
LQ Newbie
 
Registered: Dec 2007
Location: In west Mexico
Distribution: mandriva 2006, looking to upgrade to Mandriva 2008
Posts: 8

Original Poster
Rep: Reputation: 0
thanks so much

right about now I am feeling pretty silly about not having noticed such a silly error, oh well, thanks a lot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A little newbie problem little_ball Red Hat 1 11-27-2004 12:52 PM
extreme newbie problem...Portsentry Problem ImAnEwBiE Linux - Newbie 1 08-26-2003 09:18 AM
newbie problem dartania Linux - General 7 08-17-2003 04:36 PM
newbie nvidia problem BuckNaked Linux - Newbie 9 10-19-2002 07:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration