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 04-07-2012, 11:56 AM   #1
neha l
LQ Newbie
 
Registered: Apr 2012
Posts: 1

Rep: Reputation: Disabled
Problem in static linking in linux.


hi all, I am learning how to create static link library and I am doing it first time.

Firstly I created two header files ctest1.h and ctest2.h and compiled them by the following commands:

gcc ctest1.h -o ctest2.out (successfully executed)
gcc ctest2.h -o ctest2.out (successfully executed)

and then making the archive file by the following command

ar rcs libctest.a ctest1.out ctest2.out (successfully executed)

and then I tried to link cprog.c with this by the following command

gcc -static cprog.c libctest.a -o cprog.out (not successfully executed)

(error: libctest.c : could not read symbols: Archive has no index; run ranlib to add one)

then I gave the following command
ranlib libctest.a
and then again the same command
gcc -static cprog.c libctest.a -o cprog.out (it gave the same error again).

Please tell me what I am doing wrong, also I am a beginner with all this, if you want to suggest anything else regarding this, then I will be happy to implement your suggestion.

Thank you so much.
 
Old 04-07-2012, 12:10 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
I don't have a lot of experience with creating static libraries, but I did come across this page once when I stumbled through the process: could not read symbols . . .

Perhaps it will help you as well.

EDIT:
Also be sure to read the exchange beneath the check-mark answer--it leads to some additional debugging.

Last edited by Dark_Helmet; 04-07-2012 at 12:11 PM.
 
  


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
problem in linking static library in Jamfile vikasmailsu Programming 4 01-22-2012 11:24 PM
Static linking vs. dynamic linking? posix_memalign Programming 13 04-18-2010 03:27 PM
Problem linking static libraries in g++ zbinwu Programming 6 07-26-2007 05:31 PM


All times are GMT -5. The time now is 05:14 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration