24

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とprotobufmessages_robocup_ssl_detection.pb.hインクルードのみがあります。

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 ライブラリのみが含まれています。

最後に、make を実行すると、次のエラーが生成されます。

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リンクの前に既にビルドされている場合、エラーが表示されるのはなぜですか?

4

3 に答える 3