esa / pagmo2

A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pagmo2/
GNU General Public License v3.0
804 stars 159 forks source link

MinGW installation problem #526

Closed iosto closed 1 year ago

iosto commented 1 year ago

Hello, I am trying to run a test script (the same as found here ) to test my pagmo installation from conda. For the build process I use CMake with MinGW/Unix Makefiles as a generator, and everything seems to be going fine until it tries to link. Then I get the following error message (full output below):

[proc] Executing command: D:\Anaconda\envs\pagmo\Library\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\msys64\mingw64\bin\g++.exe -Sd:/Strathclyde/Software/MinorBodyAnalysisTool -Bd:/Strathclyde/Software/MinorBodyAnalysisTool/build -G "Unix Makefiles" [cmake] Not searching for unused variables given on the command line. [cmake] -- The CXX compiler identification is GNU 10.2.0 [cmake] -- Detecting CXX compiler ABI info [cmake] -- Detecting CXX compiler ABI info - done [cmake] -- Check for working CXX compiler: D:/msys64/mingw64/bin/g++.exe - skipped [cmake] -- Detecting CXX compile features [cmake] -- Detecting CXX compile features - done [cmake] -- WARNING: building debug version! [cmake] -- Found GSL: C:/msys64/mingw64/include (found version "2.6") [cmake] -- WARNING: building debug version! [cmake] -- Found Boost: D:/Anaconda/envs/pagmo/Library/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found version "1.78.0")
[cmake] -- Found NLOPT: D:/Anaconda/envs/pagmo/Library/lib/nlopt.lib
[cmake] -- NLOPT library: D:/Anaconda/envs/pagmo/Library/lib/nlopt.lib [cmake] -- NLOPT headers: D:/Anaconda/envs/pagmo/Library/include [cmake] -- Found OpenMP_CXX: -fopenmp (found version "4.5") [cmake] -- Found OpenMP: TRUE (found version "4.5")
[cmake] -- Found OpenMP_CXX: -fopenmp (found version "4.5") [cmake] -- Found OpenMP_CXX: -fopenmp (found version "4.5") [cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD [cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success [cmake] -- Found Threads: TRUE
[cmake] -- Required Boost libraries: serialization [cmake] -- Found Boost: D:/Anaconda/envs/pagmo/Library/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.60.0") found components: serialization [cmake] -- Detected Boost version: 1.78.0 [cmake] -- Boost include dirs: D:/Anaconda/envs/pagmo/Library/include [cmake] -- Requested IPOPT components: header [cmake] -- Found pagmo_IPOPT: D:/Anaconda/envs/pagmo/Library/include/coin-or
[cmake] -- Creating the 'pagmo::IPOPT::header' imported target. [cmake] -- Path to the ipopt headers: D:/Anaconda/envs/pagmo/Library/include/coin-or [cmake] -- Configuring done [cmake] -- Generating done [cmake] -- Build files have been written to: D:/Strathclyde/Software/MinorBodyAnalysisTool/build [main] Building folder: MinorBodyAnalysisTool pagmo_test [build] Starting build [proc] Executing command: D:\Anaconda\envs\pagmo\Library\bin\cmake.EXE --build d:/Strathclyde/Software/MinorBodyAnalysisTool/build --config Debug --target pagmo_test -j 14 -- [build] [100%] Building CXX object apps/CMakeFiles/pagmo_test.dir/Other/test_pagmo.cpp.obj [build] [100%] Linking CXX executable ../pagmo_test.exe [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj):D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:16: undefined reference to __imp__ZN5pagmo8schwefelC1Ej' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in functionmain': [build] D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:20: undefined reference to __imp__ZN5pagmo13random_device4nextEv' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:20: undefined reference toimpZN5pagmo4sadeC1Ejjjddbj' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:26: undefined reference to __imp__ZN5pagmo11archipelago6evolveEj' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:29: undefined reference toimpZN5pagmo11archipelago10wait_checkEv' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:33: undefined reference to __imp__ZNK5pagmo6island14get_populationEv' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:33: undefined reference toimpZNK5pagmo10population10champion_fEv' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:33: undefined reference to __imp__ZN5pagmo10populationD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:23: undefined reference toimpZN5pagmo11archipelagoD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:33: undefined reference to __imp__ZN5pagmo10populationD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Strathclyde/Software/MinorBodyAnalysisTool/apps/Other/test_pagmo.cpp:23: undefined reference toimpZN5pagmo11archipelagoD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function pagmo::problem::problem<pagmo::schwefel, 0>(pagmo::schwefel&&)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/problem.hpp:1049: undefined reference toimpZN5pagmo7problem17generic_ctor_implEv' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function pagmo::algorithm::algorithm<pagmo::sade, 0>(pagmo::sade&&)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/algorithm.hpp:471: undefined reference toimpZN5pagmo9algorithm17generic_ctor_implEv' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function pagmo::archipelago::archipelago<pagmo::algorithm, pagmo::problem, unsigned int, 0>(unsigned long long, pagmo::algorithm const&, pagmo::problem const&, unsigned int const&)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/archipelago.hpp:456: undefined reference toimpZN5pagmo11archipelagoC1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/archipelago.hpp:456: undefined reference to __imp__ZN5pagmo11archipelagoD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in functionvoid pagmo::archipelago::push_back<pagmo::algorithm const&, pagmo::problem const&, unsigned int const&, 0>(pagmo::algorithm const&, pagmo::problem const&, unsigned int const&)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/archipelago.hpp:550: undefined reference to __imp__ZN5pagmo11archipelago14push_back_implEOSt10unique_ptrINS_6islandESt14default_deleteIS2_EE' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in functionstd::_MakeUniq::single_object std::make_unique<pagmo::island, pagmo::algorithm const&, pagmo::problem const&, unsigned int const&>(pagmo::algorithm const&, pagmo::problem const&, unsigned int const&)': [build] D:/msys64/mingw64/include/c++/10.2.0/bits/unique_ptr.h:962: undefined reference to __imp__ZN5pagmo13random_device4nextEv' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in functionpagmo::island::island<pagmo::algorithm const&, pagmo::problem const&, 0>(pagmo::algorithm const&, pagmo::problem const&, unsigned long long, unsigned int)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/island.hpp:684: undefined reference to `impZN5pagmo10populationD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/island.hpp:684: undefined reference to `impZN5pagmo10populationD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function std::default_delete<pagmo::island>::operator()(pagmo::island*) const': [build] D:/msys64/mingw64/include/c++/10.2.0/bits/unique_ptr.h:85: undefined reference toimpZN5pagmo6islandD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function pagmo::population::population<pagmo::problem const&, 0>(pagmo::problem const&, unsigned long long, unsigned int)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/population.hpp:128: undefined reference toimpZN5pagmo7problemC1ERKS0_' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/population.hpp:130: undefined reference to __imp__ZN5pagmo10population14prob_ctor_implEy' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in functionpagmo::detail::island_data::island_data<pagmo::algorithm const&, pagmo::population>(pagmo::algorithm const&, pagmo::population&&)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/island.hpp:281: undefined reference to __imp__ZN5pagmo8r_policyC1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/island.hpp:281: undefined reference toimpZN5pagmo8s_policyC1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/island.hpp:281: undefined reference to __imp__ZN5pagmo6detail10task_queueC1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/island.hpp:283: undefined reference toimpZN5pagmo6detail14island_factoryE' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/island.hpp:281: undefined reference to __imp__ZN5pagmo6detail10task_queueD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in functionvoid gnu_cxx::new_allocator::construct<pagmo::algorithm, pagmo::algorithm const&>(pagmo::algorithm, pagmo::algorithm const&)': [build] D:/msys64/mingw64/include/c++/10.2.0/ext/newallocator.h:150: undefined reference to `impZN5pagmo9algorithmC1ERKS0' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function `void __gnu_cxx::new_allocator::construct<pagmo::population, pagmo::population>(pagmo::population, pagmo::population&&)': [build] D:/msys64/mingw64/include/c++/10.2.0/ext/newallocator.h:150: undefined reference to `impZN5pagmo10populationC1EOS0' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function pagmo::detail::prob_inner<pagmo::schwefel>::fitness(std::vector<double, std::allocator<double> > const&) const': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/problem.hpp:525: undefined reference toimpZNK5pagmo8schwefel7fitnessERKSt6vectorIdSaIdEE' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function pagmo::detail::prob_inner<pagmo::schwefel>::get_bounds() const': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/problem.hpp:529: undefined reference toimpZNK5pagmo8schwefel10get_boundsEv' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function pagmo::detail::algo_inner<pagmo::sade>::evolve(pagmo::population const&) const': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/algorithm.hpp:222: undefined reference toimpZN5pagmo10populationC1ERKS0_' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/algorithm.hpp:222: undefined reference to __imp__ZNK5pagmo4sade6evolveENS_10populationE' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/algorithm.hpp:222: undefined reference toimpZN5pagmo10populationD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Anaconda/envs/pagmo/Library/include/pagmo/algorithm.hpp:222: undefined reference to __imp__ZN5pagmo10populationD1Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in functionvoid pagmo::detail::algo_inner::set_seed_impl<pagmo::sade, 0>(pagmo::sade&, unsigned int)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/algorithm.hpp:257: undefined reference to __imp__ZN5pagmo4sade8set_seedEj' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in functionstd::cxx11::basic_string<char, std::char_traits, std::allocator > pagmo::detail::algo_inner::get_extra_info_impl<pagmo::sade, 0>(pagmo::sade const&)': [build] D:/Anaconda/envs/pagmo/Library/include/pagmo/algorithm.hpp:327: undefined reference to `impZNK5pagmo4sade14get_extra_infoB5cxx11Ev' [build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/pagmo_test.dir/objects.a(test_pagmo.cpp.obj): in function `void gnu_cxx::new_allocator::destroy(pagmo::population*)': [build] D:/msys64/mingw64/include/c++/10.2.0/ext/new_allocator.h:156: undefined reference to `impZN5pagmo10populationD1Ev' [build] collect2.exe: error: ld returned 1 exit status [build] make[3]: [apps/CMakeFiles/pagmo_test.dir/build.make:104: pagmo_test.exe] Error 1 [build] make[2]: [CMakeFiles/Makefile2:1133: apps/CMakeFiles/pagmo_test.dir/all] Error 2 [build] make[1]: [CMakeFiles/Makefile2:1140: apps/CMakeFiles/pagmo_test.dir/rule] Error 2 [build] make: [Makefile:619: pagmo_test] Error 2 [proc] The command: D:\Anaconda\envs\pagmo\Library\bin\cmake.EXE --build d:/Strathclyde/Software/MinorBodyAnalysisTool/build --config Debug --target pagmo_test -j 14 -- exited with code: 2 and signal: null [build] Build finished with exit code 2 <

I think the problem is that I am compiling using MinGW and through conda the binaries have been compiled with Visual Studio, but I cannot use Visual Studio because of some other dependencies. Is this the reason for the errors, and if so, how could I fix this without changing compiler?

Environment:

bluescarni commented 1 year ago

@iosto indeed I don't think it's possible to mix C++ binaries compiled with MSVC and MinGW.

Aside from recompiling all of pagmo's dependencies with MinGW, what could possibly work is to compile pagmo with MSVC and then write a small wrapper in pure C for interfacing with the pagmo library. As long as you stay within C (rather than C++), it should be possible to mix MinGW and MSVC.