1
votes

I followed the following steps in order to build CppDB:

svn co http://cppcms.svn.sourceforge.net/svnroot/cppcms/cppdb/trunk cppdb-trunk
cd cppdb-trunk
cmake ~/Desktop/cppdb-trunk
make
make install

Afterwards, I'm trying to compile and run the file example1.cpp from the examples directory.

When I run gcc example1.cpp I get the following errors:

/tmp/ccGWenrv.o: In function main': example1.cpp:(.text+0x2a): undefined reference tostd::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 tocppdb::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 tostd::allocator::~allocator()' example1.cpp:(.text+0x91): undefined reference to cppdb::session::operator<<(char const*)' example1.cpp:(.text+0xa5): undefined reference tocppdb::statement::operator<<(void ()(cppdb::statement&))' example1.cpp:(.text+0xb4): undefined reference to cppdb::statement::~statement()' example1.cpp:(.text+0xd2): undefined reference tocppdb::session::operator<<(char const)' example1.cpp:(.text+0xe6): undefined reference to cppdb::statement::operator<<(void (*)(cppdb::statement&))' example1.cpp:(.text+0xf5): undefined reference tocppdb::statement::~statement()' example1.cpp:(.text+0x170): undefined reference to cppdb::statement::statement()' example1.cpp:(.text+0x18e): undefined reference tocppdb::session::operator<<(char const*)' example1.cpp:(.text+0x1db): undefined reference to cppdb::statement::operator<<(tm const&)' example1.cpp:(.text+0x1e8): undefined reference tocppdb::statement::operator<<(char const*)' example1.cpp:(.text+0x1fd): undefined reference to `cppdb::statement::operator=(cppdb::statement const&)'

etc.

Any suggestions?

1
You need to compile c++ files using g++. gcc assumes C language. g++ example1.cpp what does it shows?dlmeetei

1 Answers

2
votes

Try g++ example1.cpp -lcppdb. You need to link against the C++ run-time library (using g++ instead of gcc takes care of that) and against CppDB itself (the -lcppdb part). If GCC cannot find the -lcppdb library, you'll have to provide the path using -L, and you may have to use LD_LIBRARY_PATH at run time as well.