rmcantin / bayesopt

BayesOpt: A toolbox for bayesian optimization, experimental design and stochastic bandits.
GNU Affero General Public License v3.0
396 stars 92 forks source link

Build Fails for BAYESOPT_BUILD_SHARED=ON #30

Closed Hana-Ali closed 6 months ago

Hana-Ali commented 1 year ago

Hello,

First off, thank you for creating this library! I'm really excited to use it in my dissertation, but unfortunately I've been getting errors trying to build it. When I build it as static libraries (BAYESOPT_BUILD_SHARED=OFF), it works fine, but when I want shared libraries it doesn't.

I'm currently trying to implement this to as a distutils python extension, where the BO runs in a C++ file that receives input from a Python file. To do this, I need shared libraries to link in the Extension(), which unfortunately doesn't work. I've tried building and compiling with both MINGW32 and MSVC, both fail to compile with the following errors:


C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text$_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE[_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE]+0xf1): undefined reference to `bayesopt::utils::FileParser::FileParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int)'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text$_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE[_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE]+0x78a): undefined reference to `bayesopt::utils::FileParser::openInput()'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text$_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE[_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE]+0x7e3): undefined reference to `bayesopt::utils::FileParser::read(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text$_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE[_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE]+0xb1d): undefined reference to `bayesopt::utils::FileParser::close()'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text$_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE[_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE]+0xb46): undefined reference to `bayesopt::utils::FileParser::~FileParser()'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text$_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE[_ZN17SystemCallsBranin14evaluateSampleERKN5boost7numeric5ublas6vectorIdNS2_15unbounded_arrayIdSaIdEEEEE]+0xef5): undefined reference to `bayesopt::utils::FileParser::~FileParser()'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text.startup+0x2b): undefined reference to `bayesopt::Parameters::Parameters()'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text.startup+0xb4): undefined reference to `bayesopt::utils::ParamLoader::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bayesopt::Parameters&)'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\branin_system_calls.dir/objects.a(branin_system_calls.cpp.obj):branin_system_calls.cpp:(.text.startup+0x498): undefined reference to `bayesopt::Parameters::Parameters(bopt_params)'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [examples\CMakeFiles\branin_system_calls.dir\build.make:101: bin/branin_system_calls.exe] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:190: examples/CMakeFiles/branin_system_calls.dir/all] Error 2
mingw32-make: *** [Makefile:135: all] Error 2

I'm not sure what the error is or how to fix it, any help is appreciated!

Thanks, Hana

rmcantin commented 9 months ago

Sorry, I never got the Python interface running on Windows. The library management is beyond my expertise.

Hana-Ali commented 6 months ago

No worries at all. Thanks for your response :)