So I followed the Ubuntu instructions on the Datastax website to build the c++ driver ( http://datastax.github.io/cpp-driver/topics/building/ ).
sudo apt-add-repository ppa:linuxjedi/ppa
sudo apt-get update
sudo apt-get install g++ make cmake libuv-dev libssl-dev
git clone https://github.com/datastax/cpp-driver.git
mkdir cpp-driver/build
cd cpp-driver/build
cmake ..
make
When I try to compile using g++ I get the following error messages: test.cpp:(.text+0x11): undefined reference to cass_cluster_new' test.cpp:(.text+0x1a): undefined reference to
cass_session_new' test.cpp:(.text+0x2f): undefined reference to cass_cluster_set_contact_points' test.cpp:(.text+0x42): undefined reference to
cass_session_connect' test.cpp:(.text+0x52): undefined reference to cass_future_error_code' test.cpp:(.text+0x76): undefined reference to
cass_statement_new' test.cpp:(.text+0x8d): undefined reference to cass_session_execute' test.cpp:(.text+0x9d): undefined reference to
cass_future_error_code' test.cpp:(.text+0xb6): undefined reference to cass_future_get_result' test.cpp:(.text+0xc6): undefined reference to
cass_iterator_from_result' test.cpp:(.text+0xd8): undefined reference to cass_iterator_get_row' test.cpp:(.text+0xed): undefined reference to
cass_row_get_column_by_name' test.cpp:(.text+0x108): undefined reference to cass_value_get_string' test.cpp:(.text+0x12d): undefined reference to
cass_value_get_string' test.cpp:(.text+0x12d): undefined reference to
cass_iterator_next' test.cpp:(.text+0x142): undefined reference to cass_result_free' test.cpp:(.text+0x14e): undefined reference to
cass_iterator_free' test.cpp:(.text+0x167): undefined reference to cass_future_error_message' test.cpp:(.text+0x196): undefined reference to
cass_statement_free' test.cpp:(.text+0x1a2): undefined reference to cass_future_free' test.cpp:(.text+0x1ae): undefined reference to
cass_session_close' test.cpp:(.text+0x1be): undefined reference to cass_future_wait' test.cpp:(.text+0x1ca): undefined reference to
cass_future_free' test.cpp:(.text+0x1e3): undefined reference to cass_future_error_message' test.cpp:(.text+0x212): undefined reference to
cass_future_free' test.cpp:(.text+0x21e): undefined reference to cass_cluster_free' test.cpp:(.text+0x22a): undefined reference to
cass_session_free' collect2: error: ld returned 1 exit status
What am I missing when trying to compile: g++ test.cpp
Thank you.
You need to actually link to the previously build cassandra driver.
g++ test.cpp -Lcpp-build/build -lcassandra
-L tells g++ where it searches for libraries
-l links the library
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.