robotology / osqp-eigen

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

problems compiling this library #140

Closed marvin-ad-martianum closed 1 year ago

marvin-ad-martianum commented 1 year ago

osqp is a great library and i would love to use it. however, i canot build the osqp-eigen library. osqp is installed on an ubuntu 16. i get the follwoing output trying to build

any help would be appreciated.

marvin@X1-Y-4:~/Code/osqp-eigen/build$ cmake . osqp found: 1 osqp include directories: osqp libraries: -- osqp library path: /usr/local/lib/libosqp.so -- osqp include path: /usr/local/include/osqp -- Configuring done (0.1s) -- Generating done (0.0s) -- Build files have been written to: /home/marvin/Code/osqp-eigen/build marvin@X1-Y-4:~/Code/osqp-eigen/build$ make [ 20%] Building CXX object CMakeFiles/OsqpEigen.dir/src/Data.cpp.o In file included from /home/marvin/Code/osqp-eigen/include/OsqpEigen/Data.hpp:18, from /home/marvin/Code/osqp-eigen/src/Data.cpp:12: /home/marvin/Code/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:43:37: error: ‘csc’ has not been declared 43 | csc& osqpSparseMatrix); | ^~~ /home/marvin/Code/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:52:56: error: ‘csc’ does not name a type 52 | bool osqpSparseMatrixToEigenSparseMatrix(const csc const & osqpSparseMatrix, | ^~~ /home/marvin/Code/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:62:47: error: ‘csc’ does not name a type 62 | bool osqpSparseMatrixToTriplets(const csc const & osqpSparseMatrix, | ^~~ In file included from /home/marvin/Code/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:77, from /home/marvin/Code/osqp-eigen/include/OsqpEigen/Data.hpp:18, from /home/marvin/Code/osqp-eigen/src/Data.cpp:12: /home/marvin/Code/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:12:62: error: ‘csc’ has not been declared 12 | csc& osqpSparseMatrix) | ^~~ In file included from /home/marvin/Code/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:77, from /home/marvin/Code/osqp-eigen/include/OsqpEigen/Data.hpp:18, from /home/marvin/Code/osqp-eigen/src/Data.cpp:12: /home/marvin/Code/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp: In function ‘bool OsqpEigen::SparseMatrixHelper::createOsqpSparseMatrix(const Eigen::SparseCompressedBase&, int*&)’: /home/marvin/Code/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:18:5: error: ‘c_int’ was not declared in this scope; did you mean ‘u_int’? 18 | c_int rows = colMajorCopy.rows(); | ^~~~~ | u_int .....

Yilgrimage commented 1 year ago

Hahaha,I had this problem too and then realized no one was answering you, but luckily I just solved it! it seems like you didn't set correct lib link when you compiling. /usr/bin/g++ -fdiagnostics-color=always -g /home/yilgrimage/work/other/mpc.cpp -o /home/yilgrimage/work/other/mpc -L /usr/local/lib/ -lOsqpEigen -L /usr/lib/x86_64-linux-gnu/ -losqp "-L" means the path to your lib file, and "-lxxx" means lib file name.btw you should notice that libOsqpEigen relies on libosqp so you should add libosqp's path too,

marvin-ad-martianum commented 1 year ago

yea. thank you. it is quite ugly but i had to solve it this way. because osqp and osqp-eigen are not detected by automatic reading. no idea why.

target_link_libraries(controller_test_mpc ${catkin_LIBRARIES} ${eigen3} ${osqp} /usr/local/lib/libOsqpEigen.so /usr/local/lib/libosqp.so )

traversaro commented 1 year ago

Hello @marvin-ad-martianum and @Yilgrimage , see:

TL;DR: Now osqp default branch points to the unreleased 1.0.0 version, while osqp-eigen default branch is only compatible with osqp <= 0.6.3 at the moment. If you install osqp 0.6.3 (the latest stable release) everything should work.

GiulioRomualdi commented 1 year ago

Since https://github.com/robotology/osqp-eigen/pull/131 got merged, master is now compatible with osqp master.

Closing for the time being, in case of issue feel free to open it again 😃