FLTK with CodeLite

General questions regarding the usage of CodeLite
Bozzck
CodeLite Curious
Posts: 6
Joined: Mon Jan 04, 2010 1:53 pm
Genuine User: Yes
IDE Question: c++
Contact:

FLTK with CodeLite

Post by Bozzck »

Hi, i'm very new with c++ , i'm using codelite on windows system, i wanna use FLTK library which come as source zip file with codelite. Can somebody help me generating fltk with codelite, all the lib dll? probably a step by step instruction would be nice, since i'm very new with c++, thank you
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: FLTK with CodeLite

Post by eranif »

I would have helped, but I got no knowledge in FLTK, I suggtest that you might try and build it first from sources using the command line (There surely some instructions on how to do it on the FLTK site)

Once, you got this problem solved, we can help you here to setup codelite to create a FLTK project

Eran
Make sure you have read the HOW TO POST thread
Bozzck
CodeLite Curious
Posts: 6
Joined: Mon Jan 04, 2010 1:53 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: FLTK with CodeLite

Post by Bozzck »

Thanks Eran, i will try building FLTK from command line first :)
Bozzck
CodeLite Curious
Posts: 6
Joined: Mon Jan 04, 2010 1:53 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: FLTK with CodeLite

Post by Bozzck »

Hi eran,

i got fltk compile under msys, now what do i do?
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: FLTK with CodeLite

Post by eranif »

Hi,

First create a console project.

From the menu bar:
'Workspace -> Create New Project'
(Select the g++ compiler)

Next, you should have a workspace with a single project inside it.
Open the project settings by right clicking on the project, and select 'Settings...'

In the dialog that opens, select the 'Compiler' tab, and type the following in the 'Compiler Options' field:

Code: Select all

$(shell fltk-config --cxxflags)
Next, select the 'Linker' tab,. and type the following the 'Options' field:

Code: Select all

$(shell fltk-config --ldflags)
Close the dialog (Click OK)

Paste the following code into your main.cpp file:

Code: Select all

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>

//--------------------------------------------
void but_cb( Fl_Widget* o, void*  )
{
	Fl_Button* b=(Fl_Button*)o;
	b->label("Good job"); //redraw not necessary

	b->resize(10,150,140,30); //redraw needed
	b->redraw();
}

//--------------------------------------------
int main()
{
	Fl_Window win( 300,200,"Testing" );
	
	win.begin();
	Fl_Button but( 10, 150, 70, 30, "Click me" );
	win.end();
	
	but.callback( but_cb );
	win.show();
	return Fl::run();
}
Hit F7 (to compile the file)
And you are done.
I tested it on Linux and it seems to work perfectly in my first try, however, I used Linux for this.

CodeCompletion for FLTK:
- By default, (on Linux) the include files are located under '/usr/include/Fl', so by adding the following paths to the code completion parser (from 'Settings -> Tags Settings -> Include Files'):

Code: Select all

/usr/include
/usr/include/Fl
you are good to go.

I strongly suggest that you read some online tutorials, like this one:
http://www3.telus.net/public/robark/
Eran
Make sure you have read the HOW TO POST thread
Bozzck
CodeLite Curious
Posts: 6
Joined: Mon Jan 04, 2010 1:53 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: FLTK with CodeLite

Post by Bozzck »

hi eran,

sorry to bother again,

using shell fltk-config --cxxflags, in the compiler part and --ldflags on the linker part, basically it try to createprocess and it failed,

do you have any other suggestion about tweaking codelite? i try to compile and run under msys, the test program work great using fltk-config --compile testFLTK.cpp (msys command line)

thank before hand, i'm running codelite on windows :(
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: FLTK with CodeLite

Post by eranif »

Bozzck wrote:using shell fltk-config --cxxflags, in the compiler part and --ldflags on the linker part, basically it try to createprocess and it failed,
so make sure that fltk-config is in your path (so codelite can find it)

To test the path settings:
open cmd.exe and try to run fltk-config from it, NOT from msys shell

If it still fails, add the include path, library path and the library name to the project settings.

For example, assuming that your fltk include files are located under C:\fltk\include and the lib is under C:\fltk\lib

So, in your project settings, open the 'Linker tab' and in the 'Library Path' add:

Code: Select all

C:\fltk\lib
, if you have more paths to add, add them with semicolon in between
In the 'Libraries' add:

Code: Select all

libfltk.a
Switch to the 'Compiler' tab in the 'Additional Search Path' add

Code: Select all

C:\fltk\include
(semicolon between paths)
Define any preprocessors (aka defines/macros) to the 'Preprocessor' field

To get the list of preprocessors type from the MSYS shell:
fltk-config --cxxflags

Eran



Eran
Make sure you have read the HOW TO POST thread
Bozzck
CodeLite Curious
Posts: 6
Joined: Mon Jan 04, 2010 1:53 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: FLTK with CodeLite

Post by Bozzck »

u know what eran, i might be new to using c++ but i know what a bourne shell is.... fltk-config is a script for a shell.... cmd.exe can't provide that....
it's impossible to run fltk-config inside cmd.exe, i can assure u that i set the environment variable in codelite to find fltk-config, so i dont think it's the case here.

thanks for your help anyway....
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: FLTK with CodeLite

Post by eranif »

Bozzck wrote:fltk-config is a script for a shell
I did not meant to insult you. I was using my knowledge from wxWidgets (on Windows wx-config is an executable) - like I said in my first post, I never ran it from Windows, only from Linux.

So simply enter the output of the fltk-config to the project settings, so you wont need to run it

Eran
Make sure you have read the HOW TO POST thread
Bozzck
CodeLite Curious
Posts: 6
Joined: Mon Jan 04, 2010 1:53 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: FLTK with CodeLite

Post by Bozzck »

hey eranif,

i got it to work with codelite....
damn , i even have to learn how to read makefiles and all he heh eheh... but i got it to work...

at least u lead me to the right direction, thanks alot...


CK
Post Reply