gpt4 book ai didi

c++ - Cassandra C++ 驱动程序 "undefined reference"错误

转载 作者:行者123 更新时间:2023-11-28 02:15:15 27 4
gpt4 key购买 nike

所以我按照 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
cass_session_new'test.cpp:(.text+0x2f): 对 cass_cluster_set_contact_points 的 undefined reference
test.cpp:(.text+0x42): undefined reference
cass_session_connect'test.cpp:(.text+0x52): 未定义对 cass_future_error_code' 的引用
test.cpp:(.text+0x76): undefined reference
cass_statement_new'test.cpp:(.text+0x8d): 未定义对 cass_session_execute 的引用'
test.cpp:(.text+0x9d): undefined reference
cass_future_error_code'test.cpp:(.text+0xb6): 对 cass_future_get_result' 的 undefined reference
test.cpp:(.text+0xc6): undefined reference
cass_iterator_from_result'test.cpp:(.text+0xd8): 对 cass_iterator_get_row 的 undefined reference
test.cpp:(.text+0xed): undefined reference
cass_row_get_column_by_name'test.cpp:(.text+0x108): 对 cass_value_get_string' 的 undefined reference
test.cpp:(.text+0x12d): undefined reference
cass_iterator_next'test.cpp:(.text+0x142): 未定义对 cass_result_free 的引用'
test.cpp:(.text+0x14e): undefined reference
cass_iterator_free'test.cpp:(.text+0x167): 未定义对 cass_future_error_message 的引用'
test.cpp:(.text+0x196): undefined reference
cass_statement_free'test.cpp:(.text+0x1a2): 未定义对 cass_future_free 的引用'
test.cpp:(.text+0x1ae): undefined reference
cass_session_close'test.cpp:(.text+0x1be): 对 cass_future_wait' 的 undefined reference
test.cpp:(.text+0x1ca): undefined reference
cass_future_free'test.cpp:(.text+0x1e3): 未定义对 cass_future_error_message 的引用'
test.cpp:(.text+0x212): undefined reference
cass_future_free'test.cpp:(.text+0x21e): 未定义对 cass_cluster_free 的引用'
test.cpp:(.text+0x22a): undefined reference
cass_session_free'collect2:错误:ld 返回 1 退出状态

我在尝试编译时遗漏了什么:g++ test.cpp

谢谢。

最佳答案

您需要实际链接到之前构建的 cassandra 驱动程序。

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

-L 告诉 g++ 它在哪里搜索库

-l 链接库

关于c++ - Cassandra C++ 驱动程序 "undefined reference"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34230491/

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