How to link a library to library - follow up on another post. [message #1820729] |
Mon, 27 January 2020 19:14  |
Eclipse User |
|
|
|
Please note - I am NOT asking how to link C++ source to library.
I have a library (x.a) which need to reference another library.
It is standard type .a Linux library build using Eclipse and has common source includes built-in.
No problem adding specific "#include " source. It compiles OK.
After looking at GCC option I should be able to just add library file name.
I have added it as "miscellaneous" to the GCC.
The GCC "cannot find it..."
1. Does it have to be full library file name - such as "libX.a" or only X?
2. How / where do I add path to the additional library or do I have to ?
There are too many combinations of what syntax to use, unsuccessfully
tried them,
so I could use some assistance solving this.
AGAIN
Please note - I am NOT asking how to link source to library.
I need to link TWO libraries.
[Updated on: Mon, 27 January 2020 19:15] by Moderator
|
|
|
|
|
|
|
Re: How to link a library to library - follow up on another post. [message #1826866 is a reply to message #1826861] |
Sun, 03 May 2020 07:13  |
Eclipse User |
|
|
|
I'm only guessing at why you are having a problem.
If I'm guessing incorrectly, be more specific.
The linker only uses functions in a library when needed
so placing the libraries before the object files is pointless.
Assume lib X references a function in lib Y and
lib Y references a function in lib X.
If you are using Eclipse to generate the makefile,
you do this by listing libraries multiple times -- as many as needed
e.g., X, Y, X, Y
The order can be changed using the up and down icons in the dialog.
Works for both the libraries and miscellaneous dialogs.
You could also modify the command line pattern for the linker.
Here's the result of adding /usr/lib64/libc.a as a miscellaneous object twice
and library m twice in the libraries dialog
g++ -o "Hello" ./src/Hello.o /usr/lib64/libc.a /usr/lib64/libc.a -lm -lm
If you are writing your own makefile you can cause the linker to loop over a list
see options --start-group and --end-group
in https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html
Writing your own makefile is off-topic for this forum.
[Updated on: Sun, 03 May 2020 07:35] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03207 seconds