1

i'm trying to install and use the library "ifopt" in a project but i get some errors

I have used the following commands (like here: https://github.com/ethz-adrl/ifopt/blob/master/README.md):

sudo apt-get install cmake libeigen3-dev coinor-libipopt-dev
git clone https://github.com/ethz-adrl/ifopt.git
cd ifopt
mkdir build 
cd build
cmake ..
make
sudo make install

Then i added to my CMakeLists:

find_package(ifopt)
add_executable(testifopt src/testifopt.cpp)
target_link_libraries(testifopt PUBLIC ifopt::ifopt_ipopt) 

And this is what i get, using catkin_make:

CMake Error at /home/simone/ifopt/ifopt-config.cmake:40 (include): include could not find load file: /home/simone/ifopt/ifopt_core-targets.cmake    
Call Stack (most recent call first): push_optimal_planner/CMakeLists.txt:30 (find_package)


CMake Warning (dev) at /home/simone/ifopt/ifopt-config.cmake:44 (get_target_property):
Policy CMP0045 is not set: Error on non-existent target in
get_target_property.  Run "cmake --help-policy CMP0045" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
get_target_property() called with non-existent target "ifopt::ifopt_core".
Call Stack (most recent call first): push_optimal_planner/CMakeLists.txt:30 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at /home/simone/ifopt/ifopt-config.cmake:47 (get_property): get_property could not find TARGET ifopt::ifopt_core. Perhaps it has not yet been created.
Call Stack (most recent call first): push_optimal_planner/CMakeLists.txt:30 (find_package)

What's wrong? Thanks for your help.

Simone Costi
  • 49
  • 1
  • 6
  • `And this is what i get` when doing what? What resulted in the messages you posted? Are these all messages you see? – KamilCuk Jan 27 '20 at 18:24
  • The missing file `ifopt_core-targets.cmake` and other similar files **should** be auto-generated by CMake, when you configured CMake for `ifopt`. Can you confirm these files exist in `/home/simone/ifopt`? – Kevin Jan 27 '20 at 18:31
  • @squarekittles Yes, the file exists in a folder in /home/simone/ifopt/build/ifopt_core/CMakeFiles/Export/share/ifopt/cmake – Simone Costi Jan 27 '20 at 19:08
  • @KamilCuk I was trying to using the command: "catkin_make" to build my project – Simone Costi Jan 27 '20 at 19:09
  • Maybe you should add `catkin` and `ros` tags – KamilCuk Jan 27 '20 at 19:39
  • @SimoneCosti: The path `/home/simone/ifopt/ifopt-config.cmake` smells like you take the file `ifopt-config.cmake` somewhere and **copy** it into that directory. This is not how CMake config files work. CMake should be able to find the file in its installed place. According the ifort's [CMakeLists.txt](https://github.com/ethz-adrl/ifopt/blob/master/CMakeLists.txt), the file should be installed into `share/ifort/cmake` subdirectory of the *installation prefix*. By default, installation prefix of the project is `/usr/local` and it is used by CMake when search a config file. – Tsyvarev Jan 27 '20 at 21:03
  • @Tsyvarev so what should i do to fix it? reinstalling give me the same result – Simone Costi Jan 27 '20 at 22:24
  • Not sure why you have `/home/simone/ifopt/ifopt-config.cmake` file and why CMake searches there, but you may try to remove that file (backup the file before deleting it) and try to build the project. – Tsyvarev Jan 27 '20 at 23:14
  • Possible duplicate of https://stackoverflow.com/questions/31346696/cmake-non-existent-target-error-when-trying-to-build-opencv-3-world-module-on-ub/63522609#63522609 – Vic Seedoubleyew Aug 21 '20 at 12:04

1 Answers1

0

Solved,

I needed to update Ros, reinstall IfOpt and also i added to the CMakeLists this line:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_MATH_DISABLE_FLOAT128")
Simone Costi
  • 49
  • 1
  • 6