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

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

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

然而,当我试图编译它时,在这一行的 boost headers 的 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 发表评论后(并回到家)我用 boost 1.58 在 linux 上重现了这个问题。实际上,编辑 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++) 的产物。