robotology / osqp-eigen

Simple Eigen-C++ wrapper for OSQP library
https://robotology.github.io/osqp-eigen/
BSD 3-Clause "New" or "Revised" License
395 stars 118 forks source link

osqp.h: No such file or directory #include <osqp.h> #67

Closed mzahana closed 4 years ago

mzahana commented 4 years ago

Hi.

I installed osqp from source as described here. Then, I installed osqp-eigen. I installed both system wide.

I am using catkin build to build my applications. In my CMakeLists.txt, I set the following,

find_package(OsqpEigen)
find_package(osqp REQUIRED)

I use the following include in my header file

#include "OsqpEigen/OsqpEigen.h"

When I try to compile, I get

 osqp.h: No such file or directory  #include <osqp.h>

Any advice on how to solve this issue?

Thanks.

S-Dafarra commented 4 years ago

Hi @mzahana, thanks for using OsqpEigen. My best guess at the moment would be to try linking osqp::osqp in your application using target_link_libraries in your CMakeLists. If you have any link to your application, we may try to provide more insights.

mzahana commented 4 years ago

@S-Dafarra thank you for your reply. I did that and still getting the error

This is what I use in the CMakeLists

find_package(OsqpEigen)
find_package(osqp REQUIRED)
.
.
.

add_executable(mpc_tracker_node
  src/mpc_tracker_node.cpp
)
add_dependencies(mpc_tracker_node mpc_tracker ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(mpc_tracker_node mpc_tracker ${catkin_LIBRARIES} ${nlopt_LIBRARIES} osqp::osqp)

The error looks like:

from /home/arrow/catkin_ws/src/mavros_apriltag_tracking/src/mpc_tracker.cpp:32:
/usr/local/include/OsqpEigen/Constants.hpp:12:10: fatal error: osqp.h: No such file or directory
 #include <osqp.h>

I have osqp.h available at /usr/local/include/osqp/osqp.h

mzahana commented 4 years ago

So, I got it compiled by having OsqpEigen in find_package() in the following way

find_package(catkin REQUIRED COMPONENTS
  some_packages
.
.
.
  OsqpEigen
)

It compiled without having to link osqp::osqp

Up to now, I just included the #include <OsqpEigen/OsqpEigen.h>. Didn't do anything else as I wanted to make sure the include is OK.

S-Dafarra commented 4 years ago

So, I got it compiled by having OsqpEigen in find_package() in the following way

find_package(catkin REQUIRED COMPONENTS
  some_packages
.
.
.
  OsqpEigen
)

It compiled without having to link osqp::osqp

Up to now, I just included the #include <OsqpEigen/OsqpEigen.h>. Didn't do anything else as I wanted to make sure the include is OK.

Sounds good! Then probably OsqpEigen::OsqpEigen was missing as a target to link.

S-Dafarra commented 4 years ago

@mzahana if this is no more an issue, feel free to close it.