C++ 如何在 qmake 项目中使用 Boost 库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16998326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:49:00  来源:igfitidea点击:

How do I use the Boost libraries in a qmake project?

c++qtboost

提问by ddacot

Some days ago I compiled Boost ver. 1.53.0 for VS2012. It works fine, compiles fine. Now I want to use Boost with Qt Creator. In the .profile I've included

几天前,我编译了 Boost 版本。1.53.0 用于 VS2012。它工作正常,编译正常。现在我想在 Qt Creator 中使用 Boost。在.pro我包含的文件中

INCLUDEPATH += C:\boost\boost_1_53_0\  -lboost_filesystem
LIBS += C:/boost/boost_1_53_0/stage/lib/

But when I compile I get 2 errors:

但是当我编译时,我收到 2 个错误:

:-1: error: cannot find C:/boost/boost_1_53_0/stage/lib/: Permission denied
collect2.exe:-1: error: error: ld returned 1 exit status

What should I do? I've googled but seems I'm the first with this error.

我该怎么办?我用谷歌搜索过,但似乎我是第一个遇到这个错误的人。

回答by SigTerm

INCLUDEPATH += C:\boost\boost_1_53_0\  -lboost_filesystem
LIBS += C:/boost/boost_1_53_0/stage/lib/

Wrong.

错误的。

Read this.

读这个

Solution:

解决方案:

INCLUDEPATH += C:/boost/boost_1_53_0/
LIBS += "-LC:/boost/boost_1_53_0/stage/lib/"

Boost has complicated library names ("libboost_filesystem-vc90-mt-1_53.lib") and in case of msvc it links them automatically.) If you want to link additional lib, you do it like this:

Boost 具有复杂的库名称(“libboost_filesystem-vc90-mt-1_53.lib”),并且在 msvc 的情况下它会自动链接它们。)如果你想链接额外的库,你可以这样做:

LIBS += "-LMyLibraryPath" -lmylib

Where MyLibraryPath is library path, and mylib is library you want to link with.

其中 MyLibraryPath 是库路径,而 mylib 是您要链接的库。

i'm the first with this error.

我是第一个出现这个错误的人。

The error most likely occurs because compiler tries to open directory as if it were a file or something like that.

错误很可能发生,因为编译器试图打开目录,就好像它是一个文件或类似的东西。

回答by thistleknot

win32 {
    INCLUDEPATH += C:/Users/User/Downloads/dev/boost_1_61_0
    LIBS += "-LC:/dev/Boost/lib/" \
    "-Llibboost_filesystem-mgw53-mt-d-1_61.a", "-Llibboost_system-mgw53-mt-d-1_61.a", "-Llibboost_serialization-mgw53-mt-d-1_61.a" -LLIBS

}