in reply to shared-obj linking in xs-module

I think the reason why this cannot work is, that you don't link the shared object, that contains your c symbols (libmyprint.so) into the XS shared object. You could either do that dynamically so that the symbols will be resolved at runtime, like you do with the test program for libmyprint.so, or you can just link it in there statically to make sure it will always work, even if someone moves libmyprint.so or even deletes it.

That's my educated guess. It would help if you could post the build error, though.

Cheers, Flo

Replies are listed 'Best First'.
Re^2: shared-obj linking in xs-module
by warlock (Initiate) on Mar 16, 2006 at 13:53 UTC
    Thank you for your answer. But the problem is that "test" is an executable file, it is not a shared-obj. I cannot resolve myprints's symbols in libhelloworld.so. However I have tried to do this in helloworld.o:
    helloworld.o : helloworld.c $(CC) -Wall -fPIC -I$(PERLCORE) -I. -c helloworld.c +-Wl,-rpath,$(EXTLIB_PATH) -o $@ -L$(EXTLIB_PATH) -lmyprint
    without success. What do you suggest me?

      You're trying to link an object (.o) file against a library. You should do that with the shared-object file (.so).

      For example I use this commandline to link some of my XS code against a shared library.

      cc -shared -L/usr/local/lib xs/Connection.o xs/Loudmouth.o xs/Message +.o \ xs/MessageHandler.o xs/MessageNode.o xs/Proxy.o xs/SSL.o perlmouth.o \ build/perlmouth-gtypes.o -o blib/arch/auto/Net/Jabber/Loudmouth/Loudm +outh.so \ -lloudmouth-1 -lglib-2.0 -lgobject-2.0 -lgthread-2.0

      This works pretty well.

      Another possibility would be to link the libmyprint object file (.o) together with helloworld.o into helloworld.so.

      Cheers, Flo

        Thank you, for your suggestion. It functions very well, but the problem is that you have collected all obj-files in the sh-obj file. My posted code is just a short example, but in the real case I have many sh-obj files, and some of these could be proprietary one, in this case I have only sh-obj files.

        What I can do, in this generic case?