我最近为CLion安装了MySQL Connector,因为我打算制作一个MySQL数据库程序。我已经从mysql网站安装了Connector,并尝试了website提供的代码。运行后,我发现它说boost / shared_ptr.hpp不存在。所以我去下载boost版本1.66.0并将其安装到我的C盘中。我还将这些目录添加到我的Cmake文件中,但它们仍显示错误。
这是我的Cmake文件:
cmake_minimum_required(VERSION 3.8)
project(Learn_Cpp)
set(CMAKE_CXX_STANDARD 17)
LINK_DIRECTORIES(C:/Program Files/MySQL/MySQL Connector)
LINK_DIRECTORIES(C++ 1.1.9/include C:/Boost/boost_1_66_0)
include_directories("C:/Program Files/MySQL/MySQL Connector C++ 1.1.9/include" "C:/Boost/boost_1_66_0")
set(SOURCE_FILES "C++ Tutorials/Learn.cpp" "C++ Tutorials/ClassFile.cpp" "C++ Tutorials/ClassFile.h" "C++ Tutorials/Learn.cpp")
add_executable(Learn_Cpp ${SOURCE_FILES})
我尝试解决此问题,另一个错误显示我在boost / config中没有user.hpp文件。
以下是错误消息:
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" --build C:\Users\Timothy\CLionProjects\Learn_Cpp\cmake-build-debug --target all -- -j 4
[ 33%] Building CXX object CMakeFiles/Learn_Cpp.dir/C++_Tutorials/Learn.cpp.obj
In file included from C:/Boost/boost_1_66_0/boost/smart_ptr/shared_ptr.hpp:17:0,
from C:/Boost/boost_1_66_0/boost/shared_ptr.hpp:17,
from C:/PROGRA~1/MySQL/MYSQLC~1.9/include/mysql_connection.h:31,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:9:
C:/Boost/boost_1_66_0/boost/config.hpp:30:29: fatal error: boost/config/user.hpp: No such file or directory
# include BOOST_USER_CONFIG
^
compilation terminated.
CMakeFiles\Learn_Cpp.dir\build.make:62: recipe for target 'CMakeFiles/Learn_Cpp.dir/C++_Tutorials/Learn.cpp.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/Learn_Cpp.dir/C++_Tutorials/Learn.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/Learn_Cpp.dir/all] Error 2
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/Learn_Cpp.dir/all' failed
Makefile:82: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
任何可以提供解决方案的人都将不胜感激。感谢。
更新 我解决了错误" user.hpp"但我收到另一条错误消息,这次是关于int32_t和uint32_t。我不知道这些是什么或如何解决这个问题。
这是现在的错误消息:
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" --build C:\Users\Timothy\CLionProjects\Learn_Cpp\cmake-build-debug --target Learn_Cpp -- -j 4
Scanning dependencies of target Learn_Cpp
[ 25%] Building CXX object CMakeFiles/Learn_Cpp.dir/C++_Tutorials/ClassFile.cpp.obj
[ 75%] Building CXX object CMakeFiles/Learn_Cpp.dir/C++_Tutorials/Learn.cpp.obj
[ 75%] Building CXX object CMakeFiles/Learn_Cpp.dir/C++_Tutorials/Classes_and_simple_prgm.cpp.obj
In file included from C:/PROGRA~1/MySQL/MYSQLC~1.9/include/cppconn/resultset.h:30:0,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:13:
C:/PROGRA~1/MySQL/MYSQLC~1.9/include/cppconn/config.h:95:19: error: conflicting declaration 'typedef long int int32_t'
typedef __int32 int32_t;
^~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_traits.h:420,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:5:
c:\mingw\include\stdint.h:62:15: note: previous declaration as 'typedef int int32_t'
typedef int int32_t;
^~~~~~~
In file included from C:/PROGRA~1/MySQL/MYSQLC~1.9/include/cppconn/resultset.h:30:0,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:13:
C:/PROGRA~1/MySQL/MYSQLC~1.9/include/cppconn/config.h:99:26: error: conflicting declaration 'typedef long unsigned int uint32_t'
typedef unsigned __int32 uint32_t;
^~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_traits.h:420,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:5:
c:\mingw\include\stdint.h:63:19: note: previous declaration as 'typedef unsigned int uint32_t'
typedef unsigned uint32_t;
^~~~~~~~
In file included from C:/PROGRA~1/MySQL/MYSQLC~1.9/include/cppconn/statement.h:30:0,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:14:
C:/PROGRA~1/MySQL/MYSQLC~1.9/include/cppconn/config.h:95:19: error: conflicting declaration 'typedef long int int32_t'
typedef __int32 int32_t;
^~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_traits.h:420,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:5:
c:\mingw\include\stdint.h:62:15: note: previous declaration as 'typedef int int32_t'
typedef int int32_t;
^~~~~~~
In file included from C:/PROGRA~1/MySQL/MYSQLC~1.9/include/cppconn/statement.h:30:0,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:14:
C:/PROGRA~1/MySQL/MYSQLC~1.9/include/cppconn/config.h:99:26: error: conflicting declaration 'typedef long unsigned int uint32_t'
typedef unsigned __int32 uint32_t;
^~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_traits.h:420,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from C:\Users\Timothy\CLionProjects\Learn_Cpp\C++ Tutorials\Learn.cpp:5:
c:\mingw\include\stdint.h:63:19: note: previous declaration as 'typedef unsigned int uint32_t'
typedef unsigned uint32_t;
^~~~~~~~
mingw32-make.exe[3]: *** [CMakeFiles/Learn_Cpp.dir/C++_Tutorials/Learn.cpp.obj] Error 1
mingw32-make.exe[3]: *** Waiting for unfinished jobs....
CMakeFiles\Learn_Cpp.dir\build.make:87: recipe for target 'CMakeFiles/Learn_Cpp.dir/C++_Tutorials/Learn.cpp.obj' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/Learn_Cpp.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/Learn_Cpp.dir/all] Error 2
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/Learn_Cpp.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/Learn_Cpp.dir/rule] Error 2
mingw32-make.exe: *** [Learn_Cpp] Error 2
Makefile:117: recipe for target 'Learn_Cpp' failed