MOAB and mingw64 (msys2)

Issue #127 closed
Rafał Brzegowy created an issue

Hi,

If I use -DBUILD_SHARED_LIBS=OFF I was able to compile 100% moab 5.2.1 in mings64 (msys2).

But with default -DBUILD_SHARED_LIBS=ON, i have this error:

as  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/io/CMakeFiles/moabio.dir/Tqdcfr.cpp.obj:Tqdcfr.cpp:(.text+0x891a): undefined reference to `__imp__ZN4moab2CN15midNodesPerTypeE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/io/CMakeFiles/moabio.dir/WriteGMV.cpp.obj:WriteGMV.cpp:(.text+0x733): undefined reference to `__imp__ZN4moab2CN16TypeDimensionMapE'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/io/CMakeFiles/moabio.dir/WriteGMV.cpp.obj:WriteGMV.cpp:(.text+0x1368): undefined reference to `__imp__ZN4moab2CN16TypeDimensionMapE'
collect2.exe: error: ld returned 1 exit status

Best regards

Rafal

Comments (22)

  1. Vijay M

    I remember that we fixed something similar in CN definitions for VS2015/VS2017 compatible builds. I don’t have a Windows machine handy at the moment to test this. @Paul Wilson thoughts whether you can test this somewhere with mingw64 ?

  2. Paul Wilson

    We are trying to avoid the mingw dependency in our work, so I don’t think we can help build with that. However, since @Baptiste MOUGINOT (BaM) has been working in Windows recently, he may have some thought….

  3. Baptiste MOUGINOT (BaM)

    I don’t recall having such problem to fix.
    I was able to build MOAB using this CMake command line:
    cmake ../moab -DENABLE_BLASLAPACK=OFF -DENABLE_FORTRAN=OFF -DENABLE_IMESH=OFF -DENABLE_TESTING=OFF -DENABLE_HDF5=ON -DEIGEN3_DIR=/c/Users/mouginot/Desktop/eigen-3.3.8/ -G"Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX=../moab_install/ -DHDF5_hdf5_LIBRARY_RELEASE="C:/Program Files/HDF_Group/HDF5/1.8.21/lib/libhdf5_hl.lib;C:/Program Files/HDF_Group/HDF5/1.8.21/lib/libhdf5.lib;C:/Program Files/HDF_Group/HDF5/1.8.21/lib/libzlib.lib;C:/Program Files/HDF_Group/HDF5/1.8.21/lib/libszip.lib;C:/Program Files/HDF_Group/HDF5/1.8.21/lib/libhdf5_cpp.lib" -DCMAKE_EXE_LINKER_FLAGS="" -DCMAKE_MODULE_LINKER_FLAGS="" -DCMAKE_SHARED_LINKER_FLAGS="" -DCMAKE_STATIC_LINKER_FLAGS="" -DMOAB_BUILD_MBCONVERT=OFF -DMOAB_BUILD_HEXMODOPS=OFF -DMOAB_BUILD_MBSIZE=OFF -DMOAB_BUILD_MBMEM=OFF -DMOAB_BUILD_MBSKIN=OFF -DMOAB_BUILD_MBDEPTH=OFF -DMOAB_BUILD_MBTAGPROP=OFF -DMOAB_BUILD_MBGSETS=OFF -DMOAB_BUILD_SPHEREDECOMP=OFF -DMOAB_BUILD_MBSURFPLOT=OFF -DMOAB_BUILD_MBPART=OFF -DMOAB_BUILD_MBSLAVEPART=OFF -DMOAB_BUILD_MBCOUPLER=OFF -DMOAB_BUILD_MBHONODES=OFF -DMOAB_BUILD_MBUMR=OFF -DMOAB_BUILD_MBQUALITY=OFF -DMOAB_BUILD_MBTEMPEST=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe" -DBUILD_SHARED_LIBS=ON
    (with Eigen3 and I only compile MOAB library)
    I had to make some changes on MOAB that you can find in my `windows` branch. (Note that the branch is right now sightly broken as I am trying to update it with the latest version of the develop branch.

    I hope this helps, let me know if you have any questions

  4. Baptiste MOUGINOT (BaM)

    I added

    if(MSVC)
        set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
    endif()
    

    to the main CMakelists.txt (can’t recall exactly why but this might be helpful…)

  5. Rafał Brzegowy reporter

    This error persists even after adding:

    if(MSVC)
        set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
    endif()
    

    PS. I am trying to compile a MoFEM program which uses MOAB, however it has this error:

    CMake Error at cmake/FindMOAB.cmake:19 (message):
      MBCONVERT-NOTFOUND
    Call Stack (most recent call first):
      CMakeLists.txt:21 (include)
    

    What is MBCONVERT, and is any special flag required when compiling MOAB?

    My MOAB packages: https://packages.msys2.org/package/mingw-w64-x86_64-moab?repo=mingw64

  6. Baptiste MOUGINOT (BaM)

    I got the same issue, but as I only needed the MOAB lib not the executable I disabled all of them… (MBCONVERT seems to be part of what I disabled)

  7. Baptiste MOUGINOT (BaM)

    here is the list of what I disabled:
    -DMOAB_BUILD_MBCONVERT=OFF

    -DMOAB_BUILD_HEXMODOPS=OFF

    -DMOAB_BUILD_MBSIZE=OFF

    -DMOAB_BUILD_MBMEM=OFF

    -DMOAB_BUILD_MBSKIN=OFF

    -DMOAB_BUILD_MBDEPTH=OFF

    -DMOAB_BUILD_MBTAGPROP=OFF

    -DMOAB_BUILD_MBGSETS=OFF

    -DMOAB_BUILD_SPHEREDECOMP=OFF

    -DMOAB_BUILD_MBSURFPLOT=OFF

    -DMOAB_BUILD_MBPART=OFF

    -DMOAB_BUILD_MBSLAVEPART=OFF

    -DMOAB_BUILD_MBCOUPLER=OFF

    -DMOAB_BUILD_MBHONODES=OFF

    -DMOAB_BUILD_MBUMR=OFF

    -DMOAB_BUILD_MBQUALITY=OFF

    -DMOAB_BUILD_MBTEMPEST=OFF

  8. Vijay M

    The mbconvert tool should not require anything special. It works with whatever formats are available. If you have HDF5, NetCDF, PNetCDF etc then, it provides a way to convert the file formats between them. For MoFEM, I assume you need HDF5 ?

    Please also provide the CMake configure command you used and the CMakeError.log if possible so that we can better understand what is failing internally.

  9. Rafał Brzegowy reporter

    The solution is to modify line 391 in CMakeLists:

    -if (NOT WIN32) # Need further work to prepare for windows
    +if (NOT WIN32 OR MSYS OR MINGW) # Need further work to prepare for windows
    

    then compilation goes 100% (for static library) and I also get .exe files.

  10. Rafał Brzegowy reporter

    Now I try compile MOAB with MPI, the msys has MSMPI: https://packages.msys2.org/base/mingw-w64-msmpi

    With this I have tis errors:

    C:/msys64/usr/local/pkg_moab/src/moab-5.2.1/src/Internals.hpp:20: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
       20 | #pragma warning( disable : 4786 )
          |
    C:/msys64/usr/local/pkg_moab/src/moab-5.2.1/src/HigherOrderFactory.cpp: In member function 'moab::ErrorCode moab::HigherOrderFactory::convert_sequence(moab::ElementSequence*, moab::EntityHandle, moab::EntityHandle, bool, bool, bool)':
    C:/msys64/usr/local/pkg_moab/src/moab-5.2.1/src/HigherOrderFactory.cpp:135:28: warning: this statement may fall through [-Wimplicit-fallthrough=]
      135 |             mid_face_nodes = false;
    
    C:/msys64/usr/local/pkg_moab/src/moab-5.2.1/src/DualTool.cpp: In member function 'moab::ErrorCode moab::DualTool::get_graphics_points(moab::EntityHandle, std::vector<int>&, std::vector<moab::DualTool::GraphicsPoint>&)':
    
    C:/msys64/usr/local/pkg_moab/src/moab-5.2.1/src/LocalDiscretization/LinearTri.cpp: In static member function 'static moab::ErrorCode moab::LinearTri::initFcn(const double*, int, double*&)':
    
    C:/msys64/usr/local/pkg_moab/src/moab-5.2.1/src/moab/OrientedBox.hpp: In member function 'moab::ErrorCode moab::OrientedBoxTreeTool::join_trees(const moab::Range&, moab::EntityHandle&, const moab::OrientedBoxTreeTool::Settings*)':
    
    C:/msys64/usr/local/pkg_moab/src/moab-5.2.1/tools/refiner/test_mesh_refiner.cpp:122:5: error: 'gettimeofday' was not declared in this scope; did you mean 'mingw_gettimeofday'?
      122 |     gettimeofday( &tic, 0 );
          |     ^~~~~~~~~~~~
          |     mingw_gettimeofday
    

    I need moab/ParallelComm.hpp for MoFEM: http://mofem.eng.gla.ac.uk/mofem/html/

  11. Rafał Brzegowy reporter

    I did the test: compiling MOAB with MSMPI but using configure, compilation went to the end. However, the following errors occurred:

    1.

    In GeomQueryTool.cpp, Intx2MeshOnSphere.cpp and IntxUtils.cpp:

    error: 'M_PI' was not declared in this scope

    I manually replaced M_PI with 3.1415

    2.

    In size.cpp:

    size.cpp:10:10: fatal error: sys/times.h: No such file or directory
       10 | #include <sys/times.h>
    

    and

    size.cpp:578:5: error: 'tms' was not declared in this scope; did you mean 'tm'?
      578 |     tms timebuf;
          |     ^~~
          |     tm
    

    I fix this by:

    by comment line 10

    //#include <sys/times.h>
    

    and change:

    #ifdef WIN32
    

    to

    #ifndef WIN32
    

    It follows that it is rather possible to compile MOAB with MSMPI using CMakeLists.txt (I prefer Cmake).

  12. Rafał Brzegowy reporter

    Hi,

    With the new version (5.3.0) I have this error:

    C:/msys64/usr/local/pkg_moab/src/moab-5.3.0/tools/refiner/test_mesh_refiner.cpp: In function 'int TestMeshRefiner(int, char**)':
    C:/msys64/usr/local/pkg_moab/src/moab-5.3.0/tools/refiner/test_mesh_refiner.cpp:126:5: error: 'gettimeofday' was not declared in this scope; did you mean 'mingw_gettimeofday'?
      126 |     gettimeofday( &tic, 0 );
          |     ^~~~~~~~~~~~
          |     mingw_gettimeofday
    [2/314] Building CXX object tools/refiner/CMakeFiles/MOABrefiner.dir/EdgeSizeEvaluator.cpp.obj
    

  13. Vijay M

    You should be able to disable the refiner tool when you build. We are planning to do a cleanup of all unused sources/tools that are no longer actively used, and the refiner tool will be part of that deprecated archive. So unless you rely on the functionality of it, in which case it would be good to know for us, then I’d disable it.

  14. Rafał Brzegowy reporter

    I found the cause of the problem, no additional "_" as below (in test_mesh_refiner.cpp):

    -#if defined( _MINGW32_ ) || defined( _MINGW64_ )
    +#if defined( __MINGW32__ ) || defined( __MINGW64__ )
    

  15. Rafał Brzegowy reporter
    • changed status to open

    With version 5.3.1 I have this error:

    -- Found LAPACK: C:/msys64/mingw64/lib/libopenblas.dll.a
    -- Found Eigen3: C:/msys64/mingw64/include/eigen3 (Required is at least version "3.2.0")
    -- Found MPI_C: C:/msys64/mingw64/lib/libmsmpi.a (found version "2.0")
    -- Could NOT find MPI_CXX (missing: MPI_CXX_WORKS)
    CMake Error at C:/msys64/mingw64/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
      Could NOT find MPI (missing: MPI_CXX_FOUND) (found version "2.0")
    Call Stack (most recent call first):
      C:/msys64/mingw64/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
      C:/msys64/mingw64/share/cmake-3.21/Modules/FindMPI.cmake:1748 (find_package_handle_standard_args)
      CMakeLists.txt:281 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    See also "C:/msys64/usr/local/pkg_moab/src/build-x86_64-w64-mingw32/CMakeFiles/CMakeOutput.log".
    See also "C:/msys64/usr/local/pkg_moab/src/build-x86_64-w64-mingw32/CMakeFiles/CMakeError.log".
    
  16. Log in to comment