News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Using simple g++ compiling in Code::Blocks Ubuntu Linux

Started by makuto, February 23, 2012, 05:34:57 AM

Previous topic - Next topic

makuto

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

MortenMacFly

Quote from: makuto on February 23, 2012, 05:34:57 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Jenna

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.