Deploy FLTK toolkit with Xcode6 on OS X 10.10.3 (Yosemite)

289 views
Skip to first unread message

Zhao Xinyu

unread,
May 1, 2015, 11:58:07 AM5/1/15
to fltkg...@googlegroups.com
I am addicted Xcode user and I am trying to integrate latest FLTK tool in Xcode Project. I searched a little bit and combined a few solutions together. Now it works (well, at least it pops out the “hello world” interface). 

A couple of things to note:
  • FLTK is reported to be somehow incompatible with OS X 10.10. If you downloaded from the office site, there might be bugs as you compiled the source codes (using sudo make install). For me, they are "make[1]: *** [Fl_cocoa.o] Error 1” and "make: *** [install] Error 1”. 
  • We will use homebrew to install FLTK 1.3.3. Type in your terminal ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
Use the following steps to integrate FLTK into Xcode 6

        1. Install FLTK with homebrew: brew install FLTK
2. Create a new command-line C++ project on Xcode
        Following changes are on “Building setting“ of you project. (click your project on navigation panel and then click building settings in the banner).
        3. Change in “search paths" as such:

            Header Search Paths : -I/usr/local/include
            Library Search Paths : /usr/local/lib

        4. Change in “search paths" as such

             Always search user paths: YES
             User header search paths: /usr/local/Cellar/fltk/1.3.3/include
             Framework search paths: /usr/local/Cellar/fltk/1.3.3/include

             NOTE: replace 1.3.3 to the version you download(maybe 1.3.2_1). You can always check the specific directory to verify the folder name.

         5. Change in “linking” as such
             
             First type in fltk-config --ldflags in your terminal. You will get a line of flags. Copy this line.
             Paste EXACTLY that line into “other linker flags”

             NOTE: my flag is: -L/opt/local/lib -Wl,-headerpad_max_install_names -lfltk -lpthread -framework Cocoa   It really depends on your system, don’t copy mine. 


         6. Run a demo to test the framework
             
           #include <FL/Fl.H>

#include <FL/Fl_Window.H>

#include <FL/Fl_Box.H>


int main(int argc, char **argv) {

    Fl_Window *window = new Fl_Window(300,180);

    Fl_Box *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();

}


          If everything goes right, it should pop out a simple form as below: 
 





Kevin Ingwersen (Ingwie Phoenix)

unread,
May 1, 2015, 12:27:31 PM5/1/15
to fltkg...@googlegroups.com
On Fr. Mai 01 2015 06:26:54 Zhao Xinyu wrote:
I am addicted Xcode user and I am trying to integrate latest FLTK tool in Xcode Project. I searched a little bit and combined a few solutions together. Now it works (well, at least it pops out the “hello world” interface). 
Ohhh. FLTK and XCode hasnt been a topic in a while. I use the command line and Atom.io myself, but also on 10.10.x.

A couple of things to note:
  • FLTK is reported to be somehow incompatible with OS X 10.10. If you downloaded from the office site, there might be bugs as you compiled the source codes (using sudo make install). For me, they are "make[1]: *** [Fl_cocoa.o] Error 1” and "make: *** [install] Error 1”. 
I have had not a single issue. All tests work and it is also actively tested on 10.10 by Manolo, if I remember correctly.

Why? FLTK is ment to be compiled in staticaly. There is an XCode project that makes a FLTK.framework, but I have always felt as that linking it staticaly is much better.
Looks good to me. Though, if you added the xcode project in FLTK’s repo as a sort of dependency (I forgot how XCode calls that stuff), then the linking and such should work automaticaly.

Kind regards,
Ingwie

Ian MacArthur

unread,
May 1, 2015, 12:39:58 PM5/1/15
to fltkg...@googlegroups.com
On Fri May 01 2015 05:26:54, Zhao Xinyu wrote:
I am addicted Xcode user and I am trying to integrate latest FLTK tool in Xcode Project. I searched a little bit and combined a few solutions together. Now it works (well, at least it pops out the “hello world” interface). 

A couple of things to note:
  • FLTK is reported to be somehow incompatible with OS X 10.10. If you downloaded from the office site, there might be bugs as you compiled the source codes (using sudo make install). For me, they are "make[1]: *** [Fl_cocoa.o] Error 1” and "make: *** [install] Error 1”. 
  • We will use homebrew to install FLTK 1.3.3. Type in your terminal ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Um... OK, thanks for the info., but but why all this trouble?

Is it not easier just to grab the latest weekly tarball from fltk site and use the Xcode project bundled in that to build everything?

Then everything works fine, and you get a recent version, not the older version that the packagers ship... the current snapshots work well on OSX 10.10.




Zhao Xinyu

unread,
May 2, 2015, 4:29:38 AM5/2/15
to fltkg...@googlegroups.com
Hi, Ingwie:
Thank you for the comment. The FLTK.framework is for Xcode 4. I am not sure if it works for Xcode 6. 
How to link FLTK with Xcode statically? Add some files into project?
The thing is: I cannot build FLTK source in my mac. I tried “./configure” and “make” as instructed by documentation. There are hundreds of compile errors coming out. I attached some error info below. They all share the similar format “missing qualified-id” or “expected declaration”. Any thought on why this happens?

/System/Library/Frameworks/AppKit.framework/Headers/NSGraphics.h:31:92: error: expected unqualified-id before ',' token

     NSCompositeHighlight NS_DEPRECATED_MAC(10_0, 10_0, "Use NSCompositeSourceOver instead"),

                                                                                            ^

/System/Library/Frameworks/AppKit.framework/Headers/NSGraphics.h:54:1: error: expected unqualified-id before '}' token

 };

 ^

/System/Library/Frameworks/AppKit.framework/Headers/NSGraphics.h:54:1: error: expected declaration before '}' token

make[1]: *** [Fl_cocoa.o] Error 1

make: *** [all] Error 1


Regards
Xinyu

在 2015年5月1日星期五 UTC-5上午11:27:31,Ingwie Phoenix写道:

Zhao Xinyu

unread,
May 2, 2015, 4:29:38 AM5/2/15
to fltkg...@googlegroups.com
BTW, you said “use Xcode bundled in that”, do you mean put Xcode Project into FLTK’s the top-level folder? 

Regards
Xinyu

在 2015年5月1日星期五 UTC-5上午11:39:58,Ian MacArthur写道:

Zhao Xinyu

unread,
May 2, 2015, 4:29:39 AM5/2/15
to fltkg...@googlegroups.com
Hi, 
You are right. But that only solves the search path problem. You still need to set up the linker flag right?

在 2015年5月1日星期五 UTC-5上午11:39:58,Ian MacArthur写道:
On Fri May 01 2015 05:26:54, Zhao Xinyu wrote:

imm

unread,
May 2, 2015, 4:40:33 AM5/2/15
to general fltk

On May 2, 2015 9:29 AM, "Zhao Xinyu" wrote:
>
> BTW, you said “use Xcode bundled in that”, do you mean put Xcode Project into FLTK’s the top-level folder? 
>

In the IDE folder of the tarball there is a project for use with Xcode.

Apple have done a reasonable job of maintaining compatibility between Xcode versions so it pretty much just works with recent Xcode too.

There is some discussion of this, I believe, in the OSX README in the top folder of the tarball.

--
Ian
Sent, perhaps surprisingly, from my Fairphone FP1

att...@ucdavis.edu

unread,
Apr 5, 2016, 4:00:50 AM4/5/16
to fltk.general
After we built the project in the IDE folder of the tarball, how do compile our new projects? The one in the IDE folder works fine, but when I try running new code it cannot find Fl/FL.h
Reply all
Reply to author
Forward
0 new messages