Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在windows中无法从cmake中找到MySQL和Boost includes/libs_C++_Mysql_Boost_Cmake - Fatal编程技术网

C++ 在windows中无法从cmake中找到MySQL和Boost includes/libs

C++ 在windows中无法从cmake中找到MySQL和Boost includes/libs,c++,mysql,boost,cmake,C++,Mysql,Boost,Cmake,我有以下CMakeLists.txt: cmake_minimum_required(VERSION 3.7) project(TestProject) message(STATUS "start running cmake...") find_package(Boost 1.61.0 COMPONENTS system filesystem REQUIRED) set(SOURCE_FILES main.cpp) add_executable(TestProject ${SOURCE_FILE

我有以下
CMakeLists.txt

cmake_minimum_required(VERSION 3.7)
project(TestProject)
message(STATUS "start running cmake...")
find_package(Boost 1.61.0 COMPONENTS system filesystem REQUIRED)
set(SOURCE_FILES main.cpp)
add_executable(TestProject ${SOURCE_FILES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(TestProject $ENV{MYSQL_INCLUDE_DIR})
target_link_libraries(TestProject $ENV{MYSQL_LIBRARIES})
if (Boost_FOUND)
    message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
    message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
    message(STATUS "Boost_VERSION: ${Boost_VERSION}")
    include_directories(TestProject ${Boost_INCLUDE_DIRS})
    target_link_libraries(TestProject ${Boost_LIBRARIES})
endif ()
//The directory containing a CMake configuration file for Boost.
Boost_DIR:PATH=Boost_DIR-NOTFOUND

//Boost filesystem library (debug)
Boost_FILESYSTEM_LIBRARY_DEBUG:FILEPATH=Boost_FILESYSTEM_LIBRARY_DEBUG-NOTFOUND

//Boost filesystem library (release)
Boost_FILESYSTEM_LIBRARY_RELEASE:FILEPATH=Boost_FILESYSTEM_LIBRARY_RELEASE-NOTFOUND

//Path to a file.
Boost_INCLUDE_DIR:PATH=Boost_INCLUDE_DIR-NOTFOUND

//Boost system library (debug)
Boost_SYSTEM_LIBRARY_DEBUG:FILEPATH=Boost_SYSTEM_LIBRARY_DEBUG-NOTFOUND

//Boost system library (release)
Boost_SYSTEM_LIBRARY_RELEASE:FILEPATH=Boost_SYSTEM_LIBRARY_RELEASE-NOTFOUND
当我运行
cmake
时,我得到以下输出:

> "E:\JetBrains\CLion 2017.1.1\bin\cmake\bin\cmake.exe" -DCMAKE_CXX_COMPILER="F:/MinGW/bin/g++.exe" -DCMAKE_C_COMPILER="F:/MinGW/bin/gcc.exe" -G "MinGW Makefiles" ..
-- The C compiler identification is GNU 6.1.0
-- The CXX compiler identification is GNU 6.1.0
-- Check for working C compiler: F:/MinGW/bin/gcc.exe
-- Check for working C compiler: F:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: F:/MinGW/bin/g++.exe
-- Check for working CXX compiler: F:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- start running cmake...
CMake Warning at E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
  Imported targets not available for Boost version
Call Stack (most recent call first):
  E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
  E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:6 (find_package)


CMake Warning at E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
  Imported targets not available for Boost version
Call Stack (most recent call first):
  E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
  E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:6 (find_package)


CMake Error at E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1793 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)


-- Path to MySQL include directories: E:\MySQL\MySQL Connector C++ 1.1.9\include
-- Path to MySQL library directories: E:\MySQL\MySQL Connector C++ 1.1.9\lib\opt\mysqlcppconn.lib
-- Configuring incomplete, errors occurred!
See also "F:/Ubuntu_Backup/CPPs/build/CMakeFiles/CMakeOutput.log".
如果我在
Clion
中使用这个
CMakeLists.txt
,系统就能够找到Boost库。以下是我从
CLion

//The directory containing a CMake configuration file for Boost.
Boost_DIR:PATH=Boost_DIR-NOTFOUND

//Boost filesystem library (debug)
Boost_FILESYSTEM_LIBRARY_DEBUG:FILEPATH=F:/MinGW/lib/libboost_filesystem.a

//Boost filesystem library (release)
Boost_FILESYSTEM_LIBRARY_RELEASE:FILEPATH=F:/MinGW/lib/libboost_filesystem.a

//Path to a file.
Boost_INCLUDE_DIR:PATH=F:/MinGW/include

//Boost library directory DEBUG
Boost_LIBRARY_DIR_DEBUG:PATH=F:/MinGW/lib

//Boost library directory RELEASE
Boost_LIBRARY_DIR_RELEASE:PATH=F:/MinGW/lib

//Boost system library (debug)
Boost_SYSTEM_LIBRARY_DEBUG:FILEPATH=F:/MinGW/lib/libboost_system.a

//Boost system library (release)
Boost_SYSTEM_LIBRARY_RELEASE:FILEPATH=F:/MinGW/lib/libboost_system.a
但是,当我从命令行中分别运行
cmake
时,我在
CMakeCache.txt
中得到以下内容:

cmake_minimum_required(VERSION 3.7)
project(TestProject)
message(STATUS "start running cmake...")
find_package(Boost 1.61.0 COMPONENTS system filesystem REQUIRED)
set(SOURCE_FILES main.cpp)
add_executable(TestProject ${SOURCE_FILES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(TestProject $ENV{MYSQL_INCLUDE_DIR})
target_link_libraries(TestProject $ENV{MYSQL_LIBRARIES})
if (Boost_FOUND)
    message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
    message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
    message(STATUS "Boost_VERSION: ${Boost_VERSION}")
    include_directories(TestProject ${Boost_INCLUDE_DIRS})
    target_link_libraries(TestProject ${Boost_LIBRARIES})
endif ()
//The directory containing a CMake configuration file for Boost.
Boost_DIR:PATH=Boost_DIR-NOTFOUND

//Boost filesystem library (debug)
Boost_FILESYSTEM_LIBRARY_DEBUG:FILEPATH=Boost_FILESYSTEM_LIBRARY_DEBUG-NOTFOUND

//Boost filesystem library (release)
Boost_FILESYSTEM_LIBRARY_RELEASE:FILEPATH=Boost_FILESYSTEM_LIBRARY_RELEASE-NOTFOUND

//Path to a file.
Boost_INCLUDE_DIR:PATH=Boost_INCLUDE_DIR-NOTFOUND

//Boost system library (debug)
Boost_SYSTEM_LIBRARY_DEBUG:FILEPATH=Boost_SYSTEM_LIBRARY_DEBUG-NOTFOUND

//Boost system library (release)
Boost_SYSTEM_LIBRARY_RELEASE:FILEPATH=Boost_SYSTEM_LIBRARY_RELEASE-NOTFOUND
目标:在使用C++代码Cugs< /COD> < /P>构建C++项目时,获取MySQL和Boost文件和库路径的正确性
如何设置环境。正确,以便
cmake
能够找到所有必需的include文件和库?

也许您的PATH变量中没有F:/MinGW/bin? 另外,您使用哪个MinGW发行版?我向你推荐这个。它有非常方便的包管理器。 你就是这样

pacman -S mingw-w64-x86_64-boost

CMake发现boost没有任何特殊的环境配置。

也许您的PATH变量中没有F:/MinGW/bin? 另外,您使用哪个MinGW发行版?我向你推荐这个。它有非常方便的包管理器。 你就是这样

pacman -S mingw-w64-x86_64-boost
CMake发现boost没有任何特殊的环境配置