我正在使用 SSL-Vision 软件。它有一个示例客户端,我一直试图将其与整个项目分开。我找到了自己编辑客户端所需的资源,所以我只是从软件中复制它们并使用 CMake 来构建我的客户端。
下面的项目结构被简化,缩小到问题(我相信!)。
.
├── CMakeLists.txt
├── main.cc
├── build
│ ├── CMakeLists.txt
│ └── messages_ssl_... (.cc/.h, 4 each)
└── src
├── CMakeLists.txt
└── (Other subdirs and sources/headers)
./CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
project( TestClient )
find_package( PkgConfig REQUIRED )
pkg_check_modules( QTCORE_PKG QtCore )
include_directories( ${QTCORE_PKG_INCLUDE_DIRS} )
include(FindProtobuf)
find_package( Protobuf REQUIRED )
include_directories( ${PROTOBUF_INCLUDE_DIRS} )
find_package( PkgConfig REQUIRED )
pkg_check_modules( GLIB_PKG glib-2.0 )
include_directories( ${GLIB_PKG_INCLUDE_DIRS} )
include_directories( "src" )
add_subdirectory( src )
include_directories( "build" )
add_subdirectory( build )
add_executable( clientTest clientTest.cc )
target_link_libraries( clientTest robocup_ssl_client messages_robocup_ssl_detection.pb messages_robocup_ssl_geometry.pb messages_robocup_ssl_wrapper.pb messages_robocup_ssl_refbox_log.pb netraw robocup_ssl_client protobuf QtCore )
./build/CMakeLists.txt:
add_library( messages_robocup_ssl_detection.pb SHARED messages_robocup_ssl_detection.pb.cc )
add_library( messages_robocup_ssl_refbox_log.pb SHARED messages_robocup_ssl_refbox_log.pb.cc )
add_library( messages_robocup_ssl_geometry.pb SHARED messages_robocup_ssl_geometry.pb.cc )
add_library( messages_robocup_ssl_wrapper.pb SHARED messages_robocup_ssl_wrapper.pb.cc )
#include
文件中可能缺少它messages_ssl_...
,但它们都是自动生成的,并且似乎是正确的。
并且messages_robocup_ssl_detection.pb.h
只有messages_robocup_ssl_detection.pb.h
protobuf 包含。
在messages_robocup_ssl_refbox_log.pb.h
:
#include "messages_robocup_ssl_detection.pb.h"
// Other protobuf includes
在messages_robocup_ssl_wrapper.h
:
#include "messages_robocup_ssl_detection.pb.h"
#include "messages_robocup_ssl_geometry.pb.h"
// Other protobuf includes
在每个 .cc 文件中仅包含其头文件和其他 protobuf 库。
最后,当我做时,会产生以下错误:
Linking CXX executable clientTest
build/libmessages_robocup_ssl_wrapper.pb.so: undefined reference to `SSL_GeometryData::ByteSize() const'
build/libmessages_robocup_ssl_wrapper.pb.so: undefined reference to `SSL_GeometryData::MergeFrom(SSL_GeometryData const&)'
build/libmessages_robocup_ssl_wrapper.pb.so: undefined reference to `protobuf_AddDesc_messages_5frobocup_5fssl_5fgeometry_2eproto()'
build/libmessages_robocup_ssl_wrapper.pb.so: undefined reference to `SSL_GeometryData::Clear()'
build/libmessages_robocup_ssl_wrapper.pb.so: undefined reference to `SSL_GeometryData::SSL_GeometryData()'
build/libmessages_robocup_ssl_wrapper.pb.so: undefined reference to `SSL_GeometryData::default_instance()'
build/libmessages_robocup_ssl_wrapper.pb.so: undefined reference to `SSL_GeometryData::SerializeWithCachedSizesToArray(unsigned char*) const'
build/libmessages_robocup_ssl_wrapper.pb.so: undefined reference to `SSL_GeometryData::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)'
collect2: ld returned 1 exit status
make[2]: ** [clientTest] Erro 1
make[1]: ** [CMakeFiles/clientTest.dir/all] Erro 2
make: ** [all] Erro 2
一段时间以来,我一直在尝试解决此问题。libmessages_robocup_ssl_wrapper.pb.so
如果在链接之前已经构建,为什么会显示错误?