我很久以前就搬进了Qt,而且我在链接库方面遇到了问题。
我使用提供的安装指南构建了 poppler-0.63 版本。
tar zippedPoppler
cd poppler
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=pathToQt5.9.2 -DCMAKE_CXX_COMPILER=clang++
make CXX=pathToclang++Compiler
sudo make install
make clear
并没有任何错误。
我已经创建了新的Qt项目,添加了
INCLUDEPATH += /Users/p.witkowski/Qt/5.9.2/clang_64/include/poppler/qt5
LIBS += -L/Users/p.witkowski/Qt/5.9.2/clang_64/lib -lpoppler -v
在包含的.cpp文件中没有任何错误 - 但是当我尝试使用poppler中的任何内容时,我发现链接错误。
的main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <poppler-qt5.h>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
Poppler::Document *doc = Poppler::Document::load("/Users/p.witkowski/Desktop/abc.pdf");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
其次是错误:
12:47:20: Running steps for project untitled1...
12:47:20: Configuration unchanged, skipping qmake step.
12:47:20: Starting: "/usr/bin/make"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../untitled1 -I. -I../../Qt/5.9.2/clang_64/include/poppler/qt5 -I../../Qt/5.9.2/clang_64/lib/QtQuick.framework/Headers -I../../Qt/5.9.2/clang_64/lib/QtGui.framework/Headers -I../../Qt/5.9.2/clang_64/lib/QtQml.framework/Headers -I../../Qt/5.9.2/clang_64/lib/QtNetwork.framework/Headers -I../../Qt/5.9.2/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/AGL.framework/Headers -I../../Qt/5.9.2/clang_64/mkspecs/macx-clang -F/Users/p.witkowski/Qt/5.9.2/clang_64/lib -o main.o ../untitled1/main.cpp
../untitled1/main.cpp:9:24: warning: unused variable 'doc' [-Wunused-variable]
Poppler::Document *doc = Poppler::Document::load("/Users/p.witkowski/Desktop/abc.pdf");
^
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.10 -Wl,-rpath,@executable_path/Frameworks -Wl,-rpath,/Users/p.witkowski/Qt/5.9.2/clang_64/lib -o untitled1.app/Contents/MacOS/untitled1 main.o qrc_qml.o -F/Users/p.witkowski/Qt/5.9.2/clang_64/lib -L/Users/p.witkowski/Qt/5.9.2/clang_64/lib -lpoppler -v -framework QtQuick -framework QtQml -framework QtNetwork -framework QtCore -framework DiskArbitration -framework IOKit -framework QtGui -framework OpenGL -framework AGL
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch x86_64 -headerpad_max_install_names -macosx_version_min 10.10.0 -o untitled1.app/Contents/MacOS/untitled1 -L/Users/p.witkowski/Qt/5.9.2/clang_64/lib -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -rpath @executable_path/Frameworks -rpath /Users/p.witkowski/Qt/5.9.2/clang_64/lib main.o qrc_qml.o -lpoppler -framework QtQuick -framework QtQml -framework QtNetwork -framework QtCore -framework DiskArbitration -framework IOKit -framework QtGui -framework OpenGL -framework AGL -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.osx.a -F/Users/p.witkowski/Qt/5.9.2/clang_64/lib
Undefined symbols for architecture x86_64:
"Poppler::Document::load(QString const&, QByteArray const&, QByteArray const&)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [untitled1.app/Contents/MacOS/untitled1] Error 1
12:47:23: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled1 (kit: TESTDesktop Qt 5.9.2 clang 64bit)
When executing step "Make"
12:47:23: Elapsed time: 00:02.