首页 > 解决方案 > Qt 创建者的 std::filesystem 链接器错误

问题描述

首先,是的,我看到了这个话题: How to Avoid std::filesystem linker errors with Qt?

我有我的 c++ 项目,在那里我使用了 std::filesystem 。我可以用 cmd ( g++ (GCC) 9.2.0 ) 编译它,例如:

g++ -std=c++17 -Wall -Wconversion-null -c client.cpp -o c.o -lstdc++fs

但有了这个 .pro 文件:

LIBS += -lws2_32
LIBS += -lstdc++fs

QT -= gui

CONFIG += c++17
CONFIG -= app_bundle

QMAKE_LFLAGS += -lstdc++fs

DEFINES += QT_DEPRECATED_WARNINGS

SOURCES += \
        client.cpp \
        logmsg.cpp \
        main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

HEADERS += \
    client.h \
    includes.h

不能这样做,我不明白为什么。

错误:

   filesystem: No such file or directory
    #include <filesystem>

          ^~~~~~~~~~~~

标签: c++qtg++linker-errorsstd-filesystem

解决方案


推荐阅读