简体   繁体   English

Cassandra C ++驱动程序“未定义引用”错误

[英]Cassandra c++ driver “undefined reference” error

So I followed the Ubuntu instructions on the Datastax website to build the c++ driver ( http://datastax.github.io/cpp-driver/topics/building/ ). 因此,我按照Datastax网站上的Ubuntu指示来构建c ++驱动程序( http://datastax.github.io/cpp-driver/topics/building/ )。

sudo apt-add-repository ppa:linuxjedi/ppa sudo apt-add-repository ppa:linuxjedi / ppa

sudo apt-get update sudo apt-get更新

sudo apt-get install g++ make cmake libuv-dev libssl-dev 须藤apt-get install g ++ make cmake libuv-dev libssl-dev

git clone https://github.com/datastax/cpp-driver.git git clone https://github.com/datastax/cpp-driver.git

mkdir cpp-driver/build mkdir cpp驱动程序/构建

cd cpp-driver/build cd cpp驱动程序/构建

cmake .. 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 当我尝试使用g ++进行编译时,出现以下错误消息:test.cpp :(。text + 0x11):对cass_cluster_new' test.cpp:(.text+0x1a): undefined reference to未定义引用cass_cluster_new' test.cpp:(.text+0x1a): undefined reference to cass_session_new'的cass_cluster_new' test.cpp:(.text+0x1a): undefined reference to test.cpp: (.text + 0x2f):未定义对cass_cluster_set_contact_points' test.cpp:(.text+0x42): undefined reference to cass_session_connect'test.cpp :(。text + 0x52):未定义对cass_future_error_code' test.cpp:(.text+0x76): undefined reference to cass_statement_new'test.cpp :(。text + 0x8d):未定义对cass_session_execute' test.cpp:(.text+0x9d): undefined reference to cass_future_error_code'test.cpp :(。text + 0xb6):未定义对cass_future_get_result' test.cpp:(.text+0xc6): undefined reference to cass_iterator_from_result'test.cpp :(。text + 0xd8):未定义对cass_iterator_get_row' test.cpp:(.text+0xed): undefined reference to cass_row_get_column_by_name'test.cpp :(。text + 0x108):未定义引用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 cass_value_get_string' test.cpp:(.text+0x12d): undefined reference to cass_iterator_next'test.cpp :(。text + 0x142)的引用:未定义对cass_result_free' test.cpp:(.text+0x14e): undefined reference to cass_iterator_free'test.cpp的引用:(。text + 0x167):未定义参考到cass_future_error_message' test.cpp:(.text+0x196): undefined reference to cass_statement_free'test.cpp :(。text + 0x1a2):未定义对cass_future_free' test.cpp:(.text+0x1ae): undefined reference to cass_session_close 'test.cpp :(。text + 0x1be):对cass_future_wait' test.cpp:(.text+0x1ca): undefined reference to未定义引用cass_future_wait' test.cpp:(.text+0x1ca): undefined reference to cass_future_free的cass_future_wait' test.cpp:(.text+0x1ca): undefined reference to test.cpp :(。text + 0x1e3):对cass_future_error_message' test.cpp:(.text+0x212): undefined reference to未定义引用cass_future_error_message' test.cpp:(.text+0x212): undefined reference to cass_future_free'测试的cass_future_error_message' test.cpp:(.text+0x212): undefined reference to cass_cluster_free'测试的未定义引用cass_cluster_free' test.cpp:(.text+0x22a): undefined reference to cass_session_free'的cass_cluster_free' test.cpp:(.text+0x22a): undefined reference to collect2:错误:ld返回1个退出状态

What am I missing when trying to compile: g++ test.cpp 我在尝试编译时缺少什么:g ++ test.cpp

Thank you. 谢谢。

You need to actually link to the previously build cassandra driver. 您实际上需要链接到以前构建的cassandra驱动程序。

g++ test.cpp -Lcpp-build/build -lcassandra

-L tells g++ where it searches for libraries -L告诉g ++它在哪里搜索库

-l links the library -l链接库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM