我按照以下步骤构建CppDB:
svn co http://cppcms.svn.sourceforge.net/svnroot/cppcms/cppdb/trunk cppdb-trunk
cd cppdb-trunk
cmake ~/Desktop/cppdb-trunk
make
make install
之后,我尝试编译并运行examples目录中的 example1.cpp 文件。
当我运行gcc example1.cpp
时,我收到以下错误:
/tmp/ccGWenrv.o:在函数
的未定义引用main': example1.cpp:(.text+0x2a): undefined reference to
std :: allocator :: allocator()&#39; example1.cpp :(。text + 0x42):未定义引用std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' example1.cpp:(.text+0x58): undefined reference to
cppdb :: session :: session(std :: __ cxx11 :: basic_string,std :: allocator&gt; const&amp;)&#39; example1.cpp :(。text + 0x64):未定义引用std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' example1.cpp:(.text+0x73): undefined reference to
std :: allocator :: ~addocation()&#39; example1.cpp :(。text + 0x91):未定义引用cppdb::session::operator<<(char const*)' example1.cpp:(.text+0xa5): undefined reference to
cppdb :: statement :: operator&lt;&lt;(void()(cppdb :: statement&amp;))&#39; example1.cpp :(。text + 0xb4):未定义引用cppdb::statement::~statement()' example1.cpp:(.text+0xd2): undefined reference to
cppdb :: session :: operator&lt;&lt;(char const )&#39; example1.cpp :(。text + 0xe6):未定义引用cppdb::statement::operator<<(void (*)(cppdb::statement&))' example1.cpp:(.text+0xf5): undefined reference to
cppdb :: statement ::〜statement()&#39; example1.cpp :(。text + 0x170):未定义引用cppdb::statement::statement()' example1.cpp:(.text+0x18e): undefined reference to
cppdb :: session :: operator&lt;&lt;(char const *)&#39; example1.cpp :(。text + 0x1db):未定义引用cppdb::statement::operator<<(tm const&)' example1.cpp:(.text+0x1e8): undefined reference to
cppdb :: statement :: operator&lt;&lt;(char const *)&#39; example1.cpp :(。text + 0x1fd):对`cppdb :: statement :: operator =(cppdb :: statement const&amp;)&#39;
等
有什么建议吗?
答案 0 :(得分:0)
试试g++ example1.cpp -lcppdb
。您需要链接C ++运行时库(使用g++
而不是gcc
处理)和CppDB本身(-lcppdb
部分)。如果GCC找不到-lcppdb
库,则必须使用-L
提供路径,并且您可能还必须在运行时使用LD_LIBRARY_PATH
。