0

I started a fresh c++ project trying to use boost program_options. Unfortunately I have trouble with cmake; depending on what I try I either get a gmake error not beeing able to build a file or another one about target patterns not containing %.

Actual errors are:

While using ${Boost_LIBRARIES} (case 1): gmake error: No rule to build /usr/local/lib/libbooost_program_options.so

While using Boost::program_options (case 2): gmake error: Target pattern does not conaint "%". Stop.

I sourced my solution attempts from this SO thread: How to link C++ program with Boost using CMake

About case 1: this provides a step by step guide for this problem. Unfortunately after step one "check if the file exists" there is no hint at what to do if it DOES exists, which it does in my case.

stat /usr/local/lib/libboost_program_options.so
  Datei: /usr/local/lib/libboost_program_options.so -> libboost_program_options.so.1.62.0

Other threads, such as "No rule to make target" error in cmake when linking to shared library suggest using finder scripts, which I already do.

edit: Thanks to a comment it turned out i was blind for parts of the error message: The path plugged into the makefile is "Boost::program_options-NOTFOUND" which will obviously result in an error.


About case 2: Target pattern contains no '%'. Makefile implies that it is a path problem with any of my paths. I have zero idea how to further debug the problem, as debugging cmake scripts seems to be not well supported. Info on this is hard to find on any search engine.

The two versions of cmake scripts I used look like this:

cmake_minimum_required(VERSION 3.13)
project(probsim)

set(CMAKE_CXX_STANDARD 17)

FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED )

add_executable(probsim main.cpp)

target_link_libraries(probsim ${Boost_LIBRARIES})
# alternative: target_link_libraries(probsim Boost::program_options)

Results are:

-- Boost version: 1.62.0
-- Found the following Boost libraries:
--   program_options
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ketzu/CLionProjects/probsim/cmake-build-debug

Summary: Cmake creates an invalid makefile one way or another, the reason seems to be related to paths used on my filesystem.

Community
  • 1
  • 1
Ketzu
  • 660
  • 1
  • 7
  • 12
  • "About case 2: [Target pattern contains no '%'. Makefile] implies that it is a path problem with any of my paths. I have zero idea how to further debug the problem" - You may start with **looking into the line of Makefile** which causes the error. Path to the Makefile and an errornous line are printed in the error message. As for the absent file `/usr/local/lib/libboost_program_options.so`, you need to **install the package** which provides given file. For find the package name, simply google for " ". – Tsyvarev Apr 10 '19 at 12:52
  • @Tsyvarev thanks for the hint for case 2, i have been blind about it. That helped. I'll edit it in. About case 1 and the installation of the package: The file exists as far as I can tell and boost-devel is installed already. – Ketzu Apr 10 '19 at 13:30

1 Answers1

0

While I could find clues for the reasons of the problem, I could not solve them. It was most likely a problem with my system config on fedora.

But as an alternative solution to operating system development library management and troubles with ld I used conan.io with cmake to setup my development environment.

While this might not help everyone sumbling accross similar problems to mine, it might help some out.

Thanks everyone for the help.

Ketzu
  • 660
  • 1
  • 7
  • 12