title: CMake linking error (undefined reference to)
body: <p>I am working with the SSL-Vision software. It has an example client that I've been trying to separate from the whole project. I found the sources needed to edit a client myself, so I just copied them from the software and used CMake to build my client.</p>
  
  <p>The project structure below is simplified, narrowing to the issue (I believe!).</p>
  
  <pre><code>.
  ├── CMakeLists.txt 
  ├── main.cc
  ├── build
  │   ├── CMakeLists.txt
  │   └── messages_ssl_... (.cc/.h, 4 each)
  └── src
      ├── CMakeLists.txt
      └── (Other subdirs and sources/headers) 
  </code></pre>
  
  <p><strong>./CMakeLists.txt</strong>:</p>
  
  <pre><code>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 )
  </code></pre>
  
  <p><strong>./build/CMakeLists.txt</strong>:</p>
  
  <pre><code>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 )
  </code></pre>
  
  <p>It could be a missing <code>#include</code> in the <code>messages_ssl_...</code> files, but they all are auto-generated and seems to be correct.</p>
  
  <p>In <code>messages_robocup_ssl_detection.pb.h</code> and <code>messages_robocup_ssl_detection.pb.h</code> there are only protobuf includes.</p>
  
  <p>In <code>messages_robocup_ssl_refbox_log.pb.h</code>:</p>
  
  <pre><code>#include "messages_robocup_ssl_detection.pb.h"
  // Other protobuf includes
  </code></pre>
  
  <p>In <code>messages_robocup_ssl_wrapper.h</code>:</p>
  
  <pre><code>#include "messages_robocup_ssl_detection.pb.h"
  #include "messages_robocup_ssl_geometry.pb.h"
  // Other protobuf includes
  </code></pre>
  
  <p>In each .cc file is included only its header and other protobuf libs.</p>
  
  <p>Finally, when I do make, the following error is generated:</p>
  
  <pre><code>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&amp;)'
  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
  </code></pre>
  
  <p>I've been trying to fix this for some time.
  Why is the <code>libmessages_robocup_ssl_wrapper.pb.so</code> showing errors if it has already been built before the linkage?</p>