Qt Creator and Gurobi
I'm a beginner in Qt and currently writing codes in Qt Creator 2.2.1 (Qt 4.7.1) to solve an math optimization model by using Gurobi C++ libraries. After installing Gurobi, I got several library files as follow:
gurobi46.lib - Gurobi library import file
gurobi_c++md2008.lib - C++ interface (when using -MD compiler switch with Visual Studio 2008)
gurobi_c++md2010.lib - C++ interface (when using -MD compiler switch with Visual Studio 2010)
gurobi_c++mdd2008.lib - C++ interface (when using -MDd compiler switch with Visual Studio 2008)
gurobi_c++mdd2010.lib - C++ interface (when using -MDd compiler switch with Visual Studio 2010)
gurobi_c++mt2008.lib - C++ interface (when using -MT compiler switch with Visual Studio 2008)
gurobi_c++mt2010.lib - C++ interface (when using -MT compiler switch with Visual Studio 2010)
gurobi_c++mtd2008.lib - C++ interface (when using -MTd compiler switch with Visual Studio 2008)
gurobi_c++mtd2010.lib - C++ interface (when using -MTd compiler switch with Visual Studio 2010)
Also, there are two Include files in a "include" folder. I did add the folder's path in .pro file under INCLUDEPATH section.
Then, I tried to create a simple program that only declares a Gurobi variable, but it does not work.
int main(int argc, char *argv)
QCoreApplication a(argc, argv);
GRBenv env = GRBenv();
There is an error saying that "Variable 'GRBenv env' has initializer but incomplete type"
So, I guess I might forget to include the library in the .pro file so I add it as an external library by using the "Add Library...." in the right-click menu. The problem is that I don't know which one I should add so I try each one of them, one by one, but none of them works. The error is still there.
I don't know what kind of things or steps I missed. Could any one help, please?
PS: the Gurobi library I downloaded from the website is for Window64. There is another one for Linux-32. I did download it and have several .a and .so files. However, the creator could not see them when I tried to add them.
[Edit: Wrapped code in @ tags. Be sure to use them! mlong]
Did you check the qmake docs on "Declaring Other Libraries":/doc/qt-4.8/qmake-project-files.html#declaring-other-libraries already? Basically, you will have to adjust the INCLUDEPATH and LIBS variables.
Thanks, Volker for the reply! I did try the method in your link and now there is a new error (but I guess a better one). It said
LNK1104: Cannot open file gurobi_c++md2010.lib
It seems that the compiler found the library but cannot open it???
I also tried to use other library files but they all gave me the same error message.
Сheck the your library path in LIBS variable.
What did you add to your .pro file?
Oh sorry guys for this very late reply. I found out that I tried to use 64-bit library with 32-bit compiler. Such a shame :D haha Thank you all very much for the replies. I do appreciate your help.