Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to link a project against static libraries?: (4 Items)
   
How to link a project against static libraries?  
I have two statically-linked-library projects that compile successfully, and I would like to make a dummy app project 
that links to them. Apparently, referencing the lib projects in project->properties->project references doesn't do it. 
Note: I don't want the app project to copy the lib binaries into its own directory; I want it to link to them where they
 are. I would also like the app to get rebuilt when one of the libraries changes.

Also, the default behavior of most linkers is to leave out library functions that are not called. Is there any way to 
defeat this behavior & force the linker to include everything? Part of the reason I'm doing this is to flush out 
references to missing functions from the libraries.

Thanks,
-Jon
Re: How to link a project against static libraries?  
If you talking about IDE for QNX project open project->properties on app. Switch to Linker tab. In drop down menu select
 "Extra libraries". Add you library there.
I don't know answer to a second question (it could be in gcc doc).

Jonathan Juniman wrote:
> I have two statically-linked-library projects that compile successfully, and I would like to make a dummy app project 
that links to them. Apparently, referencing the lib projects in project->properties->project references doesn't do it. 
Note: I don't want the app project to copy the lib binaries into its own directory; I want it to link to them where they
 are. I would also like the app to get rebuilt when one of the libraries changes.
> 
> Also, the default behavior of most linkers is to leave out library functions that are not called. Is there any way to 
defeat this behavior & force the linker to include everything? Part of the reason I'm doing this is to flush out references to missing functions from the libraries.
> 
> Thanks,
> -Jon
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post14909
> 
Attachment: Text elaskavaia.vcf 116 bytes
Re: How to link a project against static libraries?  
Elena Laskavaia wrote:
> If you talking about IDE for QNX project open project->properties on app. Switch to Linker tab. In drop down menu 
select "Extra libraries". Add you library there.
> I don't know answer to a second question (it could be in gcc doc).

The linker option to link in a whole archive is:

-Wl,--whole-archive <list of libs> -Wl,--no-whole-archive

By default, the GNU linker brings in the entire referenced object, and 
doesn't do it on a per-function basis.  To accomplish that, you would 
need to compile with -ffunction-sections and  link with -Wl,--gc-sections.

Regards,

Ryan Mansfield
Re: How to link a project against static libraries?  
OK, that did the trick. Thanks. However, down in the libraries I've deleted functions that I know for a fact are called 
from elsewhere in the libraries, and yet the linker is not complaining. This stuff must be getting excluded. However, I 
assume the complaints will start as soon as I start calling functions from main() that depend on the missing pieces. 
That's what I'm going to do next.