我正在尝试将最新版本的PicklingTools(http://www.picklingtools.com/)与QT Creator一起使用。我只想打开一个与PicklingTools文件一起下载的腌制示例文件。所以我的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
文件,但是现在我不知道该怎么做。 最佳答案
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
。关于c++ - 在QT Creator中使用PicklingTools,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39597738/