C++11 在C+中使用libpqxx构建+;11关于Kdevelop 我试图建立一个C++程序,它需要LIPQXX函数。我在Ubuntu上,我正在尝试使用Kdevelop

C++11 在C+中使用libpqxx构建+;11关于Kdevelop 我试图建立一个C++程序,它需要LIPQXX函数。我在Ubuntu上,我正在尝试使用Kdevelop,c++11,libpqxx,C++11,Libpqxx,我用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; } 此时,构建过程可以正常工作 但是我需要做些别的事情,

我用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;
}
此时,构建过程可以正常工作

但是我需要做些别的事情,我想在C++11中工作。 因此,我添加了一个-std=c++11选项,右键单击我的项目,打开配置>Cmake>高级值>Cmake\U CXX\U标志

我得到以下错误:

/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)>
/home/francis/projects/testKDEV/build>make-j2
[100%]构建CXX对象CMakeFiles/testkdev.dir/main.cpp.o
在/usr/include/c++/4.9/memory:79:0中包含的文件中,
从/usr/include/c++/4.9/tr1/memory:39,
from/usr/include/pqxx/util.hxx:31,
从/usr/include/pqxx/util:18,
从/usr/include/pqxx/except.hxx:27开始,
自/usr/include/pqxx/except:19,
从/usr/include/pqxx/result.hxx:33,
从/usr/include/pqxx/结果:19,
来自/usr/include/pqxx/binarystring.hxx:26,
来自/usr/include/pqxx/binarystring:18,
从/usr/include/pqxx/pqxx:17,
from/home/francis/projects/testKDEV/main.cpp:2:

/usr/include/c++/4.9/functional:1034:20:错误:在“之前应该有模板名,我不知道Kdevelop,但我有类似的问题。我使用Eclipse。这是我的问题和答案。那是波兰语的,所以找人翻译一下。我的英语不太好,但我要尽我所能去transtalte

您需要libpqxx-4.0.1。下载以下软件包:

下一步:

  • 检查包:md5sum-c libpqxx-4.0.1.tar.gz.md5sum
  • 如果可以:tar-xzvf libpqxx-4.0.1.tar.gz
  • cd-libpqxx-4.0.1
  • ./configure--prefix=/usr/local--enable shared
  • 您可以选择除“/usr/local”以外的路径。将安装libpqxx

  • 澄清
  • 制造
  • 安装
  • 现在您应该在/usr/local/include中有头文件,在/usr/local/lib中有libpqxx.a、libpqxx.so。如果一切正常,请在IDE中链接库。我不知道,如何在IDE中实现这一点,但这通常是相同的,但属性位于不同的位置。例如,在Eclipse CDT中:

  • 项目/属性/ C+C++ BuID/St/GCC C++编译器/包含/包含路径类型:/Ur/Prime/I/< 在GCC C++链接器/库/库搜索路径类型中:LI>:/Ur/Prime/LIB
  • 在GCC C++链接器/库/库类型中的LI>:PQXX
  • 项目中:#包括
  • 现在尝试编译。如果可以,试着运行程序。如果你在15号岗位上遇到问题

  • 转到/etc/ld.so.conf.d/,在那里创建一个名为libpqxx-4.0.1.conf的新文件,然后打开文件并在那里键入/usr/local/lib
  • 然后发出ldconfig命令
  • 在我的例子中,使用libpqxx和C++11连接PostgreSQL就是一切。祝你好运

    /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)>
    
    error while loading shared libraries: libpqxx-4.0.so: cannot open shared object file: No such file or directory