WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: how to compile fltk programs?  (Read 7926 times)

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
how to compile fltk programs?
« on: May 01, 2009, 08:55:23 AM »
I've used
Code: [Select]
g++ countdown.cxx `fltk-config --ldflags` -o countdown && ./countdownbut this generates a big executable compared to the ones present in the base system
dCore user

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: how to compile fltk programs?
« Reply #1 on: May 01, 2009, 10:03:05 AM »
Using fltk-config creates static executeables.
Tiny Core has the fltk libs in the base, so compile to use shared libs will be much smaller.

g++ -Os -fno-exceptions -fno-rtti -lfltk -o countdown countdown.cxx
strip countdown

will usually work.

Depending on the source you may also need to add
-lfltk_images -lfltk_forms

10+ Years Contributing to Linux Open Source Projects.

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: how to compile fltk programs?
« Reply #2 on: May 01, 2009, 10:38:41 AM »
Code: [Select]
g++ -Os -fno-exceptions -fno-rtti -lfltk -lfltk_images -lfltk_forms -o appbrowser appbrowser.cxx 
/tmp/cc0t9Vm1.o: In function `btn_callback(Fl_Widget*, void*)':
appbrowser.cxx:(.text+0x9a): undefined reference to `Fl_Browser::load(char const*)'
appbrowser.cxx:(.text+0xa6): undefined reference to `Fl_Widget::deactivate()'
appbrowser.cxx:(.text+0xb2): undefined reference to `Fl_Widget::deactivate()'
appbrowser.cxx:(.text+0xbe): undefined reference to `Fl_Widget::activate()'
.....
dCore user

Offline mikshaw

  • Sr. Member
  • ****
  • Posts: 368
Re: how to compile fltk programs?
« Reply #3 on: May 01, 2009, 12:56:44 PM »
might need to set CPPFLAGS for the fltk headers?  Just guessing.

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: how to compile fltk programs?
« Reply #4 on: May 01, 2009, 01:28:16 PM »
appbrowser compiles fine for me on both 1.x (compiletc) and 2.x (gcc-binutils) with:

tc@dev:~$ g++ -Os -fno-exceptions -fno-rtti -lfltk -o appbrowser appbrowser.cxx
tc@dev:~$

Be sure that you have both the .cxx and .h files together.
10+ Years Contributing to Linux Open Source Projects.

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: how to compile fltk programs?
« Reply #5 on: May 01, 2009, 02:17:08 PM »
How do I set CPPFLAGS for the fltk headers?
dCore user

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: how to compile fltk programs?
« Reply #6 on: May 01, 2009, 02:32:33 PM »
Robert: I've used your command and both the .cxx and .h files together. But I got the error above.
dCore user

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: how to compile fltk programs?
« Reply #7 on: May 01, 2009, 02:50:10 PM »
Actually I got the same error also using the command that before was working:
g++ appbrowser.cxx `fltk-config --ldflags` -o appbrowser.

I'm in PPI mode with compiletc.tcz installed.
Last time I've used PPR/TCZ, I'll reboot and try this
dCore user

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: how to compile fltk programs?
« Reply #8 on: May 01, 2009, 03:35:05 PM »
 g++ appbrowser.cxx  `fltk-config --ldflags` -o appbrowser
ok

 g++ -Os -fno-exceptions -fno-rtti -lfltk -o appbrowser appbrowser.cxx
error
dCore user

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: how to compile fltk programs?
« Reply #9 on: May 01, 2009, 04:18:27 PM »
Code: [Select]
g++ appbrowser.cxx  -Os -fno-exceptions -fno-rtti -lfltk -o appbrowser

/tmp/tcloop/compiletc/usr/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/../../../libfltk.a(Fl.o): In function `Fl::flush()':
(.text+0x7f6): undefined reference to `XDestroyRegion'
/tmp/tcloop/compiletc/usr/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/../../../libfltk.a(Fl.o): In function `Fl::flush()':
(.text+0x81c): undefined reference to `XFlush'
/tmp/tcloop/compiletc/usr/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/../../../libfltk.a(Fl.o): In function `Fl_Window::hide()':
(.text+0x162c): undefined reference to `XDestroyRegion'
/tmp/tcloop/compiletc/usr/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/.......



 g++ appbrowser.cxx  -Os -fno-exceptions -fno-rtti -lfltk -lXext -o appbrowser
the second command is ok but produces a big file
« Last Edit: May 01, 2009, 04:21:34 PM by jls_legalize »
dCore user

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: how to compile fltk programs?
« Reply #10 on: May 01, 2009, 05:47:38 PM »
If I boot TC 2.0rc1 with base norestore nolocal, i.e., pristine state.
Then grab gcc-binutils.tce from appbrowser, so that I get the .deps, then

appbrowser compiles fine.

I even grabbed the source from ibiblio, to be sure that my source is not different.
10+ Years Contributing to Linux Open Source Projects.

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: how to compile fltk programs?
« Reply #11 on: May 01, 2009, 07:41:17 PM »
Ok now in 2.0RC1 your way works, but the size of the binary is still huge compared to the one in the base system.
Code: [Select]
g++ -Os -fno-exceptions -fno-rtti -lfltk -o add2file add2file.cxx
strip add2file
results an add2fle of 386824 KB, where the one in the base system is just 4656 KB

The thing is that I just grabbed this app from the src dir from ibiblio, actually from the nluug.nl miror, since I'm in europe, and just compiled and stripped, without modifying either the .ccx or the .h
dCore user

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: how to compile fltk programs?
« Reply #12 on: May 01, 2009, 08:37:26 PM »
Try it in a pristine 1.4 with compiletc and see the difference  :o
10+ Years Contributing to Linux Open Source Projects.

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: how to compile fltk programs?
« Reply #13 on: May 02, 2009, 05:28:18 AM »
ok, it works from pristine 1.4 using compiletc.tce.

sizes now are similar:
appbrowser compiled by me: 11376 KB, original binary: 9947.
Thanx Robert
dCore user