On 22.11.2014 16:04 A.J. bonnema wrote:
> My team mate (Stephan Versluys) found how to use fltk from code blocks
> under windows, which to my surprise, it needs an older version of cmake.
Hmm, you can't say that CMake 3.0.2 (this works, according to the
attachment) is an "older version" of CMake. It's the official current
stable version, whereas 3.1.0 rc2 is a release candidate for the next
version. There may be issues with this bleeding edge version, I don't
know. If you have some error messages, it would be nice to know.
> I include his readme so you guys might check or even include in your
> docs. I didn't find it when browsing the manual, but hey .... (don't
> exactly know how to go on, but it sounds good).
I believe there is nothing particular for Code::Blocks in our
documentation. Thanks for your report and the readme. I'll try to give
you some comments about the readme and how you may proceed.
> Generate fltk makefiles
> =======================
- Start x:\cmake-3.0.2-win32-x86\bin\cmake-gui.exe
> - Set browse source to x:\fltk-1.3.3
Okay so far.
> - Set build path to x:\fltk-1.3.3\lib
This is unusual, but also not really wrong. I wouldn't recommend it
though. CMake encourages out-of-source builds, but '\lib' is an existing
source directory. So if you want to build in-source, then you would use
the root directory, i.e. x:\fltk-1.3.3 (although not recommended),
otherwise you'd want to create another directory apart from the
x:\fltk-1.3.3 tree or a separate directory within the FLTK tree, e.g.
x:\fltk-1.3.3\build. I recommend one of the latter, but which one is a
matter of personal preference. In both cases you can delete the entire
build tree w/o affecting the source files. Having the build tree outside
the FLTK tree enables you to replace or upgrade the FLTK tree easily.
BTW: this is true for Windows and Linux as well.
That said, FLTK's CMake support is not yet complete, so you may run into
issues that are not yet covered. Michael posted more info in another
message.
> Setup CodeBlocks
> ================
>
> - Set search directory for compiler to C:\Program Files (x86)\FLTK
This should be okay, but see below.
> - Set search directory for linker to C:\Program Files (x86)\FLTK and
C:\Program Files (x86)\FLTK\lib
The latter should suffice, the former is probably just overhead.
> - If creating a new fltk project remove subdirectory FL\ from includes.
>
> #include <FL\Fl.H> becomes #include <Fl.H>
Unless you have a VERY good reason to do this, never ever do this. It
will make your source code non-portable or at least non-standard. All
examples you see in the FLTK source directory, on Greg's famous cheat
page, or in any tutorial, and everything you will find working in your
Linux installation will need the 'FL/' prefix. Also note that you should
always use a forward slash for portability reasons. This will work on
all platforms including Windows. Hence the correct form is:
#include <FL/Fl.H>
I wonder how the described setup could have worked w/o some other not
mentioned settings (see below for my guess).
You should check the Code::Blocks setup again. I'm not using it
personally, but I did a few tests today with the Linux version. I
created a "FLTK projekt", and as you said it worked out of the box (in
my case: almost). The reason it didn't work for me was that I didn't
"install" FLTK but wanted to use it from its build directory (for
reasons that are OT here). So I could try and get some experience how to
set up Code::Blocks.
I guess your colleague set the search path for the compiler to
C:\Program Files (x86)\FLTK\FL
instead of
C:\Program Files (x86)\FLTK
as mentioned above. This might have been some trial-and-error effect,
but once this is fixed it should work with the 'FL/' prefix in the
include statements again.
That said: as Richard asked: "Why not just use the msys toolchain?"
This is what the FLTK devs recommend for Windows. You're using the MinGW
compiler and MinGW make anyway (included in your Code::Blocks download),
so you could also install MinGW and the MSYS development package as a
separate installation (besides Code::Blocks). This would give you an
environment similar to the Linux environment you're also using: command
line gcc/g++ compiler, together with autogen to configure the (FLTK)
build. Going further with explanations how to use it would be OT here,
but if you're interested, please take a look at README.MSWindows.txt in
the FLTK root directory. If you have more questions, feel free to ask again.
Personally I have good experiences using MinGW/MSYS (make + gcc) under
Windows and using Linux make + gcc to produce portable FLTK
applications. I'm also using CMake + make for the software I'm
developing, and on top of that I'm also using an IDE which enables me to
use a graphical debugger (gdb under the hood). I chose CodeLite as the
IDE, but Code::Blocks looks very similar.
Summary = my recommendation: fix the Code::Blocks setup, take a further
look at MinGW/MSYS (
www.mingw.org), use CMake if you like for your
projects, and you should be fine. This all can be integrated pretty well
for a good development environment to generate portable FLTK applications.
One addition you didn't ask for: use a software repository (I prefer
git, FLTK uses subversion) with a central server in your network so you
can also maintain your sources cross-platform easily. In my case we are
also sharing the CodeLite project files for our development projects in
the git repository.