Author Topic: migrate to code::blocks: linker and compiler options  (Read 205 times)

Offline niconol

  • Single posting newcomer
  • *
  • Posts: 7
migrate to code::blocks: linker and compiler options
« on: September 13, 2017, 12:15:06 pm »
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: [Select]
g++ Dic_v0.76.cpp 'pkg-config opencv --cflags' -lwiringPi -o Dic_v0.76 -lmount 'pkg-config --libs opencv' -ludev -std=c++11 -lpthread
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

Online BlueHazzard

  • Lives here!
  • ****
  • Posts: 1470
Re: migrate to code::blocks: linker and compiler options
« Reply #1 on: September 13, 2017, 03:34:36 pm »
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: [Select]
wiringPi
mount
udev
pthread
have to be put in Project->Build options->Select your project name on the left->Linker-> Link libraries
the other linker options like
Code: [Select]
'pkg-config --libs opencv'
are placed in Project->Build options->Select your project on the left->Linker->Other linker options

The same for the compiler options
Code: [Select]
'pkg-config opencv --cflags'they are placed in Project->Build options->Select your project on the left->Compiler->Other compiler options

The general compiler flags like
Code: [Select]

-std=c++11
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.

Offline niconol

  • Single posting newcomer
  • *
  • Posts: 7
Re: migrate to code::blocks: linker and compiler options
« Reply #2 on: September 18, 2017, 11:22:07 am »
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

Online BlueHazzard

  • Lives here!
  • ****
  • Posts: 1470
Re: migrate to code::blocks: linker and compiler options
« Reply #3 on: September 18, 2017, 02:43:08 pm »
Quote
why no wiringPi, mount, udev and pthread in compiler settings,
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: [Select]
why some libraries in link libraries and ither in other linker options ...Because the libraries in link libraries are actual libraries found on the file system and
Quote
'pkg-config --libs opencv'
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'
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

Offline niconol

  • Single posting newcomer
  • *
  • Posts: 7
Re: migrate to code::blocks: linker and compiler options
« Reply #4 on: September 21, 2017, 02:18:02 pm »
Thanks a lot for all.

Best