cannot compile c++ code using this library

132 views
Skip to first unread message

zhch...@colorado.edu

unread,
Jun 29, 2017, 8:51:34 PM6/29/17
to BayesOpt discussion
Hi everyone, I am trying to use this library and meet problems!
  I hope to compile the file in bayesopt/examples/bo_branin.
cpp myself(I know they are already compiled in "bin" and I could run bo_branin in bayesopt/bin folder so I believe installed bayesopt library sucessfully). I use the following to compile bo_branin.cpp
   g++ -std=c++11 bo_branin.cpp -o bo_branin
  Then the error shows
   fatal error: testfunctions.hpp: No such file or directory compilation terminated.

  Apparently the testfunction.hpp is in bayesopt folder but it cannot find this file. I could copy this testfunctions.hpp into example folder but then it shows it cannot find "specialtypes.hpp","
fileparser.hpp" so on and so forth.
 Those files are all in bayesopt folder but I believe to copy them into the example folder is not the way to solve it. Even I copy all of those hpp file then compile the bo_branin.cpp. The terminal gives me a bunch of errors like

 bo_branin.cpp:(.text+0x33): undefined reference to `bayesopt::Parameters::
Parameters()'
 bo_branin.cpp:(.text+0x8f): undefined reference to `bayesopt::utils::ParamLoader:
:load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bayesopt::Parameters&)'

  I believe my way to compile the bo_branin doesn't link to the library at all. Do you know how to solve this problem? Thanks a million!!

Ruben Martinez-Cantin

unread,
Jun 30, 2017, 10:56:06 AM6/30/17
to BayesOpt discussion
Please, read the manual from your compiler (gcc) about how to link to
external libraries and manage include paths. Note that BayesOpt uses
C++98, not 11.

Please keep this mailing list to questions about Bayesian optimization
or issues with the code (bugs, compatibility, etc.)

Best,

Ruben
> --
> You received this message because you are subscribed to the Google Groups
> "BayesOpt discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to bayesopt-discus...@googlegroups.com.
> To post to this group, send email to bayesopt-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/bayesopt-discussion.

Kun Kuang

unread,
Oct 25, 2017, 12:07:04 PM10/25/17
to BayesOpt discussion
Hi,

Did you solve the problem? I met the same problem, I used an example code (e.g. bo_cont.cpp) to call the project with rewriting the CMake file. But I can not compile and run the example in my computer.

在 2017年6月29日星期四 UTC-7下午5:51:34,zhch...@colorado.edu写道:

Zhaozhong Chen

unread,
Dec 9, 2017, 5:20:49 PM12/9/17
to BayesOpt discussion
g++ -std=c++11 bo_branin.cpp -o bo_branin -L /usr/local/include/bayesopt/ -l bayesopt -lnlopt -lm 
This is used to compile bayesopt library. -L is used link to to the library and offer its path. -l follows the library's name. -lnlopt -lm for the nlopt.
Also, if you meet things such as " cannot find testfunctions.hpp", these files are all in "include" file. Copy them to where the cpp file is.

Zhaozhong Chen

unread,
Dec 9, 2017, 5:39:52 PM12/9/17
to BayesOpt discussion
And if you cannot find header file in "include", it should be in "utils"


On Wednesday, October 25, 2017 at 10:07:04 AM UTC-6, Kun Kuang wrote:
Reply all
Reply to author
Forward
0 new messages