[SLL] linking - calling C++ code from Java using SWIG
Mathew D. Watson
watson at visiongate3d.com
Fri Nov 7 11:47:04 PST 2008
ter wrote:
> On Fri, 2008-11-07 at 09:17 -0800, Mathew D. Watson wrote:
> ...
>> java: symbol lookup error: undefined symbol: _Z8VVGCamera4open...
>>
>> The symbol name was real long, and I saw it when I ran nm on the library
>> file. The library was created using
>>
>> $ ld -r a.o b.o -o lib_ab.a
>> $ g++ -shared c.o -o lib_abc.so -L. -l_ab
>>
>> I managed to eliminate the error by creating the .so using
>>
>> $ g++ -shared a.o b.o c.o -o lib_abc.so
>>
>> Can someone explain why the symbol was missing from the first library
>> and not from the second one? In particular, why did I get the error when
>> nm showed that the symbol was present?
>>
>> How can I modify the first g++ line so it correctly links against the
>> static library lib_ab.a?
> Try
>
> $ g++ -shared c.o -o lib_abc.so -L. -Wl,-Bstatic -l_ab
>
Thanks ter. I tried that command, but I get the following error.
/usr/bin/ld: cannot find -lgcc_s
After googling on the error message, I also tried
$ g++ -shared c.o -o lib_abc.so -L. -Wl,-Bstatic -l_ab \
-Wl,-Bdynamic -lgcc_s
but that produces the same error. The last attempt was a
guess, as I really don't understand what is going on here.
Mat
More information about the linux-list
mailing list