PacktPublishing/Hands-On-Machine-Learning-with-CPP

Chapter 3 SharkML cmake config errors | Boost Serialization

Closed this issue · 5 comments

Note that I've attempted this with both the system package installed Boost (version 1.74) as well as built Boost myself (version 1.80) with the same results.

clint@sweetz:~/code/git/Hands-On-Machine-Learning-with-CPP/Chapter03/sharkml/build$ cmake ..
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
SharkML path is /home/clint/code/git/Shark
plotcpp path is /home/clint/code/git/plotcpp
CMake Error at /usr/local/lib/cmake/Boost-1.80.0/BoostConfig.cmake:141 (find_package):
  Found package configuration file:

    /usr/local/lib/cmake/boost_serialization-1.80.0/boost_serialization-config.cmake

  but it set boost_serialization_FOUND to FALSE so package
  "boost_serialization" is considered to be NOT FOUND.  Reason given by
  package:

  No suitable build variant has been found.

  The following variants have been tried and rejected:

  * libboost_serialization.so.1.80.0 (shared, Boost_USE_STATIC_LIBS=ON)

  * libboost_serialization.a (shared runtime, Boost_USE_STATIC_RUNTIME=ON)

Call Stack (most recent call first):
  /usr/local/lib/cmake/Boost-1.80.0/BoostConfig.cmake:262 (boost_find_component)
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:594 (find_package)
  CMakeLists.txt:25 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/clint/code/git/Hands-On-Machine-Learning-with-CPP/Chapter03/sharkml/build/CMakeFiles/CMakeOutput.log".

For Boost::Serialization, in /usr/local/lib I have three serialization files:
libboost_serialization.a
libboost_serialization.so
libboost_serialization.so.1.80.0

If I disable either of the "Boost_USE_STATIC_LIBS " or "Boost_USE_STATIC_RUNTIME" (or both), the binaries compile and link but immediately segfault on run.

I'm not sure what to try next if anyone can help me with what to do. I'm happy to provide any other details required.

Something new. I had previously built Boost with link=static but found another option for the runtime to be set static. I built Boost with: sudo ./b2 link=static runtime-link=static install

This solved the build problems. Unfortunately, I still get a segfault on running either of these.

I'm not at all well-versed with gdb, but the segfault appears at the same header location for both grid-shark as well as regression-shark. I don't know if my linking situation improved or only changed.

gdb output for grid-shark (after building with Debug symbols):

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from grid-shark...
(gdb) r
Starting program: /home/clint/code/git/Hands-On-Machine-Learning-with-CPP/Chapter03/sharkml/build/grid-shark 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000555555646e7c in shark::detail::MatrixRowReference<remora::matrix<double, remora::row_major, remora::cpu_tag> >::operator remora::vector<double, remora::cpu_tag> (this=<error reading variable: Cannot access memory at address 0x7fffff7fefe0>) at /home/clint/code/git/Shark/include/shark/Data/BatchInterface.h:151
151             operator Vector(){

If someone can assist me with a more robust gdb method, I'm happy to provide the details from it.

Hi @ClintRajaniemi,
The source code for this book was designed for library versions compatible with Ubuntu 18.04, so to compile the sample you need boost 1.62 and SharkML from commit 221c1f2e8abfffadbf3c5ef7cf324bc6dc9b4315. If you have a newer host system, please use Docker to setup development environment, take a look at these scripts https://github.com/PacktPublishing/Hands-On-Machine-Learning-with-CPP/tree/master/env_scripts

Thank you. I followed the docker steps and the install_env.sh fails to complete when trying to get the Shogun submodules. I don't believe there's anything wrong with your script because even manually trying to get those submodules times out.

I'll see what I can do with setting this up on an Ubuntu 18 VM.

I hope you and your family are safe. Slava Ukraine.

I'll go ahead and close this since I'm past the issue I opened with.

Thank you.

Hi @ClintRajaniemi, I created a PR to fix build issues in the Docker environment, you can use it to build samples. You can grab changes from PR until it is not merged.