gpt4 book ai didi

c++ - CppDB编译错误

转载 作者:行者123 更新时间:2023-12-02 10:24:48 26 4
gpt4 key购买 nike

我遵循以下步骤来构建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: In function main':
example1.cpp:(.text+0x2a): undefined reference to
std::allocator::allocator()' example1.cpp:(.text+0x42): undefined reference to 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 > const&)' example1.cpp:(.text+0x64): undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
example1.cpp:(.text+0x73): undefined reference to
std::allocator::~allocator()' example1.cpp:(.text+0x91): undefined reference to cppdb::session::operator<<(char const*)'
example1.cpp:(.text+0xa5): undefined reference to
cppdb::statement::operator<<(void ()(cppdb::statement&))' example1.cpp:(.text+0xb4): undefined reference to cppdb::statement::~statement()'
example1.cpp:(.text+0xd2): undefined reference to
cppdb::session::operator<<(char const
)' example1.cpp:(.text+0xe6): undefined reference to cppdb::statement::operator<<(void (*)(cppdb::statement&))'
example1.cpp:(.text+0xf5): undefined reference to
cppdb::statement::~statement()' example1.cpp:(.text+0x170): undefined reference to cppdb::statement::statement()'
example1.cpp:(.text+0x18e): undefined reference to
cppdb::session::operator<<(char const*)' example1.cpp:(.text+0x1db): undefined reference to cppdb::statement::operator<<(tm const&)'
example1.cpp:(.text+0x1e8): undefined reference to
cppdb::statement::operator<<(char const*)' example1.cpp:(.text+0x1fd): undefined reference to `cppdb::statement::operator=(cppdb::statement const&)'



等等

有什么建议么?

最佳答案

尝试g++ example1.cpp -lcppdb。您需要链接到C++运行时库(使用g++代替gcc来解决)和CppDB自身(链接-lcppdb部分)。如果GCC找不到-lcppdb库,则必须使用-L提供路径,并且可能还必须在运行时使用LD_LIBRARY_PATH

关于c++ - CppDB编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45299912/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com