Author Topic: Gurobi in Code::Blocks  (Read 959 times)

Offline Lobric

  • Single posting newcomer
  • *
  • Posts: 2
Gurobi in Code::Blocks
« on: October 15, 2020, 05:15:50 pm »
Hi !
Iíve tried to include "gurobi_c++.h" in but unluckily failed.
Can anyone tell me which part did I do wrong?





I did this both in the compiler setting and the project build options.

Result:


Iíll appreciate it very much.

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 570
Re: Gurobi in Code::Blocks
« Reply #1 on: October 15, 2020, 05:28:29 pm »
This is a linker problem, gurobi_c++.h was included successfully. Post a full rebuild log in code tags, see http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Offline sodev

  • Regular
  • ***
  • Posts: 405
Re: Gurobi in Code::Blocks
« Reply #2 on: October 15, 2020, 05:53:02 pm »
Looking at the names of the link libraries it looks like you added pretty much every Visual Studio compiled variant that was supplied, that won't work. You need to use the one library that matches your compiler. Most probably you are using some GCC compiler, it looks like all the libraries in your list are for Visual Studio, the last one might be a pure C library while the others might be C++ libraries, or it might be a GCC one. But this is just pure crystal ball science.

The proper solution is to figure out which compiler you use and if the library vendor offers a library for that compiler and what it's name is.

Offline Lobric

  • Single posting newcomer
  • *
  • Posts: 2
Re: Gurobi in Code::Blocks
« Reply #3 on: October 15, 2020, 08:25:44 pm »
Thanks for your replies.

Sorry, I just added all the libraries and failed.
I didn't know it doesn't provide support for MinGW.
It seems like the reason why it's always undefined.

This is from Gurobi's website.


Is that means I can't use Gurobi with Code Block ?

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 570
Re: Gurobi in Code::Blocks
« Reply #4 on: October 16, 2020, 08:20:13 am »
Code::Blocks is an IDE, not a compiler, and you can change the compiler it uses; MinGW is just a convenient and free option.

If the library you want to use only supports Visual Studio you can install this M$ crapware (https://visualstudio.microsoft.com/es/vs/community/) and select it as compiler in your C::B project or just use their IDE.

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: Gurobi in Code::Blocks
« Reply #5 on: October 21, 2020, 07:30:25 am »
Thanks for your replies.

Sorry, I just added all the libraries and failed.
I didn't know it doesn't provide support for MinGW.
*****

Is that means I can't use Gurobi with Code Block ?
Theoretically if Gurobi  supplis dlls, you can try to link dlls, not libs, directly to you project. GCC can do it. But even in case of the successful linking there may be a lot of the other issues for c++ library.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9604
Re: Gurobi in Code::Blocks
« Reply #6 on: October 24, 2020, 05:54:58 pm »
I didn't know it doesn't provide support for MinGW.
I can tell that I use Gurobi with MinGW just fine. Not being shown on the hompage as a supported IDE does not mean anything. If the compiler you use supports the MS library format (assuming you don't mix languages not supported), the libs can be used with this compiler, too. MinGW is quite compatible. I never had major issues with using MSVC libs. Just as a hint: Its easier to configure in C::B if you make a copy of the library with a *.a instead of *.lib extension.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ