LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-21-2005, 12:08 PM   #1
rudy2
LQ Newbie
 
Registered: Apr 2005
Posts: 2

Rep: Reputation: 0
Linking program with .a libraries


I am busy porting some old c code from IBM AIX to Linux. It's the first time I use Linux so I guess I am an absolute newbie .

The code is compiled with -c -g and then the .o files are stored by module in a module.a library (ar rcv). The main() function is also located in one of the module.a libraries.

The compilation works fine (same script as with AIX), but when I use the link command:

cc module1.a module2.a .... modulen.a -o myprogram

then it complains about undefined references in functions of module1.a using e.g. functions of module2.a. Declairing the function as external in module1.a and recompile does not help.

The same command under IBM AIX works perfect and links the program without complaining.

Is there a compiler or linker option I should use?
 
Old 04-21-2005, 02:38 PM   #2
Harmaa Kettu
Member
 
Registered: Apr 2005
Location: Finland
Posts: 196

Rep: Reputation: 30
This one reminds me of my first experiments with gcc in 1998 or -99.

The solution is still in the same place.
 
Old 04-22-2005, 06:36 AM   #3
rudy2
LQ Newbie
 
Registered: Apr 2005
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks, grouping the libraries solved the problem! Below a sample command so another newbie might not struggle with the syntax as I did.

gcc -Wl,--start-group \
../../lib/boot.a \
../../lib/def.a \
../../lib/cmn.a \
../../lib/dde.a \
-Wl,--end-group \
-o ../../run/boot
 
  


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
Linking old libraries to new one? winterhunter Linux - Software 7 10-24-2005 05:37 AM
Linking Libraries, Dependencies Killbot_5000 Linux - Software 4 09-28-2004 09:59 AM
Shared libraries and linking., devin Programming 3 04-08-2003 04:18 PM
Linking to shared libraries? Griffon26 Programming 1 10-20-2001 06:29 PM
linking with shared libraries kobilevi Programming 0 03-01-2001 11:09 AM


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