0
我編寫簡單的Protobuf-C庫。雖然它編譯成lib中我有如下錯誤:Cmake錯誤生成庫
Scanning dependencies of target ArgentumTracer-native
[ 16%] Building C object CMakeFiles/ArgentumTracer-native.dir/src/sources/http_sender.c.o
/Users/rmuhamedgaliev/Projects/ArgentumTracer-native/src/sources/http_sender.c:36:33: warning: incompatible pointer types passing 'in_addr_t *' (aka 'unsigned int *') to parameter of type 'struct in_addr *' [-Wincompatible-pointer-types]
if (inet_aton(SERVER_ADDR, &dest.sin_addr.s_addr) == 0)
^~~~~~~~~~~~~~~~~~~~~
/usr/include/arpa/inet.h:83:47: note: passing argument to parameter here
int inet_aton(const char *, struct in_addr *);
^
1 warning generated.
[ 33%] Building C object CMakeFiles/ArgentumTracer-native.dir/src/sources/main_agent.c.o
[ 50%] Building C object CMakeFiles/ArgentumTracer-native.dir/src/sources/VMInfo.pb-c.c.o
Linking C executable ArgentumTracer-native
[ 50%] Built target ArgentumTracer-native
Scanning dependencies of target argentumtracer
[ 66%] Building C object CMakeFiles/argentumtracer.dir/src/sources/http_sender.c.o
/Users/rmuhamedgaliev/Projects/ArgentumTracer-native/src/sources/http_sender.c:36:33: warning: incompatible pointer types passing 'in_addr_t *' (aka 'unsigned int *') to parameter of type 'struct in_addr *' [-Wincompatible-pointer-types]
if (inet_aton(SERVER_ADDR, &dest.sin_addr.s_addr) == 0)
^~~~~~~~~~~~~~~~~~~~~
/usr/include/arpa/inet.h:83:47: note: passing argument to parameter here
int inet_aton(const char *, struct in_addr *);
^
1 warning generated.
[ 83%] Building C object CMakeFiles/argentumtracer.dir/src/sources/main_agent.c.o
[100%] Building C object CMakeFiles/argentumtracer.dir/src/sources/VMInfo.pb-c.c.o
Linking C shared library libargentumtracer.dylib
Undefined symbols for architecture x86_64:
"_protobuf_c_message_free_unpacked", referenced from:
_vminfo__free_unpacked in VMInfo.pb-c.c.o
"_protobuf_c_message_get_packed_size", referenced from:
_vminfo__get_packed_size in VMInfo.pb-c.c.o
"_protobuf_c_message_pack", referenced from:
_vminfo__pack in VMInfo.pb-c.c.o
"_protobuf_c_message_pack_to_buffer", referenced from:
_vminfo__pack_to_buffer in VMInfo.pb-c.c.o
"_protobuf_c_message_unpack", referenced from:
_vminfo__unpack in VMInfo.pb-c.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libargentumtracer.dylib] Error 1
make[1]: *** [CMakeFiles/argentumtracer.dir/all] Error 2
make: *** [all] Error 2
的CMakeLists.txt
cmake_minimum_required(VERSION 3.1)
project(ArgentumTracer-native)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
FIND_PACKAGE(Java REQUIRED)
FIND_PACKAGE(JNI REQUIRED)
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2})
file(GLOB SOURCE_FILES "src/sources/*.c" "src/sources/*.h")
add_executable(ArgentumTracer-native ${SOURCE_FILES})
add_library(argentumtracer SHARED ${SOURCE_FILES})
target_link_libraries(ArgentumTracer-native protobuf-c)
請幫我建庫。我的資料庫擺在github上repository分支發展
您需要至少分享您的CMake代碼。乍一看,它看起來像你沒有找到/正確鏈接protobuf庫。 – StAlphonzo 2015-04-03 12:55:53
我將完整的源代碼放入存儲庫中。 – 2015-04-03 17:27:50