简体   繁体   English

/ usr / bin / ld:找不到-lcassandra

[英]/usr/bin/ld: cannot find -lcassandra

I just installed the C/C++ driver for cassandra and trying to run the simple program from examples directory but 我刚刚为cassandra安装了C / C ++驱动程序,并尝试从examples目录运行简单程序,但是

I am not able to resolve this error. 我无法解决此错误。 /usr/bin/ld: cannot find -lcassandra / usr / bin / ld:找不到-lcassandra


Here is my cassandra: 这是我的卡桑德拉:

root@iWanUbuntu-1:~/connect_cassandra_cpp/cpp-driver/examples/simple# which cassandra
/usr/sbin/cassandra

Here is the CMakeLists.txt: 这是CMakeLists.txt:

 cmake_minimum_required(VERSION 2.6.4)

 set(PROJECT_NAME_STR cassandra)
 set(PROJECT_LIB_NAME ${PROJECT_NAME_STR})

 set(PROJECT_LIB_NAME_TARGET ${PROJECT_LIB_NAME})

 set(PROJECT_SOURCE_DIR /root/connect_cassandra_cpp/cpp-driver)

 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".")
 set(PROJECT_EXAMPLE_NAME simple)

 file(GLOB EXAMPLE_SRC_FILES ${PROJECT_SOURCE_DIR}/examples/simple/*.c)

 include_directories(${INCLUDES})

 add_executable(${PROJECT_EXAMPLE_NAME} ${EXAMPLE_SRC_FILES})

 target_link_libraries(${PROJECT_EXAMPLE_NAME} ${PROJECT_LIB_NAME_TARGET} ${CASS_LIBS})

 set_property(TARGET ${PROJECT_EXAMPLE_NAME} APPEND PROPERTY COMPILE_FLAGS ${EXAMPLE_C_FLAGS})

Here is auto-generated make file commands: 这是自动生成的生成文件命令:

 root@iWanUbuntu-1:~/connect_cassandra_cpp/cpp-driver/examples/simple# make --just-print

 /usr/bin/cmake -H/root/connect_cassandra_cpp/cpp-driver/examples/simple -B/root/connect_cassandra_cpp/cpp-driver/examples/simple --check-build-system 
CMakeFiles/Makefile.cmake 0

/usr/bin/cmake -E cmake_progress_start /root/connect_cassandra_cpp    /cpp-driver/examples/simple/CMakeFiles /root/connect_cassandra_cpp/cpp-driver/examples/simple/CMakeFiles/progress.marks

make -f CMakeFiles/Makefile2 all

make -f CMakeFiles/simple.dir/build.make CMakeFiles/simple.dir/depend

cd /root/connect_cassandra_cpp/cpp-driver/examples/simple && /usr/bin/cmake -E 

cmake_depends "Unix Makefiles" /root/connect_cassandra_cpp/cpp-driver/examples/simple /root/connect_cassandra_cpp/cpp-driver/examples/simple 
/root/connect_cassandra_cpp/cpp-driver/examples/simple /root/connect_cassandra_cpp/cpp-driver/examples/simple /root/connect_cassandra_cpp/cpp-driver/examples/simple/CMakeFiles/simple.dir/DependInfo.cmake --color=

make -f CMakeFiles/simple.dir/build.make CMakeFiles/simple.dir/build
/usr/bin/cmake -E cmake_echo_color --switch= --red --bold "Linking C executable simple"

/usr/bin/cmake -E cmake_link_script CMakeFiles/simple.dir/link.txt --verbose=

/usr/bin/cmake -E cmake_progress_report /root/connect_cassandra_cpp/cpp-driver/examples/simple/CMakeFiles  1

echo "Built target simple"

/usr/bin/cmake -E cmake_progress_start /root/connect_cassandra_cpp/cpp-driver/examples/simple/CMakeFiles 0
___

Full Error Output: 全错误输出:

root@iWanUbuntu-1:~/connect_cassandra_cpp/cpp-driver/examples/simple# make

-- Configuring done

-- Generating done

-- Build files have been written to: /root/connect_cassandra_cpp/cpp-driver/examples/simple

Linking C executable simple

/usr/bin/ld: cannot find -lcassandra

collect2: error: ld returned 1 exit status

CMakeFiles/simple.dir/build.make:85: recipe for target 'simple' failed

make[2]: *** [simple] Error 1

CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/simple.dir/all' failed

make[1]: *** [CMakeFiles/simple.dir/all] Error 2

Makefile:75: recipe for target 'all' failed

make: *** [all] Error 2enter code here

Edit to the question: Cassandra Installation Output: 编辑问题:Cassandra安装输出:

    root@iWanUbuntu-1:~# sudo -E apt-get install cassandra
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    cassandra is already the newest version.
    The following packages were automatically installed and are no longer required:
    fonts-dejavu-extra libatk-wrapper-java libatk-wrapper-java-jni libgif4 libgnomevfs2-0 libgnomevfs2-common libice-dev libntdb1 libpthread-stubs0-dev libsctp1 libsm-dev libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxt-dev lksctp-tools python-ntdb tzdata-java x11proto-core-dev x11proto-input dev    x11proto-kb-dev xorg-sgml-doctools xtrans-dev
    Use 'apt-get autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.

    root@iWanUbuntu-1:~# sudo -E apt-get install cassandra-devel
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package cassandra-devel
    root@iWanUbuntu-1:~#

I'm looking at the README of this project and it seems you cloned the Code section https://github.com/datastax/cpp-driver/blob/master/README.md , but you'll need also the executables. 我正在查看此项目的自述文件,似乎您已克隆了代码部分https://github.com/datastax/cpp-driver/blob/master/README.md ,但您还需要可执行文件。 Under the executables there is driver and driver-dev, and installing the driver-dev.deb package would get you the 1. header files 2. shared libs, which the compiler can't find. 在可执行文件下有driver和driver-dev,安装driver-dev.deb软件包将为您提供1.头文件2.共享库,编译器找不到。 In general your compiler is telling you it can't find libcassandra.so within /usr/lib or usr/lib64 folders. 通常,编译器会告诉您在/ usr / lib或usr / lib64文件夹中找不到libcassandra.so。 This usually is when you install the driver, but forgot to install the driver-devel package. 通常是在安装驱动程序时,但忘记安装driver-devel软件包。 Here the devel package http://downloads.datastax.com/cpp-driver/ubuntu/ or if you installed cassandra with apt-get with something like 这里的开发包http://downloads.datastax.com/cpp-driver/ubuntu/,或者您是否使用apt-get安装了cassandra并带有类似以下内容

apt-get install cassandra 

try get the devel part with 尝试获得开发部分

 apt-get install cassandra-devel

EDIT: 编辑:

Eventually I've manually compiled and installed the driver from source and then compiled the examples/simple as the other solutions (intalling cassandra-cpp-driver.rpm) did not solved the whole thread. 最终,我从源代码手动编译并安装了驱动程序,然后编译了示例/简单示例,因为其他解决方案(安装cassandra-cpp-driver.rpm)无法解决整个线程。 Just do this: 只要这样做:

git clone https://github.com/datastax/cpp-driver.git
cd cpp-driver
mkdir build
cd build
cmake ..
make
sudo make install
cd ../examples/simple 
gcc simple.c -L /usr/local/lib64 -l cassandra -I /usr/local/include -o simple.o 

Worked for me. 为我工作。 On the other hand you could search for libcassandra.so.(some crazy extension) within /usr/lib64/ and cassandra.h within /usr/include . 另一方面,您可以在/ usr / lib64 /中搜索libcassandra.so。(有些疯狂的扩展名),在/ usr / include中搜索cassandra.h。 If there just make a symbolic link /usr/lib64/libcassandra.so to /usr/lib64/libcassandra.so.(some crazy extension) and recompile 如果只是将符号链接/usr/lib64/libcassandra.so链接到/usr/lib64/libcassandra.so。(有些疯狂的扩展名)并重新编译

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

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