无法在c++中使用Boost和Eureqa编译程序

Unable to Compile program using Boost and Eureqa in C++

本文关键字:Boost Eureqa 编译程序 c++      更新时间:2023-10-16

所以我打算在Xcode中尝试一个简单的Eureqa API示例,如下所示:https://code.google.com/p/eureqa-api/

然而,当我试图编译它时,似乎在这一行的boost头的access.hpp中有一个错误:…

{
    // note: if you get a compile time error here with a
    // message something like:
    // cannot convert parameter 1 from <file type 1> to <file type 2 &>
    // a likely possible cause is that the class T contains a 
    // serialize function - but that serialize function isn't 
    // a template and corresponds to a file type different than
    // the class Archive.  To resolve this, don't include an
    // archive type other than that for which the serialization
    // function is defined!!!
    t.serialize(ar, file_version);
}

…在'std::_1::pair'中没有名为'serialize'的成员

我该怎么做才能解决这个问题?

看起来你只是想包含标题

#include <boost/serialization/utility.hpp>

定义了std::pair<>的序列化。

EDIT在评论(和到家)之后,我在linux上用boost 1.58再现了这个问题。实际上,编辑eureqa/implementation/connection_impl.h以包含

#include <boost/serialization/utility.hpp>
#include <boost/serialization/nvp.hpp>

修复:

g++ basic_client.cpp 
    -I/home/sehe/custom/boost/ 
    -I../../ 
    -c -o basic_client.o
g++ basic_client.o 
    /home/sehe/custom/boost/stage/lib/libboost_system.a 
    /home/sehe/custom/boost/stage/lib/libboost_serialization.a 
    /home/sehe/custom/boost/stage/lib/libboost_date_time.a 
    /home/sehe/custom/boost/stage/lib/libboost_thread.a 
    -lpthread  
    -o basic_client

::_1可能是库实现(libc++)使用内联名称空间进行版本控制的工件。