Building shared nglib with OCE on MinGW-w64 fails: undefined symbols

Help
Daniel
2013-11-21
2014-07-09
  • Daniel
    Daniel
    2013-11-21

    Hello,

    as the title suggests, I am trying to build a shared nglib with MinGW-w64 using the Open Cascade Community Edition.

    I am configuring using

    export CXXFLAGS=-fpermissive
    ./configure --enable-nglib --disable-gui --enable-occ -with-occ=/d/OceReleaseMinGw -build=x86_64-w64-mingw32 --enable-shared

    after running make and make install I only get static libraries, i.e. *.a instead of *.dll files.

    However, the linker is returning the following warning:

    /bin/sh ../../libtool --tag=CXX --mode=link g++ -fpermissive -fopenmp -o libcsg.la -rpath /opt/netgen/lib algprim.lo brick.lo bspline2d.lo csgeom.lo csgparser.lo curve2d.lo edgeflw.lo explicitcurve2d.lo extrusion.lo gencyl.lo genmesh.lo identify.lo manifold.lo meshsurf.lo polyhedra.lo revolution.lo singularref.lo solid.lo specpoin.lo spline3d.lo surface.lo triapprox.lo ../../libsrc/meshing/libmesh.la -lpthread
    *** Warning: This system can not link to static lib archive ../../libsrc/meshing/libmesh.la.
    *** I have the capability to make that library automatically link in when
    *** you link to this library. But I can only do this if you have a
    *** shared version of the library, which you do not appear to have.
    libtool: link: warning: undefined symbols not allowed in x86_64-w64-mingw32 shared libraries

    I tried reconfiguring with

    export AM_LDFLAGS=-no-undefined --enable-runtime-pseudo-reloc

    and got more detailed and slightly different errors:

    /bin/sh ../../libtool --tag=CXX --mode=link g++ -fpermissive -fopenmp -no-undefined --enable-runtime-pseudo-reloc -o libmesh.la -rpath /opt/netgen/lib adfront2.lo adfront3.lo bisect.lo boundarylayer.lo clusters.lo curvedelems.lo delaunay.lo delaunay2d.lo geomsearch.lo global.lo hprefinement.lo improve2.lo improve2gen.lo improve3.lo localh.lo meshclass.lo meshfunc.lo meshfunc2d.lo meshing2.lo meshing3.lo meshtool.lo meshtype.lo msghandler.lo netrule2.lo netrule3.lo parser2.lo parser3.lo prism2rls.lo pyramid2rls.lo pyramidrls.lo quadrls.lo refine.lo ruler2.lo ruler3.lo secondorder.lo smoothing2.5.lo smoothing2.lo smoothing3.lo specials.lo tetrarls.lo topology.lo triarls.lo validate.lo zrefine.lo bcfunctions.lo parallelmesh.lo paralleltop.lo basegeom.lo ../../libsrc/linalg/libla.la ../../libsrc/gprim/libgprim.la ../../libsrc/general/libgen.la -lz -lpthread

    *** Warning: linker path does not have real file for library -lz.
    *** I have the capability to make that library automatically link in when
    *** you link to this library. But I can only do this if you have a
    *** shared version of the library, which you do not appear to have
    *** because I did check the linker path looking for a file starting
    *** with libz and none of the candidates passed a file format test
    *** using a file magic. Last file checked: c:/mingw64/x86_64-w64-mingw32/lib/libz.a
    *** The inter-library dependencies that have been dropped here will be
    *** automatically added whenever a program is linked with this library
    *** or is declared to -dlopen it.

    *** Since this library must not contain undefined symbols,
    *** because either the platform does not support them or
    *** it was explicitly requested with -no-undefined,
    *** libtool will only create a static version of it.

    and further-on:

    /bin/sh ../../libtool --tag=CXX --mode=link g++ -fpermissive -fopenmp -no-undefined --enable-runtime-pseudo-reloc -o libinterface.la -rpath /opt/netgen/lib nginterface.lo nginterface_v2.lo read_fnf_mesh.lo readtetmesh.lo readuser.lo writeabaqus.lo writediffpack.lo writedolfin.lo writeelmer.lo writefeap.lo writefluent.lo writegmsh.lo writejcm.lo writepermas.lo writetecplot.lo writetet.lo writetochnog.lo writeuser.lo wuchemnitz.lo writegmsh2.lo writeOpenFOAM15x.lo -lpthread
    libtool: link: g++ -shared -nostdlib c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/dllcrt2.o c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/crtbegin.o .libs/nginterface.o .libs/nginterface_v2.o .libs/read_fnf_mesh.o .libs/readtetmesh.o .libs/readuser.o .libs/writeabaqus.o .libs/writediffpack.o .libs/writedolfin.o .libs/writeelmer.o .libs/writefeap.o .libs/writefluent.o .libs/writegmsh.o .libs/writejcm.o .libs/writepermas.o .libs/writetecplot.o .libs/writetet.o .libs/writetochnog.o .libs/writeuser.o .libs/wuchemnitz.o .libs/writegmsh2.o .libs/writeOpenFOAM15x.o -lpthread -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1 -Lc:/mingw64/bin/../lib/gcc -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../lib -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../.. -lstdc++ -lgomp -lmingwthrd -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingwthrd -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/crtend.o -fopenmp -fopenmp -o .libs/libinterface-0.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libinterface.dll.a
    .libs/nginterface.o:nginterface.cpp:(.text+0x10a): undefined reference to `netgen::geometryregister'
    .libs/nginterface.o:nginterface.cpp:(.text+0x1a2): undefined reference to `netgen::geometryregister'
    .libs/nginterface.o:nginterface.cpp:(.text+0x1bb): undefined reference to `netgen::id'
    .libs/nginterface.o:nginterface.cpp:(.text+0x26a): undefined reference to `netgen::Mesh::Mesh()'
    .libs/nginterface.o:nginterface.cpp:(.text+0x291): undefined reference to >`netgen::Mesh::Load(std::istream&)'
    .libs/nginterface.o:nginterface.cpp:(.text+0x2a6): undefined reference to `netgen::geometryregister'
    .libs/nginterface.o:nginterface.cpp:(.text+0x2ed): undefined reference to `netgen::geometryregister'
    [..]
    c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/nginterface.o: bad reloc address 0x34 in section `.text$_ZN6netgen6NgLockC1ERNS_7NgMutexEb[_ZN6netgen6NgLockC1ERNS_7NgMutexEb]'

    Has anyone successfully built shared libraries using MinGW-w64?
    How to fix those undefined symbol/reference errors?

    Sorry for the lengthy post. Your help is really appreciated.

    /Daniel

     
    Last edit: Daniel 2013-11-21
    • Daniel
      Daniel
      2013-12-12

      This is still an unresolved, high-priority issue for me.
      I have been looking into this for some time now, but cannot find a workaround.

      I'd appreciate any input.

       
  • marco atzeri
    marco atzeri
    2014-07-09

    Hit the same issue working on a cygwin build.
    For what I see there is now a circular dependency on the
    split shared libraries

    $ find . -name Makefile.am
    ./doc/Makefile.am
    ./libsrc/csg/Makefile.am
    ./libsrc/general/Makefile.am
    ./libsrc/geom2d/Makefile.am
    ./libsrc/gprim/Makefile.am
    ./libsrc/include/Makefile.am
    ./libsrc/interface/Makefile.am
    ./libsrc/linalg/Makefile.am
    ./libsrc/Makefile.am
    ./libsrc/meshing/Makefile.am
    ./libsrc/occ/Makefile.am
    ./libsrc/stlgeom/Makefile.am
    ./libsrc/visualization/Makefile.am
    ./Makefile.am
    ./ng/Makefile.am
    ./nglib/Makefile.am
    ./tutorials/Makefile.am
    ./windows/Makefile.am

    nglib requires all the one under libsrc,
    but they require a set of symbols defined in nglib.

    This obstacle is unpassable on platforms that do not allow undefined symbols,
    a single shared lib is the only solution.