我正在尝试构建一个需要 lipqxx 功能的 C++ 程序。我在 Ubuntu 上,我正在尝试使用 Kdevelop。
我用 Code::Blocks 成功地做到了,但我正在努力寻找更好的 IDE。
现在,我用 Kdevelop 做了什么。我创建了一个简单的示例:
#include <pqxx/pqxx>
int main(int argc, char **argv) {
pqxx::connection c("dbname=xx host=localhost user=xx password=xx");
return 0;
}
我修改了 CmakeList.txt 以包含 pqxx 目录并与 libpqxx.so 链接:
cmake_minimum_required(VERSION 2.6)
project(testkdev)
include_directories ("/usr/include/pqxx")
LINK_DIRECTORIES("/usr/lib")
add_executable(testkdev main.cpp)
TARGET_LINK_LIBRARIES(testkdev libpqxx.so)
install(TARGETS testkdev RUNTIME DESTINATION bin)
此时,构建过程开始工作。
但我需要做些别的事情,我想在 C++11 中工作。所以我添加了一个 -std=c++11 选项,右键单击我的项目,打开 Configuration > Cmake > Advanced Values > CMAKE_CXX_FLAGS。
我收到以下错误:
/home/francis/projects/testKDEV/build> make -j2
[100%] Building CXX object CMakeFiles/testkdev.dir/main.cpp.o
In file included from /usr/include/c++/4.9/memory:79:0,
from /usr/include/c++/4.9/tr1/memory:39,
from /usr/include/pqxx/util.hxx:31,
from /usr/include/pqxx/util:18,
from /usr/include/pqxx/except.hxx:27,
from /usr/include/pqxx/except:19,
from /usr/include/pqxx/result.hxx:33,
from /usr/include/pqxx/result:19,
from /usr/include/pqxx/binarystring.hxx:26,
from /usr/include/pqxx/binarystring:18,
from /usr/include/pqxx/pqxx:17,
from /home/francis/projects/testKDEV/main.cpp:2:
/usr/include/c++/4.9/functional:1034:20: error: expected template-name before ‘<’ token
: tuple_element<__i, _Tuple> { };
^
/usr/include/c++/4.9/functional:1034:20: error: expected ‘{’ before ‘<’ token
/usr/include/c++/4.9/functional:1034:20: error: expected unqualified-id before ‘<’ token
/usr/include/c++/4.9/functional:1054:17: error: ‘tuple_size’ was not declared in this scope
(__i < tuple_size<_Tuple>::value)>
^
/usr/include/c++/4.9/functional:1054:35: error: ‘::value’ has not been declared
(__i < tuple_size<_Tuple>::value)>
它继续错误......有人可以帮我理解我做错了什么吗?