FLTK cmake problem in Ubuntu 14

Visto 620 veces
Saltar al primer mensaje no leído

Ibrahim A

no leída,
15 ago 2016, 7:50:3415/8/16
a fltk.general
Dear all,
I am trying to build a simple example for using fltk. The building works only when I use fltk-config but it does not work when I use cmake. I tried many google suggestions but I always get different types of errors. Your suggestion shall be appreciated.
Here are the files contents. 
----------------------------------------------------------------------
ui.h: 
----------------------------------------------------------------------
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>
class ui {
 public:
   ui();
   Fl_Window *controlPanel;
   void Show();
};
----------------------------------------------------------------------
ui.cxx 
----------------------------------------------------------------------
#include "ui.h"
ui::ui() {
  { controlPanel = new Fl_Window(590, 440);
    controlPanel->user_data((void*)(this));
    { new Fl_Button(225, 250, 120, 40, "Quit");
    } // Fl_Button* o
    { Fl_Box* o = new Fl_Box(135, 105, 305, 100, "FLTK + ITK");
      o->labelfont(9);
      o->labelsize(20);
    } // Fl_Box* o
    controlPanel->end();
  } // Fl_Window* controlPanel
}
 
void ui::Show() {
  controlPanel->show();
}
int main(  ){
    ui gui;
    gui.Show();
    Fl::run();    
    return 0;
}
----------------------------------------------------------------------
CMakeLists.txt
----------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(ui)
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})

FIND_PACKAGE(FLTK REQUIRED )
include_directories(${FLTK_INCLUDE_DIRS})
link_directories(${FLTK_LIBRARY_DIRS})
add_definitions(${FLTK_DEFINITIONS})

ADD_EXECUTABLE( ui ui.cxx )

TARGET_LINK_LIBRARIES( ui ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES})
----------------------------------------------------------------------
cmake configureation and generation work fine but I get this error message I got when I use make:
----------------------------------------------------------------------------------------------------------------------------------
[ 50%] Linking CXX executable ui
/usr/bin/ld: /usr/local/lib/libfltk.a(Fl_Window_shape.o): undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [ui] Error 1
make[1]: *** [CMakeFiles/ui.dir/all] Error 2
make: *** [all] Error 2




Michael Surette

no leída,
15 ago 2016, 8:31:5215/8/16
a fltkg...@googlegroups.com
On Mon, Aug 15, 2016 at 7:40 AM, Ibrahim A wrote:
> Dear all,
> I am trying to build a simple example for using fltk. The building works
> only when I use fltk-config but it does not work when I use cmake. I tried
> many google suggestions but I always get different types of errors. Your
> suggestion shall be appreciated.

...

> ----------------------------------------------------------------------------------------------------------------------------------
> [ 50%] Linking CXX executable ui
> /usr/bin/ld: /usr/local/lib/libfltk.a(Fl_Window_shape.o): undefined
> reference to symbol 'dlsym@@GLIBC_2.2.5'
> //lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from
> command line
> collect2: error: ld returned 1 exit status
> make[2]: *** [ui] Error 1
> make[1]: *** [CMakeFiles/ui.dir/all] Error 2
> make: *** [all] Error 2

What version of FLTK are you using? There have been many improvements
in the CMake build system since the last release. The latest 1.3
snapshot is suggested. The svn and git repositories are pretty stable
as well.

--
Mike

Albrecht Schlosser

no leída,
15 ago 2016, 8:33:1415/8/16
a fltkg...@googlegroups.com
On 15.08.2016 13:40 Ibrahim A wrote:

> I am trying to build a simple example for using fltk. The building works
> only when I use fltk-config but it does not work when I use cmake. I
> tried many google suggestions but I always get different types of
> errors. Your suggestion shall be appreciated.

First of all, FLTK's CMake support is still in development and not yet
officially supported. Particularly the latest stable release (1.3.3)
lacks many fixes that have been applied since in FLTK 1.3.4 (svn).
Please use a weekly tarball (snapshot) from the download page or use
current svn or git (github/fltk/test-only).

I tried your example with svn current, and I had to fix a few things in
CMakeLists.txt, but then I could build it. Note that your example does
not actually use OpenGL, so if you add OpenGL code there may be more to
change, but for now your example works for me with FLKT svn and this
CMake file:

#----------------------------------------------------------------------
# CMakeLists.txt
#----------------------------------------------------------------------

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(ui)
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})

set (FLTK_DIR "~/git/fltk/build/Debug") # use _your_ FLTK path here
FIND_PACKAGE(FLTK REQUIRED NO_MODULE) # must use "NO_MODULE"

# diagnostics (optional)

# message(STATUS "FLTK_INCLUDE_DIRS = '${FLTK_INCLUDE_DIRS}'")
# message(STATUS "FLTK_LIBRARIES = '${FLTK_LIBRARIES}'")
# message(STATUS "FLTK_FLUID_EXECUTABLE = '${FLTK_FLUID_EXECUTABLE}'")

include_directories(${FLTK_INCLUDE_DIRS})
link_directories(${FLTK_LIBRARY_DIRS})
add_definitions(${FLTK_DEFINITIONS})

ADD_EXECUTABLE( ui ui.cxx )

# Note: ${FLTK_LIBRARIES} is not yet defined in FLTK 1.3.x - to be fixed
later
# TARGET_LINK_LIBRARIES( ui ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES})

# use the imported target 'fltk' instead:

TARGET_LINK_LIBRARIES( ui fltk ${OPENGL_LIBRARIES})

--- snip ---

Notes:

(1) See README.CMake.txt for more information how to use FLTK 1.3.x
with CMake, and see comments in my version of your CMakeLists.txt
file above.

(2) Particularly you *may* need to set FLTK_DIR to point CMake to
your FLTK version. Otherwise CMake might find another installed
Version, and this *will* not work.

(3) Please use NO_MODULE in FIND_PACKAGE. This ensures that the
Find_FLTK module bundled with CMake is NOT used (it is designed
for FLTK 1.1 and doesn't work with FLTK 1.3).

(4) FLTK's CMake setup file (FLTKConfig.cmake) obviously does
not yet set FLTK_LIBRARIES as expected. However we define an
imported target 'fltk' that can be used for now. This will
definitely be fixed in FLTK 1.4, but I don't know if this will
also be fixed in FLTK 1.3.4 (the next and last release in the
1.3.x series).

Albrecht Schlosser

no leída,
15 ago 2016, 8:47:3315/8/16
a fltkg...@googlegroups.com
On 15.08.2016 14:33 Albrecht Schlosser wrote:
> On 15.08.2016 13:40 Ibrahim A wrote:

> I tried your example with svn current, and I had to fix a few things in
> CMakeLists.txt, but then I could build it. Note that your example does
> not actually use OpenGL, so if you add OpenGL code there may be more to
> change, but for now your example works for me with FLTK svn and ...

I should have mentioned that you need a FLTK library built with CMake
to use FLTK with CMake in the way described by me in my last posting.

Generally we do not recommend to "install" FLTK for your own
development environment, since the described approach works with
the build tree as well (see my path ~/git/fltk/build/Debug). Not
installing it avoids conflicts with other installed versions of FLTK.

If you install FLTK after building it, please make sure that no other
versions of FLTK are installed on your system.

Ibrahim A

no leída,
16 ago 2016, 8:24:1016/8/16
a fltk.general
Many thanks for your comments. I removed the installed fltk (was installed via apt-get) then I downloaded and built the updated one 

               fltk - Revision 11872: /branches/branch-1.3

using this command line: 
I didn't find github/fltk/test-only. 
Then I used the modified CMakeLists.txt file provided by Albrecht after changing this line:
                 set (FLTK_DIR "~/sw/fltk-1.3.4/build")
I got another error :
      CMake Error at CMakeLists.txt:9 (FIND_PACKAGE):
      Could not find a package configuration file provided by "FLTK" with any of the following names:
                      FLTKConfig.cmake
                      fltk-config.cmake
      Add the installation prefix of "FLTK" to CMAKE_PREFIX_PATH or set
      "FLTK_DIR" to a directory containing one of the above files.  If "FLTK"
       provides a separate development package or SDK, be sure it has been installed.
     -- Configuring incomplete, errors occurred
I couldn't find these files in my system but in CMake I found "FLTKConfig.cmake.in"
so I tried this line:
                 set (FLTK_DIR "~/sw/fltk-1.3.4/build/CMake")
but I still get the same error
      CMake Error at CMakeLists.txt:9 (FIND_PACKAGE):
Any suggestion?

Albrecht Schlosser

no leída,
16 ago 2016, 10:43:2916/8/16
a fltkg...@googlegroups.com
On 16.08.2016 13:38 Ibrahim A wrote:
> Many thanks for your comments. I removed the installed fltk (was
> installed via apt-get) then I downloaded and built the updated one
>
>
> fltk - Revision 11872: /branches/branch-1.3
>
> using this command line:
> svn co
> http://seriss.com/public/fltk/fltk/branches/branch-1.3/

Good.

> I didn't find github/fltk/test-only.

Maybe I was too lazy:
https://github.com/fltk/test-only

> Then I used the modified CMakeLists.txt file provided by Albrecht after
> changing this line:
> set (FLTK_DIR "~/sw/fltk-1.3.4/build")
> I got another error :
> CMake Error at CMakeLists.txt:9 (FIND_PACKAGE):
> Could not find a package configuration file provided by "FLTK"
> with any of the following names:
> FLTKConfig.cmake
> fltk-config.cmake
> Add the installation prefix of "FLTK" to CMAKE_PREFIX_PATH or set
> "FLTK_DIR" to a directory containing one of the above files.

This looks as if ~/sw/fltk-1.3.4/build was not built with CMake. You
should have these three files after you built FLTK in this folder, i.e.
in ~/sw/fltk-1.3.4/build:
$ ls FLTK*
FLTKConfig.cmake FLTK-Functions.cmake FLTK-Targets.cmake

You really need to build FLTK with CMake if you want it to work with a
project like your test project. Otherwise you can set the needed
libraries manually.

> I couldn't find these files in my system but in CMake I found
> "FLTKConfig.cmake.in"
> so I tried this line:
> set (FLTK_DIR "~/sw/fltk-1.3.4/build/CMake")
> but I still get the same error
> CMake Error at CMakeLists.txt:9 (FIND_PACKAGE):

That's not correct and can't work.

> Any suggestion?

You didn't write how you actually built FLTK - see above for my
suggestions. More precise advice:

cd ~/sw

Note: subdir fltk-1.3 must not exist at this time!

svn co http://seriss.com/public/fltk/fltk/branches/branch-1.3/ fltk-1.3
cd fltk-1.3
mkdir build
cd build
cmake ..
make
ls FLTK*

Now your FLTK library should be in ~/sw/fltk-1.3/build and the last
command (ls FLTK*) should show:

FLTKConfig.cmake FLTK-Functions.cmake FLTK-Targets.cmake

If this all went well, cd to your project directory, change the line
with "FLTK_DIR" in CMakeLists.txt to:

set (FLTK_DIR "~/sw/fltk-1.3/build")

and then run CMake as appropriate and make.

Duncan Gibson

no leída,
16 ago 2016, 10:48:0916/8/16
a fltkg...@googlegroups.com
> I am trying to build a simple example for using fltk. The building
> works only when I use fltk-config but it does not work when I use
> cmake.

I wrote the "Using CMake to build an FLTK application" article on
the CMake Wiki, but I was a CMake novice, and the article could be
a bit clearer than it is. The article describes use of the CMake
internals that were designed for an older version of FLTK, and so
it might not work as intended as documented anymore.

D,

This message and any attachments are intended for the use of the addressee or addressees only.
The unauthorised disclosure, use, dissemination or copying (either in whole or in part) of its
content is not permitted.
If you received this message in error, please notify the sender and delete it from your system.
Emails can be altered and their integrity cannot be guaranteed by the sender.

Please consider the environment before printing this email.

Ibrahim A

no leída,
16 ago 2016, 11:43:5116/8/16
a fltk.general
It works now after building using cmake :). Thanks a lot for your support. 

Greg Ercolano

no leída,
16 ago 2016, 13:54:0016/8/16
a fltkg...@googlegroups.com
On 08/16/16 07:48, Duncan Gibson wrote:
> I wrote the "Using CMake to build an FLTK application" article on
> the CMake Wiki, but I was a CMake novice, and the article could be
> a bit clearer than it is. The article describes use of the CMake
> internals that were designed for an older version of FLTK, and so
> it might not work as intended as documented anymore.

Note that you can edit the article if need be by using the
"Modify Article" link (in red) above the article's heading, e.g.
http://www.fltk.org/articles.php?L834+I100+T+P1+Q

Let me know if you have trouble using it.

Duncan Gibson

no leída,
17 ago 2016, 3:27:3617/8/16
a fltkg...@googlegroups.com
> > I wrote the "Using CMake to build an FLTK application" article on
> > the CMake Wiki, but I was a CMake novice, and the article could be
> > a bit clearer than it is. The article describes use of the CMake
> > internals that were designed for an older version of FLTK, and so
> > it might not work as intended as documented anymore.

> Note that you can edit the article if need be by using the
> "Modify Article" link (in red) above the article's heading,
> e.g. http://www.fltk.org/articles.php?L834+I100+T+P1+Q

No worries, Greg.

I am able to change the FLTK article above, but this mainly provides
a link to the CMake article https://cmake.org/Wiki/CMakeForFLTK that
should really be updated to reflect the newer versions of CMake, FLTK
and the current best practice, especially for using a non-installed
version of FLTK. You have to register on the CMake site to edit it.

I wrote the original article back in 2008, when it looked like CMake
would be taking over from autotools "in the very near future" and I
was a CMake novice. Unfortunately I haven't had much chance to work
with either CMake or FLTK since then, so I don't really have first
hand experience of best practice, or how things have changed beyond
reading articles by Albrecht and Michael on the fltk.coredev forum.

An immediate cosmetic change would be to rename the 'ui' component
to be 'gui' to avoid confusion with the FLTK_WRAP_UI macro, I think.
Then add some discussion of FIND_PACKAGE(FLTK REQUIRED NO_MODULE).

I don't enough recent experience of FLTK and CMake to know what
else could be improved in the documentation.

Cheers
Duncan

PS. This also begs the question whether such an article should be
part of the FLTK documentation, where more FLTK devs can eyeball
it and keep it up to date as FLTK evolves, or whether it should
be a more remote article on the CMake site with the extra hassle
of becoming a registered user there to be able to update it.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos