Eigen library + Code::Blocks - codeblocks

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.

Related

How to use SDL2 with Qt Creator - Windows

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

Why does OMNet++ compiler gets errors for a precompiled package?

I have included an external package callled SoPlex (a folder of .cpp and .h files and the library files) into my OMNet++ project. I have already tested the package in Code::Blocks IDE and it works fine besides some warnings it had: warning: explicit conversion operators only available with -std=c++11 or -std=gnu++11.
It certainly was working in Code::Blocks IDE. But when I want to use it in my OMNet++ project it gives a lot of errors for the SoPlex package like in the picture:
It gives a lot of errors for just the code of SoPlex and not my OMNet++ project code.
Any idea what may cause the problem?
I have used MinGW to compile SoPlex package in Code::Blocks IDE. When I use MinGW GCC in OMNet++ instead of GCC for OMNet++ as current toolchain there is this error fatal error: omnetpp.h: No such file or directory.
Regarding the errors with the 3rd party library. Depending where you put the library inside the src folder, at least that directory must be added as an include dir, otherwise the header files will not be found by the compiler.
As for the problem with the omnetpp.h: OMNeT++ has it's own makefile generator which automatically adds the required include folder (omnetpp_root/include). The generic MinGW GCC toolchain does not. If you want to avoid extra work, always use the omnet toolchain to build your models.

Error in CodeBlocks C++ program and how to set default main class

I have included the boost library in a Codeblocks c++ project.
Now, in the file
boost/function.hpp
there is an include statement
#include <boost/preprocessor/iterate.hpp>
However I get this error in Codeblocks when I try and compile:
/home/arvind/Documents/Workspace/Browser/boost/function.hpp|15|fatal error:
boost/preprocessor/iterate.hpp: No such file or directory|
What am I doing wrong here? I have simply included the Boost library as it is.
Also, I cannot find the screen/option to set the main class (which will actually execute).
How do I do this?(I am new to CodeBlocks hence this question).
Your boost includes seem to be in a non-standard/system directory : /home/arvind/Documents/Workspace/Browser, you must tell the compiler to look there (gcc -I command-line switch).
Go to Project->Build Options->Search Directories->Compiler and add the directory where boost includes are. I don't have a codeblocks install right here so this was from here.
If you can, I would recommand installing boost on your system once and for all instead of just copying files in your codeblocks workspace.

dev cpp win32 the program can't start because sqlite3.dll is missing

I am using dev c++ IDE which used ming gcc(i am not sure of it)
I wanted to use sqlite3 in my win32 c application
I downloaded sqlite3.dll and sqlite3.dev and used dlltool to create a .a file like libsqlite3.a and pasted in the lib folder of dev cpp and added this path in the project options -> parameters
i copied the header file sqlite3.h into the include folder(which i got from another website - http://www.opensource.apple.com/source/SQLite/SQLite-74/derived_source/sqlite3.h)
i executed the program and got the message 'the program can't start because sqlite3.dll is missing in your computer'
so i copied the sqlite3.dll into my working directory and then it worked
BUT
How to make the sqlite.* static while compiling?
I mean i thought by including the libsqlite3.a, the final exe will not be dependent of any external dll's.
So i want to know how to compile in a way that i will not be needing a dll and by doing so it makes my windows program standalone.
do i have a create a .lib file instead of .a file?
EDIT after answers and comments:
Besides, the devpak is working fine... yet i wanted to know how to include files to project or to create .a files so i am trying this way because if some components do not provide devpak then this will be the way we need to compile.. isn't it?
EDIT to show what i have done after the answer by CL and the two comments
This is how i have added the sqlite.c to project list
Here is the compile log
Compiler: Default compiler
Building Makefile:
"C:\Users\jayapalc\Documents\test-sqlite\Makefile.win"
Executing make...
make.exe -f "C:\Users\jayapalc\Documents\test-sqlite\Makefile.win" all
g++.exe -c sqlite3.c -o sqlite3.o -I"lib/gcc/mingw32/3.4.2/include"
-I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
sqlite3.c: In function `void strftimeFunc(sqlite3_context*, int,
sqlite3_value**)':
sqlite3.c:14727: error: invalid conversion from void*' tochar*'
The files i got in sqlite.org/sqlite-amalgamation-3071502.zip are
shell.c, sqlite3.h, sqlite3.c, sqlite3ext.h and i saw in other discussions that shell.c is not needed...
Besides, people were talking about gcc and g++... .
Apart from updating Dev-C++ itself, try this to compile sqlite.c as a C file:
Go to Project >> Project Options >> Files.
Find the C file we're talking about. Untick "Compile file as C++".
This should inform Dev-C++ that it should invoke gcc.exe, and not g++.exe.
If you don't want to compile sqlite yourself by adding it to your project, you can try passing the -static flag to GCC/G++ to force it to link libsqlite.a statically.
Just include the sqlite3.c file in your project.
You need only this filed, and it must be compiled as C, not C++.
Apparently, Dev-C++ does not allow mixing C and C++ source files in one project.
Instead, you could try to compile sqlite3.c as C and then include the generated .o file into the C++ project (on the Linker page).

Problems compiling with libraries

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 .

Resources