简体   繁体   English

CMake 和 MinGW-w64 包含路径

[英]CMake and MinGW-w64 include paths

I have a C++ project that needs to be built with CMake and MinGW-W64.我有一个需要使用 CMake 和 MinGW-W64 构建的 C++ 项目。

Some libraries (such as zlib, libpng) are in: C:\\Dev\\mingw64-5.3.0\\x86_64-w64-mingw32\\一些库(如zlib、libpng)在: C:\\Dev\\mingw64-5.3.0\\x86_64-w64-mingw32\\

So I use : -DCMAKE_PREFIX_PATH="C:\\Dev\\mingw64-5.3.0\\x86_64-w64-mingw32"所以我使用: -DCMAKE_PREFIX_PATH="C:\\Dev\\mingw64-5.3.0\\x86_64-w64-mingw32"

But, I get a compilation error because the following header is outdated and miss important symbols:但是,我收到一个编译错误,因为以下标头已过时并且缺少重要符号:

C:\Dev\mingw64-5.3.0\x86_64-w64-mingw32\include\float.h

If I add a compiler flag to search into the proper include directory for float.h:如果我添加一个编译器标志来搜索 float.h 的正确包含目录:

-DCMAKE_CXX_FLAGS="-isystem C:/Dev/mingw64-5.3.0/lib/gcc/x86_64-w64-mingw32/5.3.0/include"

Then, this does not work, since CMake will add this folder after its generated includes_CXX.rsp然后,这是行不通的,因为 CMake 会在生成 includes_CXX.rsp 之后添加这个文件夹

How can I handle this issue?我该如何处理这个问题? Is there a way to enforce header search path priority?有没有办法强制执行标题搜索路径优先级?

You could also add the include location(s) to environment variable C_INCLUDE_PATH and CPLUS_INCLUDE_PATH .您还可以将include位置添加到环境变量C_INCLUDE_PATHCPLUS_INCLUDE_PATH

To locate the libraries you can do the same for the lib with the LIBRARY_PATH environment variable.要定位库,您可以使用LIBRARY_PATH环境变量对lib执行相同的LIBRARY_PATH

For DLL and EXE files you may even need to add the bin path to PATH .对于 DLL 和 EXE 文件,您甚至可能需要将bin路径添加到PATH

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

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