如何在Windows上链接C ++ 17的std :: filesystem

时间:2019-04-13 16:01:16

标签: windows cmake g++ filesystems appveyor

我正在AppVeyor CI上构建一个c ++程序。我想将stdc ++文件系统库链接到我的一个可执行文件。

这是appveyor.yml的代码段

image: Visual Studio 2015
install: 
  - set PATH=%PATH:C:\Program Files\Git\usr\bin=% # trick to remove sh.exe
  - set PATH=%PATH%;C:\cygwin64\bin;C:\MinGW\bin
  - set CC=C:\cygwin64\bin\gcc.exe
  - set CXX=C:\cygwin64\bin\g++.exe
before_build:
    - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_SH="CMAKE_SH-NOTFOUND" -G"CodeBlocks - MinGW Makefiles" .
build_script:
  - mingw32-make

这是我的cmake文件

cmake_minimum_required(VERSION 3.0)
project(oop-exercises)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin/)

add_executable(check check.cpp)
add_executable(create-exercise create-exercise.cpp)
add_executable(cpp17 testcpp17.cpp)

target_link_libraries(cpp17 stdc++fs) 

install(TARGETS check create-exercise DESTINATION bin)

在Linux上工作正常。但我在传送带上出现此错误

C:\projects\oop-exercises\testcpp17.cpp:5:22: fatal error: filesystem: No such file or directory
 #include <filesystem>
                      ^
compilation terminated.
CMakeFiles\cpp17.dir\build.make:61: recipe for target 'CMakeFiles/cpp17.dir/testcpp17.cpp.o' failed
mingw32-make[2]: *** [CMakeFiles/cpp17.dir/testcpp17.cpp.o] Error 1

有关更多信息,这是我的github存储库:https://github.com/kerolloz/oop-exercises

0 个答案:

没有答案