【发布时间】:2012-07-14 05:13:44
【问题描述】:
我遵循here 的示例,我的代码是相同的。
当我按照他的解释在控制台中键入 mysql_config --libs 和 mysql_config --cflags 时,我得到的输出与他显示的相同。然而,当我尝试使用
进行编译时g++ -o 输出文件 $(mysql_config --cflags) test.cpp $(mysql_config --libs)
我得到错误:
test.cpp:3:25: 错误:mysql.h: 没有这样的文件或目录
test.cpp:在函数âint main()â中:
test.cpp:6:错误:“MYSQL”未在此范围内声明
test.cpp:6:错误:âconnâ 未在此范围内声明
test.cpp:7:错误:“MYSQL_RES”未在此范围内声明
test.cpp:7:错误:âresâ 未在此范围内声明
test.cpp:8:错误:“MYSQL_ROW”未在此范围内声明
test.cpp:8:错误:预期的 `;'在“行”之前
test.cpp:13:错误:“mysql_init”未在此范围内声明
test.cpp:17:错误:“mysql_real_connect”未在此范围内声明
test.cpp:18:错误:“mysql_error”未在此范围内声明
test.cpp:19:错误:“exit”未在此范围内声明
test.cpp:22:错误:“mysql_query”未在此范围内声明
test.cpp:23:错误:“mysql_error”未在此范围内声明
test.cpp:24:错误:“exit”未在此范围内声明
test.cpp:27:错误:“mysql_use_result”未在此范围内声明
test.cpp:31:错误:“row” 未在此范围内声明
test.cpp:31:错误:“mysql_fetch_row”未在此范围内声明
test.cpp:35:错误:“mysql_free_result”未在此范围内声明
test.cpp:36:错误:“mysql_close”未在此范围内声明
当我尝试“whereis mysql”时,它会显示 /usr/bin/mysql、/usr/lib/mysql 和 /usr/share/mysql,但我不确定 mysql.h 的确切位置。我正在处理的服务器管理员说他安装了 MySQL,我确实可以使用 phpMyAdmin 创建/操作表。
另外,请给我关于这个特殊问题的建议。我知道 MySQL 的 C++ 包装器,但我现在尝试只使用 C API。谢谢!
【问题讨论】:
标签: c++ mysql compiler-errors redhat