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?
This one reminds me of my first experiments with gcc in 1998 or -99. :)
The solution is still in the same place.
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 \
|All times are GMT -5. The time now is 01:32 PM.|