[mercury-users] Building shared library containing C++ code
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Mar 24 03:32:02 AEDT 2003
On 23-Mar-2003, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> I'm trying to build a library of some Mercury modules using the simple
> 'mmake depend; mmake libmylib' where mylib.m is a wrapping module that
> includes all the modules of the library. Some of the modules use some C
> code, and I would naturally like to have the objects from C contained in
> the library as well. Therefore, I've added
>
> MLOBJS-mylib=c_object1.o c_object2.o
>
> to the Mmakefile.
>
> If I run 'mmake libmylib.a' (the static version of the library), it gets
> created successfully.
>
> If I run plain 'mmake libmylib', I get this error:
>
> gmake: *** No rule to make target `db_cint.pic_o', needed by `libcore.so'.
> Stop.
>
> db_cint.c is one of the extra C source codes. The static version,
> db_cint.o, gets compiled via the standard $(CC) $(CFLAGS) -c ... rule.
>
> How should I create db_cint.pic_o?
It should created in the same way as the db_cint.o file,
except that you need to also pass `-fpic' (or `-fPIC') to gcc.
(You may need to add a rule to your Mmakefile for this.)
> What does the .pic_o extension mean? (What's the difference from .o?)
To quote the Mercury user's guide: "`.pic_o' files are object code files
that contain position-independent code (PIC)". Such files are suitable
for linking into shared libraries (`.so' files).
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list