[SLL] linking - calling C++ code from Java using SWIG
Mathew D. Watson
watson at visiongate3d.com
Fri Nov 7 12:13:05 PST 2008
Mathew D. Watson wrote:
> ter wrote:
>> On Fri, 2008-11-07 at 09:17 -0800, Mathew D. Watson wrote:
>> ...
>>> 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
>
An experienced programmer came by and explained the mystery to me.
-l_ab tells the linker to resolve only what is needed by object
files listed earlier on the command line. The following command
solved the problem.
g++ -shared c.o lib_ab.a -o lib_abc.so
Thanks!
More information about the linux-list
mailing list