Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - [Q] on build a DLL from static shared objects: (4 Items)
   
[Q] on build a DLL from static shared objects  
we are trying to build a shared object out of static shared archives only,
but the resulting .SO does not have any exported symbols.
As the S.a archives are all compiled using -fPIC and the functions are global, we would expect that the resulting .SO 
will contain the symbols from S.a files - but this is not working.
We tried to use a version script to explicitly declare the functions that should be exported, but it's not working.
So is it possible at all, to generate a .SO out of S.a files only?
are we doing something wrong, or what has to be done that a function from S.a file gets exported from within the build .
SO file?

any suggestions?
TIA
/hp
Re: [Q] on build a DLL from static shared objects  
Hans-Peter Reichert wrote:
> we are trying to build a shared object out of static shared archives only,
> but the resulting .SO does not have any exported symbols.
> As the S.a archives are all compiled using -fPIC and the functions are global, we would expect that the resulting .SO 
will contain the symbols from S.a files - but this is not working.
> We tried to use a version script to explicitly declare the functions that should be exported, but it's not working.
> So is it possible at all, to generate a .SO out of S.a files only?
> are we doing something wrong, or what has to be done that a function from S.a file gets exported from within the build
 .SO file?
> 
> any suggestions?

You can use force the entire archive into the shared object using 
--whole-archive. Otherwise ld will only pull the required objects from 
the archive.

Regards,

Ryan Mansfield
Re: [Q] on build a DLL from static shared objects  
> You can use force the entire archive into the shared object using 
> --whole-archive. Otherwise ld will only pull the required objects from 
> the archive.

I did not know that flag, thanks. I also had to add --no-whole-archive after our own libs to avoid pulling in everything
 else, too. It works on the command line if all archives are listed directly. But in our automated build, we use a 
linker script file to provide the list of libraries (to avoid running into command line limits). These scripts contain 
an INPUT command per archive.
==> 
This works fine:
   qcc ... -Wl,--whole-archive liboneS.a libtwoS.a -Wl,--no-whole-archive ...

This doesn't:
   qcc ... -Wl,--whole-archive all_my_libs.txt -Wl,--no-whole-archive ...
where all_my_libs.txt is something like
   INPUT(liboneS.a)
   INPUT(libtwoS.a)

Should --whole-archive also affect the archives listed in the linker script (i.e. "is this a bug?")? Or is there another
 command we could use in the script?

Regards,
Daniel
Re: [Q] on build a DLL from static shared objects  
Daniel Weber wrote:
>> You can use force the entire archive into the shared object using 
>> --whole-archive. Otherwise ld will only pull the required objects from 
>> the archive.
> 
> I did not know that flag, thanks. I also had to add --no-whole-archive after our own libs to avoid pulling in 
everything else, too. It works on the command line if all archives are listed directly. But in our automated build, we 
use a linker script file to provide the list of libraries (to avoid running into command line limits). These scripts 
contain an INPUT command per archive.
> ==> 
> This works fine:
>    qcc ... -Wl,--whole-archive liboneS.a libtwoS.a -Wl,--no-whole-archive ...
> 
> This doesn't:
>    qcc ... -Wl,--whole-archive all_my_libs.txt -Wl,--no-whole-archive ...
> where all_my_libs.txt is something like
>    INPUT(liboneS.a)
>    INPUT(libtwoS.a)
> 
> Should --whole-archive also affect the archives listed in the linker script (i.e. "is this a bug?")? Or is there 
another command we could use in the script?

It's a bug. I've filed a PR and I have a fix for it. If you want I can 
provide an experimental linker or you can submit a ticket and we can get 
an official one to you.

Regards,

Ryan Mansfield