Re: [fltk.general] Linker problem with Fl_Output
On 13.03.2013 10:32, Mirko D. Comparetti wrote: ... If I issue an fltk-config --compile main.cpp everything works and I get the working executable file. If I create this cmake file: - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - #CMakeList.txt cmake_minimum_required(VERSION 2.8) project(test) find_package(FLTK REQUIRED NO_MODULE) find_package(OpenGL REQUIRED) set(test_SRCS main.cpp ) set(test_HDRS ) add_executable(test ${APPLICATION_EXECUTABLE_SYSTEM} ${test_SRCS} ${test_HDRS}) target_link_libraries(test ${FLTK_LIBRARIES}) target_link_libraries(test ${OPENGL_LIBRARIES}) - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - I can cmake it using the GUI and create the makefile without any problem, but when I issue the make command, this is the output error from the linker (and not from the compiler): - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - Linking CXX executable test CMakeFiles/test.dir/main.cpp.o: In function `main': main.cpp:(.text+0x5f): undefined reference to `Fl_Output::Fl_Output(int, int, int, int, char const*)' collect2: ld returned 1 exit status make[2]: *** [test] Error 1 make[1]: *** [CMakeFiles/test.dir/all] Error 2 make: *** [all] Error 2 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - Do you know how to solve it? I think I'm missing some dependencies, but I don't know which ones. Please read the file README.CMake.txt, particularly the part about using FLTK with CMake. If you know how to work with CMake, you should understand what you need, but I can't say what it is. I can only guess that $(FLTK_LINKLIBRARIES) is not correct, since in the example given in this file you can read: target_link_libraries(hello fltk) and later, why the name fltk is chosen and more... If this doesn't help, please try to post the linker command and information about your OS (and version), FLTK version, and build system (e.g. MinGW on Windows?). Albrecht ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Linker problem with Fl_Output
#includeFL/Fl.H #includeFL/Fl_Window.H #includeFL/Fl_Input.H #includeFL/Fl_Output.H int main() { Fl_Window win(400, 600, TestWindow); win.begin(); Fl_Output test(50, 50, 300, 500, Test); This is wrong, you must create widgets dynamically when inserting them to a window. This might work better: Fl_Output* pO_Test= new Fl_Output(50, 50, 300, 500, Test); It is not necessary to keep pO_Test, because the window grabbed the Fl_Output, but you can use it for more initialisation, e.g. setting pO_Test-callback(), or something like that. ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Linker problem with Fl_Output
On 13.03.2013 10:50, Albrecht Schlosser wrote: [...] Please read the file README.CMake.txt, particularly the part about using FLTK with CMake. If you know how to work with CMake, you should understand what you need, but I can't say what it is. I can only guess that $(FLTK_LINKLIBRARIES) is not correct, since in the example given in this file you can read: target_link_libraries(hello fltk) and later, why the name fltk is chosen and more... If this doesn't help, please try to post the linker command and information about your OS (and version), FLTK version, and build system (e.g. MinGW on Windows?). Albrecht I read the instruction on that file and I tried to adapt to my situation, so now the cmakefile is: - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - cmake_minimum_required(VERSION 2.8) project(test) find_package(FLTK REQUIRED NO_MODULE) include(${FLTK_USE_FILE}) set(test_SRCS main.cpp ) set(test_HDRS ) add_executable(test ${APPLICATION_EXECUTABLE_SYSTEM} ${test_SRCS} ${test_HDRS}) target_link_libraries(test fltk) - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - which doesen't work at all because of the following cmake error: - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - CMake Error at CMakeLists.txt:6 (include): include called with wrong number of arguments. Include only takes one file. - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - If I remove that include(${FLTK_USE_FILE}) I still get the - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - Linking CXX executable test CMakeFiles/test.dir/main.cpp.o: In function `main': main.cpp:(.text+0x5f): undefined reference to `Fl_Output::Fl_Output(int, int, int, int, char const*)' collect2: ld returned 1 exit status make[2]: *** [test] Errore 1 make[1]: *** [CMakeFiles/test.dir/all] Errore 2 make: *** [all] Errore 2 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - 8 - - - - When I issue 'make VERBOSE=1', this is what it does: /usr/bin/c++ CMakeFiles/test.dir/main.cpp.o -o test -rdynamic -lfltk My current set-up is: Ubuntu 12.04 with FLTK 1.3.2, using eclipse and make. Thank you again, MDC ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Linker problem with Fl_Output
On 03/13/13 03:24, Edzard Egberts wrote: #includeFL/Fl.H #includeFL/Fl_Window.H #includeFL/Fl_Input.H #includeFL/Fl_Output.H int main() { Fl_Window win(400, 600, TestWindow); win.begin(); Fl_Output test(50, 50, 300, 500, Test); This is wrong, you must create widgets dynamically when inserting them to a window. Not wrong AFAIK, just not commonly used outside of small examples. It's fine for when instances of widgets are being created inside main(), which won't go out of scope unless the program ends. But it's true, in the typical case where widgets are often created outside of main(), you must use 'new'. ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Linker problem with Fl_Output
#includeFL/Fl.H #includeFL/Fl_Window.H #includeFL/Fl_Input.H #includeFL/Fl_Output.H int main() { Fl_Window win(400, 600, TestWindow); win.begin(); Fl_Output test(50, 50, 300, 500, Test); This is wrong, you must create widgets dynamically when inserting them to a window. This might work better: Fl_Output* pO_Test= new Fl_Output(50, 50, 300, 500, Test); It is not necessary to keep pO_Test, because the window grabbed the Fl_Output, but you can use it for more initialisation, e.g. setting pO_Test-callback(), or something like that. Unfortunately this doesn't solve the problem... The strange thing is that if I change Output in Input (in the non-pointer solution), it works perfectly. Thanks MDC ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Linker problem with Fl_Output
On 13.03.2013 11:59, Mirko D. Comparetti wrote: The strange thing is that if I change Output in Input (...), it works perfectly. Okay, now we're coming closer, and now we REALLY need your build environment and your FLTK version! Let me guess: (1) you're linking against the shared libs of FLTK ? (2) you're probably using a FLTK version older than 1.3.2 ? Note that FLTK 2.x is OLDER than any 1.3.x version, and that you should definitely NOT use 2.0 or 3.0 (dev./pre-alpha version). Please try to link statically and tell us the FLTK version. If it's not 1.3.2 or later (svn), there may be missing c'tors in the shared libs that have already been fixed. If it's 1.3.2 or a later svn version, then you found another missing c'tor, and we should fix this. TIA for feedback ... Albrecht ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Linker problem with Fl_Output
On 03/13/13 03:59, Mirko D. Comparetti wrote: The strange thing is that if I change Output in Input (in the non-pointer solution), it works perfectly. Sounds like when you get that error, the Makefile target isn't linking in libfltk.a (or -l fltk) I don't know cmake well enough to tell you what's wrong or why changing your app from Fl_Input - Fl_Output breaks the build, as both widgets are defined in the libfltk.a library (or '-l fltk' link flag) Sounds like either something is magically changing your makefile between your working and non working build (you mentioned it builds OK with cmake using the GUI in your OP, which might be doing such magic generating makefiles on the fly) or a different make target is being used when you switched Fl_Input - Fl_Output. I'd suggest disabling .SILENT in your Makefile, or disabling whatever is preventing the compile + link lines from being printed in the 'make' output, as it's hiding the commands you need to see to tell what's wrong. Almost positive though that the error you're seeing is because its not linking in liblftk.a (or using -l fltk). ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Linker problem with Fl_Output
On 03/13/13 04:28, Greg Ercolano wrote: Almost positive though that the error you're seeing is because its not linking in liblftk.a (or using -l fltk). Unless it's what Albrecht mentioned about linking dynamically.. something I almost never do. ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk