Porting a C++ based project
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 404 from 2014/6/11
    From: Germany
    Hi.

    I'm currently porting a C++ project. It has relatively few dependencies.
    That is: xz, bz2, z, curl, icu (not necessarily required).

    I found libbz2.a in the SDK. Also I found libz_shared.a but using it for linking did't really work. So I've compiled zlib from source to libz.a.
    How is libz_shared.a supposed to be used?

    Is there libcurl available?

    Now, I've pretty much compiled the project OK so far.
    I'm wondering now in which way I can make it more MorphOS native by using the available shared libraries bz2, z.
    Is it possible to create shared libraries that have static library dependencies (libbz2, etc.)?
    What would need to be changed in the sources to do that (use the proto includes)?


    Manfred
  • »08.02.16 - 10:06
    Profile
  • MorphOS Developer
    CISC
    Posts: 619 from 2005/8/27
    From: the land with ...
    Take a look in gg:os-include, there are several stub-includes there that are activated by a special define you can use at compile-time (-D__MORPHOS_SHAREDLIBS iirc), then you can link with the lib*_shared.a libs (not all the libraries need one though).

    Making shared libraries that depend on static libraries is usually ok as long as they

    1. are fully re-entrant (ie, are not using globals)
    2. don't invoke certain libc functions (I/O, memory, etc)

    If they do you need to wrap those with your own or handle full libnix init yourself (see the nixskeleton library example in the SDK) and use baserel if there are globals (all linked dependencies must also be compiled baserel (and installed into the libb32 subdir) then as well).


    - CISC
  • »08.02.16 - 11:23
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 404 from 2014/6/11
    From: Germany
    OK, thanks.

    I tried to compile using this define (__MORPHOS_SHAREDLIBS) and then used the link library libz_shared.a.
    But there doesn't seem to be a similar library for bz2. The proto bz2 include adds a BZ2Base type which cannot be found when linking with libbz2.a.
    Which bz2 library do I link with then?


    Manfred
  • »09.02.16 - 07:06
    Profile
  • MorphOS Developer
    CISC
    Posts: 619 from 2005/8/27
    From: the land with ...
    For libraries that don't have a lib*_shared.a it should be enough to link with aboxstubs (if you disabled inlines) and auto (for the *Base), though this is default at link stage (unless you invoke ld directly).


    - CISC
  • »09.02.16 - 07:43
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 404 from 2014/6/11
    From: Germany
    No, I didn't disable inlines at least not to my knowledge.
    I don't use ld directly.
    This is the compile command when building an executable:
    Code:
    ppc-morphos-g++-5 buildtest.cpp -o buildtest -D__MORPHOS_SHAREDLIBS -Iinclude -L. -lsword -lz_shared

    The library libsword.a has been compiled with __MORPHOS_SHAREDLIBS as well and the objected files were combined using ar.
    Are you saying that this should automatically link against libauto (-lauto) for the *Base types)?
    If so that doesn't seem to be the case.
    Adding -lauto manually I'm getting an error that ld cannot open -lauto


    Manfred
  • »09.02.16 - 08:42
    Profile
  • MorphOS Developer
    CISC
    Posts: 619 from 2005/8/27
    From: the land with ...
    You should use -noixemul when building with -D__MORPHOS_SHAREDLIBS as there are potential issues combining shared libraries with ixemul, one of those is that there is no libauto. :)

    I do believe there is a libbz2_shared.a as well, but maybe only for libnix?


    - CISC
  • »09.02.16 - 09:08
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 404 from 2014/6/11
    From: Germany
    Thanks, that did the trick.


    Manfred
  • »09.02.16 - 10:00
    Profile