libigl / libigl

Simple MPL-2.0-licensed C++ geometry processing library.
http://libigl.github.io/libigl/
GNU General Public License v3.0
4.6k stars 1.14k forks source link

Mosek Quadratic Programming #773

Closed arvigj closed 1 year ago

arvigj commented 6 years ago

After installing mosek and linking it, a call to the function igl::mosek::mosek_quadprog gives the following compilation error:

undefined reference to `MSK_getcodedesc'
undefined reference to `MSK_makeenv'
undefined reference to `MSK_maketask'
undefined reference to `MSK_putmaxnumvar'
undefined reference to `MSK_putmaxnumcon'
...
undefined reference to `MSK_deleteenv'

What could be the issue here?

alecjacobson commented 6 years ago

What version of mosek are you using?

arvigj commented 6 years ago

Mosek version 8.1.0.53

arvigj commented 6 years ago

Also, I get the following warning on cmake WARNING: Target "ex5_bin" requests linking to directory "/home/arvi/Documents/mosek/8/tools/platform/linux64x86/bin". Targets may link only to libraries. CMake is dropping the item. Example 403 on libigl works properly. I've included igl::mosek in target_link_libraries and even tried adding a find_package(MOSEK) along with copying the libigl FindMOSEK.cmake file into my cmake modules directory, but to no avail. I can #include <igl/mosek/mosek_quadprog.h> but as soon as I call the function I get the first compilation error.

jdumas commented 6 years ago

Can you run the tutorial or does it produces the error too? Otherwise, can you produce a minimal example of your project setup (the CMake) so we can reproduce the problem?

arvigj commented 6 years ago

This is the CMakeLists.txt that I am using, minus the OpenCV library.

cmake_minimum_required(VERSION 3.1)
project(ex5)

# libigl
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# libigl
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF)
option(LIBIGL_WITH_ANTTWEAKBAR       "Use AntTweakBar"    OFF)
option(LIBIGL_WITH_CGAL              "Use CGAL"           ON)
option(LIBIGL_WITH_COMISO            "Use CoMiso"         OFF)
option(LIBIGL_WITH_CORK              "Use Cork"           OFF)
option(LIBIGL_WITH_EMBREE            "Use Embree"         OFF)
option(LIBIGL_WITH_LIM               "Use LIM"            OFF)
option(LIBIGL_WITH_MATLAB            "Use Matlab"         OFF)
option(LIBIGL_WITH_MOSEK             "Use MOSEK"          ON)
option(LIBIGL_WITH_OPENGL            "Use OpenGL"         ON)
option(LIBIGL_WITH_OPENGL_GLFW       "Use GLFW"           ON)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui"          ON)
option(LIBIGL_WITH_PNG               "Use PNG"            OFF)
option(LIBIGL_WITH_PYTHON            "Use Python"         OFF)
option(LIBIGL_WITH_TETGEN            "Use Tetgen"         OFF)
option(LIBIGL_WITH_TRIANGLE          "Use Triangle"       OFF)
option(LIBIGL_WITH_VIEWER            "Use OpenGL viewer"  ON)
option(LIBIGL_WITH_XML               "Use XML"            OFF)

find_package(LIBIGL REQUIRED QUIET)

# Add your project files
file(GLOB SRCFILES src/main.cpp)
add_executable(${PROJECT_NAME}_bin ${SRCFILES} src/content_aware_bbw.h src/content_aware_bbw.cpp src/mapping.cpp src/mapping.h)
target_link_libraries(${PROJECT_NAME}_bin igl::cgal igl::mosek igl::core igl::opengl_glfw igl::opengl_glfw_imgui)

I am building cmake using the following command

cmake -D MOSEK_INCLUDE_DIR=~/Documents/mosek/8/tools/platform/linux64x86/h -D MOSEK_LIBRARIES=~/Documents/mosek/8/tools/platform/linux64x86/bin -D CMAKE_BUILD_TYPE=Debug ../

When I pass these cmake variables to the the tutorial compilation cmake, I get example 403 (which uses igl::mosek for bbw) to compile and run without a problem.

jdumas commented 6 years ago

You should not pass MOSEK_INCLUDE_DIR and MOSEK_LIBRARIES directly to the cmake command. Try to first add any hardcoded guess in the FindMOSEK.cmake (you can copy it in your project). My guess is that the find_package(MOSEK) does not fail because you set yourself the variables MOSEK_LIBRARIES MOSEK_INCLUDE_DIR, but the library does not point to the correct file (you set it to point to a folder, whereas it should really point to the lib itself).

Also, I might be wrong, but it doesn't look like tutorial 403 is using mosek at all. The #include <igl/bbw.h> should be replaced by #include <igl/mosek/bbw.h> if mosek is enabled.

alecjacobson commented 1 year ago

This is hopefully handled by cmake now though modern mosek might not be working.