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 installing osqp-eigen #162

Closed DRETQ closed 2 months ago

DRETQ commented 2 months ago

When I was installing osqp-eigen and got to the mingw32-make step, the problem I encountered was that it prompted “undefined reference to csc_spalloc” can anyone answer this? 1

traversaro commented 2 months ago

Can you describe:

Thanks!

DRETQ commented 2 months ago

@traversaro the version of osqp-eigen is v0.8.0, i just refer the link" git clone https://github.com/robotology/osqp-eigen.git" and the version of osqp is 0.6.3. The command i used to generate the mingw makefile is "mingw32-make" in the cmd. The compiler i used is CMake (I'm using version 3.28).

traversaro commented 2 months ago

Can you try with osqp-eigen v0.8.1 ?

The command i used to generate the mingw makefile is "mingw32-make" in the cmd.

That will run the mingw makefile, it will not execute it. The mingw makefile is generated by CMake, can you clarify which options of CMake you used?

The compiler i used is CMake (I'm using version 3.28).

CMake is not a C++ compiler. From your output I guess you are using TDM-GCC-64 or something similar, but if you can just specify what you are using that would be great.

More in general, I am not sure if anyone ever used osqp+osqp-eigen with mingw instead of msvc on Windows, so I am not sure if this will work.

DRETQ commented 2 months ago

@traversaro how can i get the osqp-eigen v0.8.1 ? If i execute "git clone https://github.com/robotology/osqp-eigen.git", the default is the version 0.8.1. I used the command "cmake -G "MinGW Makefiles" .. cmake -DCMAKE_INSTALL_PREFIX:PATH=D:\Qt\osqp-eigen-master\install " before "mingw32-make". Yeah, i have the TDM-GCC-64 and i also have visual studio 2022. Actually, i just follow the "https://blog.csdn.net/weixin_46663638/article/details/135138106", it seems that i don't include eigen in VS.

traversaro commented 2 months ago

@traversaro how can i get the osqp-eigen v0.8.1 ? If i execute "git clone https://github.com/robotology/osqp-eigen.git", the default is the version 0.8.1.

Yes, that is what I was referring to, in https://github.com/robotology/osqp-eigen/issues/162#issuecomment-2134640967 you instead mentioned you were using osqp-eigen v0.8.0 .

DRETQ commented 2 months ago

@traversaro where can i get the osqp-eigen v0.8.1 ?Thanks.

traversaro commented 2 months ago

@traversaro where can i get the osqp-eigen v0.8.1 ?Thanks.

https://github.com/robotology/osqp-eigen/releases/tag/v0.8.1

traversaro commented 2 months ago

Are you 100% sure you did not accidentally used osqp master branch? Because this error is exactly what you get if you are compiling against osqp master on Windows, see https://github.com/robotology/osqp-eigen/issues/146 and https://github.com/osqp/osqp/issues/576 for the actual issue tracking the problem.

DRETQ commented 2 months ago

@traversaro Ok, I will check the questions you asked because I'm a newbie and maybe there are some questions I didn't pay attention to

DRETQ commented 2 months ago

@traversaro When I use osqp-eigen v0.8.1, I encountered this error when running to “mingw32-make”. 2

DRETQ commented 2 months ago

@traversaro Do I need to change anything in vs? Thanks

DRETQ commented 2 months ago

@traversaro Is the osqp master branch you mentioned called Qdldl?

traversaro commented 2 months ago

Which version of osqp are you using? Can you report the CMakeCache.txt of both osqp and osqp-eigen to understand if something is going wrong?

DRETQ commented 2 months ago

@traversaro i am using osqp v0.6.3, here are the CMakeCache.txt of both osqp and osqp-eigen. CMakeCache(osqp).txt CMakeCache(osqp-eigen).txt

traversaro commented 2 months ago

osqp is built using the Visual Studio 17 2022 CMake generator and the MSVC compiler, while osqp-eigen is built with MinGW Makefiles CMake generator the TDM-GCC-64 compiler. The Microsft's Visual Studio toolchain (MSVC) and the Windows's GCC toolchain (mingw) are not mutually compatible, so you need to build all the libraries in your project with the same compiler/generator.

DRETQ commented 2 months ago

@traversaro Thanks for your answer, should I compile with MSVC or mingw? I just follow this guidance. install guidance.txt

traversaro commented 2 months ago

@traversaro Thanks for your answer, should I compile with MSVC or mingw? I just follow this guidance. install guidance.txt

Both are fine, as long as you are consistent. If you want to follow those instructions, I would suggest to delete your repos and start again, something went wrong in your osqp build if you wanted to build with mingw and instead you are building with Visual Studio.

DRETQ commented 2 months ago

@traversaro Ok, thank you. I decide to use the Visual Studio to compile. So in my osqp-eigen build, the last two command should be "cmake --build . cmake --build . --target install" instead of "mingw32-make mingw32-make install". Is my understanding correct?

traversaro commented 2 months ago

@traversaro Ok, thank you. I decide to use the Visual Studio to compile. So in my osqp-eigen build, the last two command should be "cmake --build . cmake --build . --target install" instead of "mingw32-make mingw32-make install". Is my understanding correct?

Yes, that is correct. However, as Visual Studio is a multiple config generator, probably you may also want to specify the config used, for example:

cmake --build . --config Release 
cmake --build . --config Release --target install
DRETQ commented 2 months ago

@traversaro When I use these two commands, “cmake --build . --config Release cmake --build . --config Release --target installI” still get the following error. 3

traversaro commented 2 months ago

You are still using the mingw/gcc generator, as you can see from the errors. What is your experience with CMake? I will suggest you to read some extensive cmake tutorial to understand how to create a new build with the visual studio generator.

DRETQ commented 2 months ago

@traversaro When installing osqp-eigen, I open cmake, then configure it based on the source files and build, then generate

traversaro commented 2 months ago

@traversaro When installing osqp-eigen, I open cmake, then configure it based on the source files and build, then generate

You need to set the cmake configurator either with the -G command line option or from the GUI, and set it to the same value for both osqp and osqp-eigen.

DRETQ commented 2 months ago

@traversaro Finally, I followed the video and website successfully installed eigen,osqp and osqp-eigen libraries. And test the example file MPCExample successfully. Thank you for your reply to my question and good luck and good health!https://blog.csdn.net/weixin_46663638/article/details/135138106. https://www.bilibili.com/video/BV1SG411v73G/?spm_id_from=333.337.search-card.all.click&vd_source=062a389c428606eab4b465d18160714d

traversaro commented 2 months ago

Great! If you solved your problem, can you close this issue?

DRETQ commented 2 months ago

@traversaro Hello, i have one more question, I would like to ask if you have used the osqp solver in matlab/simulink version 2015b? How should I implement it if I don't use the s-function? There is already a c version of the osqp solver and a simulink model, the ultimate goal is to make the model and the controller connected together eventually compilable with c code. Thanks

traversaro commented 2 months ago

We always used the OSQP solver in simulink via the https://github.com/robotology/wb-toolbox . As it has a lot of dependencies, I suggest you to install it via https://github.com/robotology/robotology-superbuild/blob/master/doc/matlab-one-line-install.md or by installing the robotology-superbuild from source: https://github.com/robotology/robotology-superbuild .

DRETQ commented 2 months ago

@traversaro Ok, thanks. I'm not sure if it can be implemented in simulink 2015b since osqp is relatively new, and I've seen issues in this topic involving simulink versions, mainly because I have a simulink 2015b model. https://github.com/osqp/osqp/issues/113

DRETQ commented 2 months ago

@traversaro I think i can't use your suggestion, since i found in https://github.com/robotology/robotology-superbuild/blob/master/doc/matlab-one-line-install.md, it notes that the minimum version of MATLAB supported by the robotology-superbuild is R2022a. What a pity!