robotology / osqp-eigen

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

osqp-eigen compiled successfully, but example test failed. #118

Closed reflector-li closed 2 years ago

reflector-li commented 2 years ago

I want to use osqp-eigen on windows 11, and I have already installed and tested Eigen3.4.0 and osqp0.6.2 which ran normally. However, When I compiled and installed osqp-eigen successfully, I want to test it using MPCExample.cpp and it failed with the following error:

E:\C++\test\cmake-build-debug\test.exe

Process finished with exit code -1073741515 (0xC0000135)

The CMakeLists.txt I used for the example is

cmake_minimum_required(VERSION 3.20)
project(test)

set(CMAKE_CXX_STANDARD 14)
#set(OSQPEIGEN_INCLUDE_DIR D:/cppThirdParty/libInstall/osqpEigenLib/include)
#set(OSQPEIGEN_LIB_DIR D:/cppThirdParty/libInstall/osqpEigenLib/bin)
find_package(Eigen3 REQUIRED)
find_package(osqp REQUIRED
             PATHS D:/cppThirdParty/libInstall/osqpLib
              NO_DEFAULT_PATH)
find_package(OsqpEigen REQUIRED
             PATHS D:/cppThirdParty/libInstall/osqpEigenLib
             NO_DEFAULT_PATH)

#include_directories(${OSQPEIGEN_INCLUDE_DIR})
#link_directories(${OSQPEIGEN_LIB_DIR})

add_executable(test main.cpp)
target_link_libraries(test Eigen3::Eigen osqp::osqpstatic OsqpEigen::OsqpEigen)

I installed osqp to customized path, so I declare it on find_packages(). I guass the error occurs for false to find the osqp-eigen library. I used both find_package() way and include_package() manually, but both failed. Can someone help me solver it? Thank you!

S-Dafarra commented 2 years ago

Hi @reflector-li, thanks for opening the issue. I suspect it might be related to a setup issue. Can you try to add the path to the bin folder where you installed OsqpEigen to the Windows PATH env variable?

traversaro commented 2 years ago

Yes, 0xC0000135 is the error raised if some .dll required by the executable can't be found. I guess the missing .dll could be the one of osqp or the one of òsqp-eigen

reflector-li commented 2 years ago

Hi @reflector-li, thanks for opening the issue. I suspect it might be related to a setup issue. Can you try to add the path to the bin folder where you installed OsqpEigen to the Windows PATH env variable?

Thank you very much! I use MinGW as my complile enviroment. It remind that libosqp-eigen.dll can not be found. So I compile it with my cmake configuration. Now I can use it. I will post the CMakeLists.txt I use to help someone who met the same problem with me.

cmake_minimum_required(VERSION 3.20)
project(osqp_eigen)
include_directories(./include)
aux_source_directory(./src DIR_LIB_SRCS)
find_package(Eigen3 REQUIRED)
# add the customed install path of osqp
find_package(osqp REQUIRED
        PATHS D:/cppThirdParty/libInstall/osqpLib
        NO_DEFAULT_PATH)
add_library(osqp_eigen STATIC ${DIR_LIB_SRCS})
target_link_libraries(osqp_eigen Eigen3::Eigen osqp::osqpstatic)
install(TARGETS osqp_eigen ARCHIVE DESTINATION lib)
install(DIRECTORY ./include/ DESTINATION include)
GiulioRomualdi commented 2 years ago

Hi @reflector-li, I closed the issue since according to https://github.com/robotology/osqp-eigen/issues/118#issuecomment-1098213601 it seems that you were able to have a working setup. Please do not hesitate to open it again if I misunderstood