title: Cmake undefined reference to symbol 'dlsym@@GLIBC_2.2.5 even though I link with -ldl
body: <p>I'm getting undefined reference to <code>dlsym@@GLIBC_2.2.5</code> even after linking it before and after the libraries. However in the linking output it appears that it's linking just before, but linking before all libraries should work, I guess.</p>
  <pre><code>/bin/g++-9     CMakeFiles/http_downloader.dir/http_downloader_cli.cpp.o CMakeFiles/http_downloader.dir/SimpleOpenVPNSocket.cpp.o  -o http_downloader  -lpthread /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/liblz4.so -ldl downloader/libhttp_downloader_cli.a downloader/libhttp_downloader_lib.a ../../libopenvpn/libopenvpn_lib.a ../../_smoltcp_cpp_interface/libsmoltcp_cpp.a ../../_libtins/lib/libtins.a -ldl /usr/lib/x86_64-linux-gnu/libcrypto.so -lpthread /usr/lib/x86_64-linux-gnu/liblz4.so /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libcrypto.so ../../../../smoltcp_cpp_interface/target/debug/libsmoltcp_cpp_interface_rust.a /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libcrypto.so 
  /usr/bin/ld: ../../../../smoltcp_cpp_interface/target/debug/libsmoltcp_cpp_interface_rust.a(std-6640d3868fa846e8.std.1mk5kra7-cgu.0.rcgu.o): undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
  /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line
  collect2: error: ld returned 1 exit status
  make[2]: *** [src/examples/http_downloader/CMakeFiles/http_downloader.dir/build.make:113: src/examples/http_downloader/http_downloader] Error 1
  make[2]: Leaving directory '/workspaces/libopenvpnclient/build'
  make[1]: *** [CMakeFiles/Makefile2:519: src/examples/http_downloader/CMakeFiles/http_downloader.dir/all] Error 2
  make[1]: Leaving directory '/workspaces/libopenvpnclient/build'
  make: *** [Makefile:130: all] Error 2
  </code></pre>
  <p>This is how I'm linking it in CMake:</p>
  <pre><code>add_executable(http_downloader http_downloader_cli.cpp SimpleOpenVPNSocket.cpp)
  add_core_dependencies(http_downloader)
  
  target_include_directories(http_downloader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/downloader/include)
  add_dependencies(http_downloader http_downloader_cli http_downloader_lib openvpn_lib smoltcp_cpp tins)
  set_property(TARGET http_downloader PROPERTY CXX_STANDARD 17)
  target_link_libraries(http_downloader dl http_downloader_cli http_downloader_lib openvpn_lib smoltcp_cpp tins dl)
  </code></pre>
  <p>As you can see I've put <code>dl</code> before and after everything just to make sure.</p>
  <p>If I understand correctly, <code>.a</code> libs do not have dependencies, they only have missing symbols and we have to fill them. Seems like I'm doing that by linking with <code>-ldl</code></p>