User forums > Using Code::Blocks

migrate to code::blocks: linker and compiler options

(1/1)

niconol:
Hi,
first, sorry for my low-level english.
I developed a software on a rpi, with raspbian OS.
First, I've done it in a single file, Dic_v.076.cpp ( >:(ugly), I use several librairies (system librairies and other as lwiringPi) and i compiled it with this line:


--- Code: ---g++ Dic_v0.76.cpp 'pkg-config opencv --cflags' -lwiringPi -o Dic_v0.76 -lmount 'pkg-config --libs opencv' -ludev -std=c++11 -lpthread
--- End code ---

it works good



Now I want to migrate to code blcoks, with several files ... but I need to configure it properly.

I discovered already code::blocks with an only one other application, with only one library, mentioned in "other linker options"/"linker settings" and as 'pkg-config gtkmm-3.0 --libs' and in "other options"/"compiler settings" as 'pkg-config gtkmm-3.0 --cflags'


I need some help to migrate my project to code::blocks, and more generally, understand and control compiler and linker options and how to use them.

can you help me?

Best

BlueHazzard:
A start point would be this:
http://wiki.codeblocks.org/index.php/The_build_process_of_Code::Blocks

If you have any compiling problems read and follow this:
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F and this
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

as you have found out the libraries like

--- Code: ---wiringPi
mount
udev
pthread
--- End code ---
have to be put in Project->Build options->Select your project name on the left->Linker-> Link libraries
the other linker options like

--- Code: ---'pkg-config --libs opencv'

--- End code ---
are placed in Project->Build options->Select your project on the left->Linker->Other linker options

The same for the compiler options

--- Code: ---'pkg-config opencv --cflags'
--- End code ---
they are placed in Project->Build options->Select your project on the left->Compiler->Other compiler options

The general compiler flags like

--- Code: ---
-std=c++11

--- End code ---
can be selected from the Project->Build options->Select your project on the left->Compiler->Compiler flags list

For the files you simply add them to your project with Project->Add files or generate them with File->New. Note that you have to use the file ending ".cpp" for c++ files or codeblocks can not use the right compiler.

i hope this helps.
For future help please ask specific questions.

niconol:
Thanks a lot BlueHazzard,
good links for me,
I followed your guidance, and everythink works good.

I need to find more information for understand,
why no wiringPi, mount, udev and pthread in compiler settings,
why some libraries in link libraries and ither in other linker options ...
 
If you know a good link explaining all about this, I'm interesting

Best

BlueHazzard:

--- Quote ---why no wiringPi, mount, udev and pthread in compiler settings,
--- End quote ---
because this are libraries. The compiler does not have to know about them. See https://en.wikipedia.org/wiki/Compiler and https://en.wikipedia.org/wiki/Linker_(computing)


--- Code: ---why some libraries in link libraries and ither in other linker options ...
--- End code ---
Because the libraries in link libraries are actual libraries found on the file system and

--- Quote ---'pkg-config --libs opencv'
--- End quote ---
is a command that gets executed by codeblocks in a shell and the output of this command is passed to the linker. What this command does: it searches and prints the libraries needed for opencv in the pkg database. And mostly it prints also all needed linker options.

--- Quote ---'pkg-config opencv --cflags'
--- End quote ---
is the same as above but it searches for "c-flags" = compiler flags. You can get the output of this commands by simply copy and pasting it into a shell and execute it

niconol:
Thanks a lot for all.

Best

Navigation

[0] Message Index

Go to full version