Using Code Blocks

Jan 2, 2010 at 9:47pm
closed account (iw0XoG1T)
A recent discussion on this forum made me rethink not using a IDE. I choose code blocks because it seems to be popular.

this is the hello world I am trying to build:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>

int main (int argc, char ** argv) {
    Fl_Window *window;
    Fl_Box *box;

    window = new Fl_Window (300, 180);
    box = new Fl_Box (20, 40, 260, 100, "Hello World!");

    box->box (FL_UP_BOX);
    box->labelsize (36);
    box->labelfont (FL_BOLD+FL_ITALIC);
    box->labeltype (FL_SHADOW_LABEL);
    window->end ();
    window->show (argc, argv);

    return(Fl::run());
}


The libraries I need are in this directory /usr/lib

To build this program using the command line I would type:
1
2
g++ -Wall -o main.o -c main.cpp
g++ main.o  -lfltk -lfltk_images -o main


Using the easy to use IDE all I get is this error
1
2
ld    cannot find -lXft
=== Build finished: 1 errors, 0 warnings ===


I have no idea what library "-lXft" is or why it is being looked for. It seems to me selecting the right libraries should be common and easy to do.

I know this is not the right forum--but the code block forum doesn't seem to be set up for simple questions.
Jan 2, 2010 at 9:49pm
-l(library) is a command line switch you pass to gcc/g++, which is passed to ld, to tell it that there's a library it needs to look for to resolve any unresolved references. If you remove that switch (-lXft), then ld won't look for this Xft library. I don't know if you'll need it or not.
Jan 2, 2010 at 10:05pm
closed account (iw0XoG1T)
I do not know how to remove the switch--I do not even know where to look for this information. To compile and build a program using make files is not hard--because there is reasonable documentation that is easy to find. On the other hand compiling and building within these IDEs is hard, and the documentation seems to be well hidden.
Jan 2, 2010 at 10:13pm
IIRC in Code::Blocks there's a setting for that. Something like Project->Build Settings; but I can't remember. Bazzy uses codeblocks, maybe you could PM him directly.
Jan 2, 2010 at 10:14pm
Compiling with an IDE is easier than with other tools, with Code::Blocks you just have to go to the project's Build Options editor

[EDIT] Oh... I'm famous!
Last edited on Jan 2, 2010 at 10:16pm
Jan 2, 2010 at 10:23pm
You'll always be famous to me ;)
Jan 2, 2010 at 10:50pm
closed account (iw0XoG1T)
Thank you Bazzy -- I was able to build the program

To correct the problem I performed:
project -> properties -> project build options [button]->linker settings [tab] -> and added the proper libraries

You were so much helpful than the code blocks forum.
Jan 7, 2010 at 9:49am
@Bazzy
you're a C++ superstar!
Topic archived. No new replies allowed.