This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Shared library linking with external static libraries.


Thanks, I'm getting closer to what I want.

I've created a simple Version script:

[code]
VERSION {
    {
        global:
            SomeRootNameSpaceClass*;
            SomeOtherRootNameSpaceClass*;
            SomeNameSpace::*;
            SomeOtherNameSpace::*;
        local:
            *;
    };
}
[/code]

But then, if I try to link with the produced so, i get undefined references
to methods that should be exported:

/usr/bin/gcc -o myApp $(OBJS) -L/path/to/the/SdkDir -lMySdk
someObj.o: In function `SomeClass::someMethod()':
someObj.cpp:(.text+0x367): undefined reference to
`SomeNameSpace::SomeClass::someMethod(<params>)'

And a lot of other missing symbols appear. This happens eventhough when i
execute following command:

nm -C --defined-only /path/to/the/SdkDir/libMySdk.so  | grep
"SomeNameSpace::SomeClass::someMethod"

I get, the proper method, which should have been exported:

00087790 t SomeNameSpace::SomeClass::someMethod(<params>)

I bet i'm still missing something.

Thanks again,
Florent.



Ian Lance Taylor-3 wrote:
> 
> FloofLeBo <bluswedshooz@yahoo.fr> writes:
> 
>> PaweÅ Sikora-2 wrote:
>>> 
>>> On Tuesday 12 of October 2010 12:24:33 FloofLeBo wrote:
>>> 
>>>>     - How can I tell gcc (used with "-shared") to not expose the
>>>> externals
>>>> libraries's symbols, since they were compiled without
>>>> -fvisibility=hidden
>>>> ?
>>> 
>>> you can instruct linker to expose/hide symbols (via global/local
>>> section)
>>> in version script. see the 'info ld', section '3.9 VERSION Command' for
>>> ex. 
>>> 
>>> BR,
>>> Pawel.
>>> 
>>> 
>>
>> I tried this command below:
>>
>> /usr/bin/gcc  -melf_i386  -shared -Wl,-soname,libMySdk.so.1 -o
>> libMySdk.so
>> $(OBJS) -Wl,--exclude-libs,ALL $(LIBS) $(SUBLIBS)
>>
>> where:
>>     - $(OBJS) contains my SDK's objects files (*.o)
>>     - $(LIBS) contains -L and -l statements
>>     - $(SUBLIBS) contains the path to the home-made sub-libraries .a
>> files
>>
>> But this did not do the trick, and the symbols from $(LIBS) still get
>> exported in the .so shared object.
>>
>> What am I missing ?
> 
> 
> You are missing a version script.
> 
> Ian
> 
> 

-- 
View this message in context: http://old.nabble.com/Shared-library-linking-with-external-static-libraries.-tp29941925p29944993.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]