Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
936 views
in Technique[技术] by (71.8m points)

visual c++ - Using Gurobi in C++17 (CLion) - "Could not find Gurobi (missing_GUROBI_LIBRARY)"

I am trying to use Gurobi in my CLion environment. CLion alone runs perfectly with the MSVC compiler.

    Clion - version 2020.3.1
    Visual Studio - 2019
    C++ 17
    Gurobi version 9.0.3

To install Gurobi I followed this installation guide:

https://www.gurobi.com/documentation/8.1/quickstart_linux/software_installation_guid.html#section:Installation

To use in CLion I added this to my CMakeLists.txt:

https://support.gurobi.com/hc/en-us/articles/360039499751-How-do-I-use-CMake-to-build-Gurobi-C-C-projects-

I already have some Gurobi code where the Library is already included: #include "gurobi_c++.h"

When I run my code now, I get this error message:

    CMake Error at C:/Program Files/JetBrains/CLion 2020.3.1/bin/cmake/win/share/cmake- 
    3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
    Could NOT find GUROBI (missing: GUROBI_LIBRARY)

My CMakeList.txt is this:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to make sure to link the correct version of the Gurobi library. Please check the FindGUROBI.cmake file and modify the NAMES line according to your installed Gurobi version (e.g. gurobi90):

find_library(GUROBI_LIBRARY
    NAMES gurobi gurobi91
    HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
    PATH_SUFFIXES lib)

Please also make sure to set the environment variable GUROBI_HOME to point to your installation directory.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...