致命错误 C1083:无法打开包含文件:"boost/variant.hpp":没有此类文件或目录
fatal error C1083: Cannot open include file: 'boost/variant.hpp': No such file or directory
我正在做一个2天后到期的项目,在过去的2天里,我一直在寻找一种方法来让它工作。我对c++相当陌生,我们的Class项目要求我们使用c++制作5款游戏,并将它们导出到MySQL数据库中作为高分表。
MySQL数据库完全没有问题。我唯一的问题是让c++连接到MySQL数据库。
所以这里有一些更多的信息,以防有人能帮助我。
我使用Visual Studio 2010和2012。(就像我有VS 2012,而我的学校有2010,所以我不知道是否有任何兼容性差异,但我也有VS2010)。
我已经在网上搜索了5个小时或更多关于这些事情,比如为什么我的"#include"语句不起作用,我已经学会了进入项目属性和添加不同的包含库。通常在冲浪一段时间后,我可以弄清楚我错在哪里,但在这里我只是遇到了一个死胡同,因为我能找到的唯一帮助,包括boost,我已经做了,但我完全难住了这一点。我的朋友们都开始不耐烦了,因为这是我们剩下的最后一件事了。
这是我认为我应该包括的东西。
我正在做的两个测试程序的My include(两者完全相同)
"Additional Include Directories"
C:UsersDamianDesktopboost_1_53_0boost_1_53_0boost
C:Program FilesMySQLMySQL Connector C++ 1.1.3include
C:Program FilesMySQLMySQL Server 5.6include
My Linker->"Additional Library Directories"
C:UsersDamianDesktopboost_1_53_0boost_1_53_0boost
C:Program FilesMySQLMySQL Connector C++ 1.1.3libopt
C:Program FilesMySQLMySQL Server 5.6lib
我正在运行的两个程序的代码。
这个是我在Visual Studio 2012上测试的
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
#include <stdlib.h>
#include <Windows.h>
#include <mysql.h>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#define host "localhost"
#define username "username"
#define password "password"
#define database "db_test"
int main()
{
MYSQL* conn;
conn = mysql_init( NULL );
if( conn )
{
mysql_real_connect( conn, host, username, password, database, 0, NULL, 0 );
}
MYSQL_RES* res_set;
MYSQL_ROW row;
unsigned int i;
mysql_query( conn, "SELECT * FROM tbl_clients WHERE id = 1" );
res_set = mysql_store_result( conn );
unsigned int numrows = mysql_num_rows( res_set );
if( numrows )
{
row = mysql_fetch_row( res_set );
if( row != NULL )
{
cout << "Client ID : " << row[0] << endl;
cout << "Client Name: " << row[1] << endl;
}
}
if( res_set )
{
mysql_free_result( res_set );
}
if( conn )
{
mysql_close( conn );
}
return 0;
}
这是我试图在Visual Studio 2010上编译的代码
#include <stdio.h>
#define W32_LEAN_AND_MEAN
#include <winsock2.h>
#include "mysql.h"
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <iostream>
// change these to suit your setup
#define TABLE_OF_INTEREST "highscores"
#define SERVER_NAME "127.0.0.1"
#define DB_USER "root"
#define DB_USERPASS "root"
#define DB_NAME "test"
// prototypes
void showTables(MYSQL*);
void showContents(MYSQL*,const char*);
using namespace std;
int main(int argc, char* argv[])
{
MYSQL *hnd=NULL; // mysql connection handle
const char *sinf=NULL; // mysql server information
hnd = mysql_init(NULL);
if (NULL == mysql_real_connect(hnd,SERVER_NAME,DB_USER,DB_USERPASS,DB_NAME,0,NULL,0))
{
fprintf(stderr,"Problem encountered connecting to the %s database on %s.n",DB_NAME,SERVER_NAME);
}
else
{
fprintf(stdout,"Connected to the %s database on %s as user '%s'.n",DB_NAME,SERVER_NAME,DB_USER);
sinf = mysql_get_server_info(hnd);
if (sinf != NULL)
{
fprintf(stdout,"Got server information: '%s'n",sinf);
showTables(hnd);
showContents(hnd,TABLE_OF_INTEREST);
}
else
{
fprintf(stderr,"Failed to retrieve the server information string.n");
}
mysql_close(hnd);
}
return 0;
}
void showTables(MYSQL *handle)
{
MYSQL_RES *result=NULL; // result of asking the database for a listing of its tables
MYSQL_ROW row; // one row from the result set
result = mysql_list_tables(handle,NULL);
row = mysql_fetch_row(result);
fprintf(stdout,"Tables found:nn");
while (row)
{
fprintf(stdout,"t%sn",row[0]);
row = mysql_fetch_row(result);
}
mysql_free_result(result);
fprintf(stdout,"nEnd of tablesn");
return;
}
void showContents
(
MYSQL *handle,
const char *tbl
)
{
MYSQL_RES *res=NULL; // result of querying for all rows in table
MYSQL_ROW row; // one row returned
char sql[1024], // sql statement used to get all rows
commastr[2]; // to put commas in the output
int i,numf=0; // number of fields returned from the query
sprintf(sql,"select * from %s",tbl);
fprintf(stdout,"Using sql statement: '%s' to extract all rows from the specified table.n",sql);
if (!mysql_query(handle,sql))
{
res = mysql_use_result(handle);
if (res)
{
numf = mysql_num_fields(res);
row = mysql_fetch_row(res);
fprintf(stdout,"Rows returned:nn");
while (row)
{
commastr[0]=commastr[1]=(char)NULL;
for (i=0;i<numf;i++)
{
if (row == NULL)
{
fprintf(stdout,"%sNULL",commastr);
}
else
{
fprintf(stdout,"%s%s",commastr,row);
}
commastr[0]=',';
}
fprintf(stdout,"n");
row = mysql_fetch_row(res);
}
fprintf(stdout,"nEnd of rowsn");
mysql_free_result(res);
}
else
{
fprintf(stderr,"Failed to use the result acquired!n");
}
}
else
{
fprintf(stderr,"Failed to execute query. Ensure table is valid!n");
}
return;
}
现在这两个都给出了这个错误
1>c:program filesmysqlmysql connector c++ 1.1.3includecppconnconnection.h(31): fatal error C1083: Cannot open include file: 'boost/variant.hpp': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
请帮忙!注意:我只是试图连接到数据库成功,所以我可以运行不同的查询和什么的。这些程序只是我从别处复制来的测试程序。
谢谢! !
我想
"Additional Include Directories"
C:UsersDamianDesktopboost_1_53_0boost_1_53_0boost
必须是
"Additional Include Directories"
C:UsersDamianDesktopboost_1_53_0boost_1_53_0
相关文章:
- 如何将class.cpp和class.hpp编译为一个.o文件
- g++ -I 和 -L 命令来查找不起作用的 .hpp 文件
- Gnuplot_i.hpp C++接口绘制局部变量而不是文件
- 致命错误:找不到'boost/uuid/uuid.hpp'文件
- 造成致命错误:boost/fusion/iterator/equal_to.hpp 没有这样的文件或目录
- 无法使包含.hpp文件与其中的2个文件一起使用
- 在指向现有内存地址的 hpp 文件中声明成员函数的最佳方法
- 无法打开包含文件'Graphics.hpp'没有这样的文件或目录,Visual Studio的其他包含不起作用
- 编译器正在查找.当"实施"完全在"我的"中时的CPP文件.HPP文件
- 我的项目中某些仅标头文件不能包含使用 CMake 和 Vscode 的"SFML/Graphics.hpp"
- 如何正确使用hpp文件和cpp文件中的嵌套类
- 错误: C1083: 无法打开包含文件:"boost/asio.hpp": 没有此类文件或目录
- 从一个cpp中给出所使用的头文件和hpp文件的列表
- 如何在 CMakeList 中包含 h/hpp 头文件.txt而不是 cpp 或其他 hpp 文件
- CMake add_executable() 使用.cpp文件或 .hpp 文件
- <opencv2/opencv.hpp>, <opencv2/imgproc.hpp>, <opencv2/highgui.hpp> 没有这样的文件或目录
- 添加 boost 文件系统.hpp 无法编译
- 我可以使用 cmake/make 编译我使用的所有且仅编译 cpp/hpp 文件吗?
- 将函数及其实现移动到与主文件不同的文件(.hpp 和 .cpp)时,性能会受到很大影响
- 如何使用g++获取C++头文件(.hpp)的程序集代码