Error when compiling mip1_c++ using VSCode on mac
OngoingHi All,
I am working on macOS Mojave v10.14.6. I am running my code in VSCode, but I cannot compile it using following command:
clang++ -std=c++17 -stdlib=libc++ helloworld.cpp -o helloworld.exe -l /Library/gurobi901/mac64/include -L /Library/gurobi901/mac64/lib -lgurobi_c++ -lgurobi90 -m64
(I named the mip1_c++ file as helloworld)
I got following errors:
ld: library not found for -l/Library/gurobi901/mac64/include
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I guess I did not successfully link the library to the project? I am new to Gurobi. Could any one help me out? Thanks!
-
By the way, I can successfully build all examples in /Library/gurobi901/mac64/examples/build using the makefile.
0 -
Hi,
You need to change "-l /Library/gurobi901/mac64/include" to "-I/Library/gurobi901/mac64/include". That's a capital "I" - to specify the include directory. The library is already loaded using "-L" and "-l".
I would not call the binary EXE, by the way. This is usually only done on Windows.
You might also want to check out CMake for easier compilation/building.
Cheers,
Matthias0 -
Hi,
Thanks! It is my typo.
The link in your post is very useful! Thanks for sharing! My next step is to learn how to use CMake to build c++ project. I tried to use the template of CMakeLists from the link, but I have following errors:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GUROBI_CXX_LIBRARY
linked by target "gurobi-template" in directory /Users/yingqiuzhang/Documents/TestVSC/helloworld
linked by target "gurobi-template" in directory /Users/yingqiuzhang/Documents/TestVSC/helloworld
GUROBI_INCLUDE_DIRS
used as include directory in directory /Users/yingqiuzhang/Documents/TestVSC/helloworld
used as include directory in directory /Users/yingqiuzhang/Documents/TestVSC/helloworld
used as include directory in directory /Users/yingqiuzhang/Documents/TestVSC/helloworld
-- Configuring incomplete, errors occurred!
See also "/Users/yingqiuzhang/Documents/TestVSC/helloworld/build/CMakeFiles/CMakeOutput.log".
I am new to this. I appreciate your help!
0 -
I solved above issues by adding GRUOBI_HOME environment variable.
0 -
Hi, I have encounter the same issues even thought I add the GRUOBI_HOME environment variable.
set(GUROBI_HOME "/Library/gurobi912/mac64")
And that's my errors:
The tsp is my file name, I don't know what should I do to fix the error, thank u so much!!
1 -
Jacob Jin
I have the same issue. Did you manage to fix it?0
Please sign in to leave a comment.
Comments
6 comments