Author Topic: Using simple g++ compiling in Code::Blocks Ubuntu Linux  (Read 4899 times)

makuto

  • Guest
Using simple g++ compiling in Code::Blocks Ubuntu Linux
« on: February 23, 2012, 05:34:57 am »
Hey, I figured out how to successfully compile my SFML applications using
g++ -c main.cpp
then
g++ -o main main.o -lsfml-graphics -lsfml-window -lsfml-system
in the Ubuntu Linux terminal.  It then compiles into a Linux binary.  What I was wondering is how I would configure Code::Blocks to basically output this automatically into g++, then output the errors etcetera.  Is this what CB outputs automatically already? If I try to set everything up (linker, directories, etc.) like normal, I always get hosts of errors like "cannot find SFML/Graphics.hpp" and stuff like that.  Basically, can I just tell code::blocks that when I compile output to g++ the above commands, and stop if there are errors?
PS I installed the Linux version of SMFL by using sudo make install in the SFML Linux directory.  
Thanks,

Makuto
« Last Edit: February 23, 2012, 05:47:32 am by makuto »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Using simple g++ compiling in Code::Blocks Ubuntu Linux
« Reply #1 on: February 23, 2012, 09:01:37 am »
Basically, can I just tell code::blocks that when I compile output to g++ the above commands, and stop if there are errors?
You need to:
- create a project
- add your files
- setup the include directories for the compiler
- setup the include directories for the linker
- add the libraries to link against
- (optionally) add any compiler / linker flags you need

Consult the C::B documentation on the project's compiler/linker settings (see my sig).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Using simple g++ compiling in Code::Blocks Ubuntu Linux
« Reply #2 on: February 23, 2012, 10:32:03 am »
And in ubuntu there are smfl packages, so no need to selfcompile it.
In general it's better to use the packages distributed for your distro instead of selfcompile the libs, unless you know exactly what you do.

BTW:
the most development packages have pkg-config files, so you do not need to set up the folders and libs manually.