datastax的cpp驱动程序

datastax的cpp驱动程序

我在ubuntu14.04上跑步。我可以在机器上安装datastax的cpp驱动程序。
但我不能举出任何例子

Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/include/cassandra.h
-- Up-to-date: /usr/local/lib/libcassandra.so.0.7.0
-- Up-to-date: /usr/local/lib/libcassandra.so.0
-- Up-to-date: /usr/local/lib/libcassandra.so
-- Up-to-date: /usr/local/lib/libcassandra_static.a
root@ubuntu-cassandra:~/cpp-driver# cd -
/root/cpp-driver/examples/simple
root@ubuntu-cassandra:~/cpp-driver/examples/simple# strace -s 1024  -f -e execve  gcc -I /usr/local/include/ -L /usr/local/lib/ -lcassandra simple.c
execve("/usr/bin/gcc", ["gcc", "-I", "/usr/local/include/", "-L", "/usr/local/lib/", "-lcassandra", "simple.c"], [/* 23 vars */]) = 0
Process 30450 attached
[pid 30450] execve("/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1", ["/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1", "-quiet", "-I", "/usr/local/include/", "-imultiarch", "x86_64-linux-gnu", "simple.c", "-quiet", "-dumpbase", "simple.c", "-mtune=generic", "-march=x86-64", "-auxbase", "simple", "-fstack-protector", "-Wformat", "-Wformat-security", "-o", "/tmp/cc8RgD1Y.s"], [/* 26 vars */]) = 0
[pid 30450] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=30450, si_status=0, si_utime=3, si_stime=1} ---
Process 30451 attached
[pid 30451] execve("/usr/local/sbin/as", ["as", "-I", "/usr/local/include/", "--64", "-o", "/tmp/ccCetiDS.o", "/tmp/cc8RgD1Y.s"], [/* 26 vars */]) = -1 ENOENT (No such file or directory)
[pid 30451] execve("/usr/local/bin/as", ["as", "-I", "/usr/local/include/", "--64", "-o", "/tmp/ccCetiDS.o", "/tmp/cc8RgD1Y.s"], [/* 26 vars */]) = -1 ENOENT (No such file or directory)
[pid 30451] execve("/usr/sbin/as", ["as", "-I", "/usr/local/include/", "--64", "-o", "/tmp/ccCetiDS.o", "/tmp/cc8RgD1Y.s"], [/* 26 vars */]) = -1 ENOENT (No such file or directory)
[pid 30451] execve("/usr/bin/as", ["as", "-I", "/usr/local/include/", "--64", "-o", "/tmp/ccCetiDS.o", "/tmp/cc8RgD1Y.s"], [/* 26 vars */]) = 0
[pid 30451] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=30451, si_status=0, si_utime=0, si_stime=0} ---
Process 30452 attached
[pid 30452] execve("/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2", ["/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2", "--sysroot=/", "--build-id", "--eh-frame-hdr", "-m", "elf_x86_64", "--hash-style=gnu", "--as-needed", "-dynamic-linker", "/lib64/ld-linux-x86-64.so.2", "-z", "relro", "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o", "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o", "/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o", "-L/usr/local/lib/", "-L/usr/lib/gcc/x86_64-linux-gnu/4.8", "-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu", "-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib", "-L/lib/x86_64-linux-gnu", "-L/lib/../lib", "-L/usr/lib/x86_64-linux-gnu", "-L/usr/lib/../lib", "-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..", "-lcassandra", "/tmp/ccCetiDS.o", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "-lc", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "/usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o", "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o"], [/* 28 vars */]) = 0
Process 30453 attached
[pid 30453] execve("/usr/bin/ld", ["/usr/bin/ld", "--sysroot=/", "--build-id", "--eh-frame-hdr", "-m", "elf_x86_64", "--hash-style=gnu", "--as-needed", "-dynamic-linker", "/lib64/ld-linux-x86-64.so.2", "-z", "relro", "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o", "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o", "/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o", "-L/usr/local/lib/", "-L/usr/lib/gcc/x86_64-linux-gnu/4.8", "-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu", "-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib", "-L/lib/x86_64-linux-gnu", "-L/lib/../lib", "-L/usr/lib/x86_64-linux-gnu", "-L/usr/lib/../lib", "-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..", "-lcassandra", "/tmp/ccCetiDS.o", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "-lc", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "/usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o", "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o"], [/* 28 vars */]) = 0
[pid 30453] +++ exited with 1 +++
[pid 30452] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=30453, si_status=1, si_utime=2, si_stime=1} ---
/tmp/ccCetiDS.o: In function `main':
simple.c:(.text+0x1b): undefined reference to `cass_cluster_new'
simple.c:(.text+0x88): undefined reference to `cass_cluster_setopt'
simple.c:(.text+0xae): undefined reference to `cass_cluster_connect'
simple.c:(.text+0xc4): undefined reference to `cass_future_wait'
simple.c:(.text+0xd3): undefined reference to `cass_future_error_code'
simple.c:(.text+0xf5): undefined reference to `cass_future_get_session'
simple.c:(.text+0x116): undefined reference to `cass_string_init'
simple.c:(.text+0x13b): undefined reference to `cass_statement_new'
simple.c:(.text+0x155): undefined reference to `cass_session_execute'
simple.c:(.text+0x165): undefined reference to `cass_future_wait'
simple.c:(.text+0x171): undefined reference to `cass_future_error_code'
simple.c:(.text+0x190): undefined reference to `cass_future_get_result'
simple.c:(.text+0x1a0): undefined reference to `cass_iterator_from_result'
simple.c:(.text+0x1b5): undefined reference to `cass_iterator_get_row'
simple.c:(.text+0x1ca): undefined reference to `cass_row_get_column'
simple.c:(.text+0x1d9): undefined reference to `cass_value_get_string'
simple.c:(.text+0x1ea): undefined reference to `cass_row_get_column'
simple.c:(.text+0x1fc): undefined reference to `cass_value_get_bool'
simple.c:(.text+0x20d): undefined reference to `cass_row_get_column'
simple.c:(.text+0x21c): undefined reference to `cass_value_get_string'
simple.c:(.text+0x22d): undefined reference to `cass_row_get_column'
simple.c:(.text+0x23c): undefined reference to `cass_value_get_string'
simple.c:(.text+0x295): undefined reference to `cass_iterator_next'
simple.c:(.text+0x2a9): undefined reference to `cass_result_free'
simple.c:(.text+0x2b5): undefined reference to `cass_iterator_free'
simple.c:(.text+0x2c3): undefined reference to `cass_future_error_message'
simple.c:(.text+0x2fa): undefined reference to `cass_future_free'
simple.c:(.text+0x309): undefined reference to `cass_session_close'
simple.c:(.text+0x319): undefined reference to `cass_future_wait'
simple.c:(.text+0x32a): undefined reference to `cass_future_error_message'
simple.c:(.text+0x364): undefined reference to `cass_future_free'
simple.c:(.text+0x373): undefined reference to `cass_cluster_free'
collect2: error: ld returned 1 exit status
[pid 30452] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=30452, si_status=1, si_utime=0, si_stime=0} ---
+++ exited with 1 +++

我无法推断为什么会发生这种情况,因为这些库存在于路径中
另一个调试输出:link
在进一步的调查中,我分别汇编和链接了这些文件。仍然没有进展
root@ubuntu-cassandra:~/cpp-driver/examples/simple# g++ -g -v -o simpler -L /usr/local/lib/ -lcassandra simple.o
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g' '-v' '-o' 'simpler' '-L/usr/local/lib/' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o simpler /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/local/lib/ -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lcassandra simple.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
simple.o: In function `main':
simple.c:(.text+0x1b): undefined reference to `cass_cluster_new'
simple.c:(.text+0x88): undefined reference to `cass_cluster_setopt'
simple.c:(.text+0xae): undefined reference to `cass_cluster_connect'
simple.c:(.text+0xc4): undefined reference to `cass_future_wait'
simple.c:(.text+0xd3): undefined reference to `cass_future_error_code'
simple.c:(.text+0xf5): undefined reference to `cass_future_get_session'
simple.c:(.text+0x116): undefined reference to `cass_string_init'
simple.c:(.text+0x13b): undefined reference to `cass_statement_new'
simple.c:(.text+0x155): undefined reference to `cass_session_execute'
simple.c:(.text+0x165): undefined reference to `cass_future_wait'
simple.c:(.text+0x171): undefined reference to `cass_future_error_code'
simple.c:(.text+0x190): undefined reference to `cass_future_get_result'
simple.c:(.text+0x1a0): undefined reference to `cass_iterator_from_result'
simple.c:(.text+0x1b5): undefined reference to `cass_iterator_get_row'
simple.c:(.text+0x1ca): undefined reference to `cass_row_get_column'
simple.c:(.text+0x1d9): undefined reference to `cass_value_get_string'
simple.c:(.text+0x1ea): undefined reference to `cass_row_get_column'
simple.c:(.text+0x1fc): undefined reference to `cass_value_get_bool'
simple.c:(.text+0x20d): undefined reference to `cass_row_get_column'
simple.c:(.text+0x21c): undefined reference to `cass_value_get_string'
simple.c:(.text+0x22d): undefined reference to `cass_row_get_column'
simple.c:(.text+0x23c): undefined reference to `cass_value_get_string'
simple.c:(.text+0x295): undefined reference to `cass_iterator_next'
simple.c:(.text+0x2a9): undefined reference to `cass_result_free'
simple.c:(.text+0x2b5): undefined reference to `cass_iterator_free'
simple.c:(.text+0x2c3): undefined reference to `cass_future_error_message'
simple.c:(.text+0x2fa): undefined reference to `cass_future_free'
simple.c:(.text+0x309): undefined reference to `cass_session_close'
simple.c:(.text+0x319): undefined reference to `cass_future_wait'
simple.c:(.text+0x32a): undefined reference to `cass_future_error_message'
simple.c:(.text+0x364): undefined reference to `cass_future_free'
simple.c:(.text+0x373): undefined reference to `cass_cluster_free'
collect2: error: ld returned 1 exit status
root@ubuntu-cassandra:~/cpp-driver/examples/simple# nm simple.o
                 U cass_cluster_connect
                 U cass_cluster_free
                 U cass_cluster_new
                 U cass_cluster_setopt
                 U cass_future_error_code
                 U cass_future_error_message
                 U cass_future_free
                 U cass_future_get_result
                 U cass_future_get_session
                 U cass_future_wait
                 U cass_iterator_free
                 U cass_iterator_from_result
                 U cass_iterator_get_row
                 U cass_iterator_next
                 U cass_result_free
                 U cass_row_get_column
                 U cass_session_close
                 U cass_session_execute
                 U cass_statement_new
                 U cass_string_init
                 U cass_value_get_bool
                 U cass_value_get_string
                 U fprintf
0000000000000000 T main
                 U printf
                 U stderr
                 U strlen

最佳答案

您需要在命令中使用“-lcassandra”而不是“simple.o”:

g++ simple.o -g -o simpler -L/usr/local/lib/ -lcassandra

我找到了一个解释原因的答案:Why does the order of '-l' option in gcc matter?

09-06 23:09