我试图在QT Creator中使用最新版本的PicklingTools(http://www.picklingtools.com/)。我只想打开一个与PicklingTools文件一起下载的pickle示例文件。所以我的main.cpp文件看起来很基本:
#include <iostream>
#include "chooseser.h"
using namespace std;
int main()
{
Val result;
LoadValFromFile("../PicklingTools163Release/C++/SamplePickles/p7.pkl",result,SERIALIZE_P0);
return 0;
}
我按以下方式编辑了.pro文件:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp \
INCLUDEPATH += ../PicklingTools163Release/C++/
INCLUDEPATH += ../PicklingTools163Release/C++/opencontainers_1_8_4/include/
LIBS += -pthread
HEADERS += \
../PicklingTools163Release/C++/chooseser.h \
QMAKE_CXXFLAGS += -std=c++0x -pthread
QMAKE_CXXFLAGS += -fno-strict-aliasing -DLINUX_ -DOC_NEW_STYLE_INCLUDES -Wno-deprecated -I../PicklingTools163Release/C++/opencontainers_1_8_4/include -I../PicklingTools163Release/C++ -pthread -D_REENTRANT
目前我收到多个未定义的引用错误:
- Fehler: undefined reference to `OC::CopyPrintableBufferToVector(char const*, unsigned long, char*, unsigned long)'
- Fehler: undefined reference to `OC::P2TopLevelLoadVal(OC::Val&, char*)'
- Fehler: undefined reference to `OC::OpalLoadSomeTable(OC::Val&, char*, bool, OC::MachineRep_e)'
- Fehler: undefined reference to `OC::CopyPrintableBufferToVector(char const*, unsigned long, char*, unsigned long)'
- Fehler: undefined reference to `OC::MakeVector(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, char const*, unsigned long)'
我想我需要进一步编辑.pro
文件,但现在我不知道该怎么做。
答案 0 :(得分:1)
OpenContainers代码仅作为INCLUDE使用,即,您不必链接任何东西以使用OpenContainers代码(OC :: Val,OC :: Tab等)。但是!
要使用任何Pickling代码(例如您在P2TopLevelLoadVal
,MakeVector
等处看到的未定义条目),您需要构建并链接到ptools库。该库包含所有Python酸洗代码。
% cd /home/me/PicklingTools163Release/C++
% make -f Makefile.Linux libptools.so
# .... builds a lot of files, and put them into libptools.so ....
# Update your Makefile to link against libptools.so
希望有所帮助。链接到Makefile中的libptools.so
。