Cassandra C++ 驱动程序 "undefined reference" 错误
Cassandra c++ driver "undefined reference" error
所以我按照 Datastax 网站上的 Ubuntu 说明构建了 c++ 驱动程序 (http://datastax.github.io/cpp-driver/topics/building/)。
sudo apt-add-repository ppa:linuxjedi/ppa
sudo apt-get 更新
sudo apt-get install g++ make cmake libuv-dev libssl-dev
git 克隆 https://github.com/datastax/cpp-driver.git
mkdir cpp-driver/build
cd cpp-driver/build
cmake ..
制作
当我尝试使用 g++ 进行编译时,出现以下错误消息:
test.cpp:(.text+0x11): 对 cass_cluster_new'
test.cpp:(.text+0x1a): undefined reference to
cass_session_new 的未定义引用
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_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_free' 的未定义引用
test.cpp:(.text+0x1e3): 对 cass_future_error_message'
test.cpp:(.text+0x212): undefined reference to
cass_future_free 的未定义引用
test.cpp:(.text+0x21e): 对 cass_cluster_free'
test.cpp:(.text+0x22a): undefined reference to
cass_session_free 的未定义引用
collect2:错误:ld 返回了 1 个退出状态
我在尝试编译时遗漏了什么:g++ test.cpp
谢谢。
您实际上需要 link 之前构建的 cassandra 驱动程序。
g++ test.cpp -Lcpp-build/build -lcassandra
-L 告诉 g++ 它在哪里搜索库
-l links 图书馆
所以我按照 Datastax 网站上的 Ubuntu 说明构建了 c++ 驱动程序 (http://datastax.github.io/cpp-driver/topics/building/)。
sudo apt-add-repository ppa:linuxjedi/ppa
sudo apt-get 更新
sudo apt-get install g++ make cmake libuv-dev libssl-dev
git 克隆 https://github.com/datastax/cpp-driver.git
mkdir cpp-driver/build
cd cpp-driver/build
cmake ..
制作
当我尝试使用 g++ 进行编译时,出现以下错误消息:
test.cpp:(.text+0x11): 对 cass_cluster_new'
test.cpp:(.text+0x1a): undefined reference to
cass_session_new 的未定义引用
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_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_free' 的未定义引用
test.cpp:(.text+0x1e3): 对 cass_future_error_message'
test.cpp:(.text+0x212): undefined reference to
cass_future_free 的未定义引用
test.cpp:(.text+0x21e): 对 cass_cluster_free'
test.cpp:(.text+0x22a): undefined reference to
cass_session_free 的未定义引用
collect2:错误:ld 返回了 1 个退出状态
我在尝试编译时遗漏了什么:g++ test.cpp
谢谢。
您实际上需要 link 之前构建的 cassandra 驱动程序。
g++ test.cpp -Lcpp-build/build -lcassandra
-L 告诉 g++ 它在哪里搜索库
-l links 图书馆