简体   繁体   English

将Boost库添加到Qt项目时出现LNK1104错误

[英]LNK1104 Error when adding Boost library to Qt project

M'kay so I'm new to Qt and I'm trying to include the boost/filesystem lib to my project. 恩,所以我是Qt新手,我正在尝试将boost/filesystem lib包含到我的项目中。 However, when I try to build it, I always get this error: 但是,当我尝试构建它时,总是会出现此错误:

LNK1104: File "libboost_filesystem-vc140-mt-1_61.lib" cannot be opened. LNK1104:无法打开文件“ libboost_filesystem-vc140-mt-1_61.lib”。

Now, I know that this library needs to be build beforehand, so, as described on the Boost-Website I made: 现在,我知道该库需要预先构建,因此,正如我在Boost网站上所述:

bootstrap
.\b2

and it built just fine. 它的构建还不错。 I also used the Qt dialog to add the libary to my project, my .pro-file looks like this: 我还使用Qt对话框将库添加到我的项目中,我的.pro文件如下所示:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = ProjectName
TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp \
    someclass.cpp \
    someclass2.cpp

HEADERS  += mainwindow.h \
    someclass.h \
    someclass2.h

FORMS    += mainwindow.ui

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61
else:unix: LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61

INCLUDEPATH += $$PWD/boost
DEPENDPATH += $$PWD/boost

Apparently, I did something wrong, but I can't figure out, WHAT exactly it is. 显然,我做错了什么,但我不知道是什么。 The internet knows the problem, but it seems there's no "easy" solution to it. 互联网知道问题所在,但是似乎没有“简单”的解决方案。

Turned out, my project didn't like the lib-version. 原来,我的项目不喜欢lib版本。

I rebuilt my lib files: 我重建了我的lib文件:

>b2 --build-dir="destination/directory" toolset=msvc --build-type=complete link=static threading=multi --with-filesystem stage

Then, I used the library in 然后,我在

release/link-static/runtime-link-static/threading-multi/  

Which is: 这是:

libboost_filesystem-vc140-mt-s-1_61

And re-ran qmake for the .pro-file. 并为.pro文件重新运行qmake。 Then built and executed the application and the error is gone. 然后构建并执行该应用程序,错误消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM