I am trying to use gurobi in OMNet++. I have included gurobi_c++.h and in order to detect this file, I have already told the compiler where it can find it and the libraries. To do so, I went to Makemake options, custom, Makefrag and added two lines: EXTRA_OBJS += -LC:/gurobi701/win32/lib and CFLAGS += -IC:/gurobi701/win32/include. The first contains the path to gurobi C++ libraries and second contains the path to header file gurobi_c++.h. I also added the path to the include file in the Includes section in Path and symbols part for GNU C++ and path to libraries to Library Paths.
Despite all these, when I compile it says undefined reference to error for all functions used from gurobi_c++.h. I can see that it detects gurobi_c++.h, but I still have those errors.
Any ideas on what may cause the problem?
contents of bin folder:
contents of lib folder:
You need to link with gurobi_c++ library file. Change EXTRA_OBJS into:
EXTRA_OBJS += -LC:/gurobi701/win32/lib -lgurobi_c++
assuming that the library is called libgurobi_c++.a or libgurobi_c++.dll.
Related
Trying to use Code::blocks with the library Eigen. Using windows vista. With some help from a forum I got this command to compile a sample program:
C:\Users\Me\Desktop\eigen>g++ -I C:\Users\Me\Desktop\eigen\eigen3
-o test2.exe C:\Users\Me\Desktop\eigen\test.cpp
But if I cd anywhere else (other than my folder containing test.cpp) and try to build, I get a permission denied error.
On code blocks I started a new project and went to Settings->Compiler->Linker settings->Link libraries-> and added C:\Users\Me\Desktop\eigen
And also added the same link under build options. I got this error:
C:\Users\Me\Desktop\GUI\vector\main.cpp|2|fatal error:
Eigen/Dense: No such file or directory|
The pages I followed were:
http://eigen.tuxfamily.org/dox/GettingStarted.html
https://github.com/Microsoft/AirSim/blob/master/docs/install_eigen.md
As eigen has already stated, all you have to do is copy the headers from the eigen folder to the include folder of your compiler (or just make sure your compiler can find your eigen folder).
Just copy the entire Eigen folder from drive/(where eigen is)/eigen/ to the include folder of code blocks in CodeBlocks\MinGW\include.
After that, all you have to do is make sure in Settings->Compiler in the Search directories tab, the compiler tab has the location to include and linker tab to lib, and the same goes for your build options.
There is absolutely no use of adding the Eigen folder to link libraries option of the linker tab, since Eigen has no libraries and works only with headers.
I was struggling with using SDL2 and Qt Creator and found some threads here on SO that were mostly helpful but nothing that put it all together for SDL2 and Qt Creator on Windows 10. The main issue was that I could not use the console for I/O at the same time as SDL2 and following the other recommendations, a number of different things went wrong.
There were two keys:
Which SDL2.dll file to use and which directory to place it.
Some said use the SDL2.dll file download from the SDL website. Others said put this file in the main project directory, which did not work for me. What worked for me was first doing a build of my project (which failed) but creates a "build-..." directory. Then, taking the SDL2.dll file from installDir\SDL2-2.0.5\i686-w64-mingw32\bin and placing it in the "build-..." directory.
In the project.pro file, adding manually:
INCLUDEPATH += installDir/SDL2-2.0.5/i686-w64-mingw32/include
LIBS += -L installDir/SDL2-2.0.5/i686-w64-mingw32/lib -lmingw32 -mwindows -mconsole -lSDL2main -lSDL2
CXXFLAGS = -std=c++11
To be honest, I don't know if all of the calls in LIBS are needed, but it's now working perfectly for me and I thought I'd share some knowledge.
Where to put the DLL
The dll, is required to be in a directory which match one of the following rules:
Is part of the $PATH$ environment variable
Is in the same directory than the executable
Is in a directory which is actively specified in your code and loaded "manually".
In my case, I just moved those DLL to my /bin folder.
Libs and includes
Includes are required for the compiler, for this purpose, both of the following possibilities match:
Copy the SDL includes in the compiler include directory.
Add the include path to the project using INCLUDEPATH as explained by #launchpadmcquack.
Libs are required by the linker, for this purpose, both of the following possibilities match:
Copy the SDL libs in the compiler lib directory.
Add the lib to the project using LIBS as explained in the question.
Considering the library list, SDL2 is required, others depends on you specific projects. E.g. In my case I do not link any of the mingw32, mwindows or mconsole.
Additional note: You may specify C++11 with the CONFIG parameter:
CONFIG *= c++11
I installed boost v1.47 DLL (MT, Debug) for VC9 from boostpro. My code #include's <boost/regex.hpp>. When I try to build, VC gives me LNK1104 cannot open file libboost_regex-vc90-mt-gd-1_47.lib, even though boost_1_47/lib has been added to Additional Library Dependencies (in double quotes). The problem seems to be that the name of the library in the directory is not libboost_regex-vc90-mt-gd-1_47.lib, but simply boost_regex-vc90-mt-gd-1_47.lib.
How do I get VC to omit the leading 'lib' ? Any help would be greatly appreciated.
Thanks in advance
In Boost the lib prefix denotes whether the libraries were built for static or dynamic (shared) linking. To indicate you want to dynamically link the libraries (as the name without the lib prefix implies) define the preprocessor directive of BOOST_ALL_DYN_LINK.
In Visual Studio, go to the project's settings, and select Configuration Properties > C/C++ > Preprocessor page. Add BOOST_ALL_DYN_LINK to Preprocessor Definitions.
See also this related question: https://stackoverflow.com/a/2521866/483776
I am trying to compile some C++ code which uses the CGAL library on OS X Lion. I downloaded and installed on some directory the CGAL library. Then, when I try to compile the code, using "make";
triangulation.h:18:64: error: CGAL/Exact_predicates_inexact_constructions_kernel.h: No such file or directory
which means it does not find the CGAL lib. I look at the Makefile, and I see that it compiles using the flag
-lCGAL
Wondering how to solve this, I guess I could pass the information about the placement of my compiled library to this variable, but I do not how. I tried with export and so on but it does not recognize it, any hints?
The error message doesn't mean the library isn't found; it means a header file isn't found. The -lCGAL switch does indeed refer to the library. You're going to need a -IXXXXX switch added on to CFLAGS, where XXXXX is the path to the directory containing the CGAL directory which in turn contains Exact_predicates_inexact_constructions_kernel.h .
I am having a linker error LNK 2001 unresolved external symbol.My point is I do have the respective include directory added under Project Settings->C/C++->General ->Additional Include .I see that this include directory does have the header file which contains the function which is causing the error.
I also add all the lib folders under linker options->general->additional lib dependencies.
What could be going wrong? How can I trace what file is missing?
You need more than just the library path, you need to specify the libraries explicitly. i.e something.lib
(under Linker->Input->Additional Dependencies in VS2005)
Linker errors have nothing to do with include files. You get compiler errors from missing include files/directories. The linker needs the actual definitions aka code to work its magic and create your binary file (exe/dll/static library etc...).
Are you linking to the library of which you are #includeing the headers from?