Author Topic: How to solve the problems of FLTK in Code::Blocks  (Read 2792 times)

Offline hrz

  • Single posting newcomer
  • *
  • Posts: 7
How to solve the problems of FLTK in Code::Blocks
« on: June 18, 2021, 09:42:44 am »
I am read the book:Programming principles and practice using C++. And now, I am learning to use GUI library. I've downloaded the FLTK and compiled it.I've built a simple FLTK project to test and it worked.But when I inputed the example codes and downloaded all the GUI files in www.stroustrup.com and included them,they were failed to compiled.
The basic message are:
1. OS:windows 10,
2. Code::Blocks version:17.12,
3.FLTK version: 1.3.5,
The compile message are:
1.cmath:1094:11: error: '::hypot' has not been declared
   using ::hypot;
           ^
2.gcc/mingw32/5.1.0/include/c++/bits/locale_facets_nonio.h:1971:5: error: template-id 'do_get<>' for 'String std::__cxx11::messages<char>::do_get(std::messages_base::catalog, int, int, const String&) const' does not match any template declaration
     messages<char>::do_get(catalog, int, int, const string&) const;
3.Window.h:25:18: error: expected ')' before 'xy'
     Window(Point xy, int w, int h, const string& title);
4.Point.h:33:18: error: expected ')' before 'xy'
5.Point.h:98:5: error: 'Vector_ref' does not name a type
     Vector_ref<Button> selection;
.................

Process terminated with status 1 (0 minute(s), 2 second(s))
50 error(s), 30 warning(s) (0 minute(s), 2 second(s))

why the <cmath> should be error?
why "Point.h" is error?
I don't know how to solve these problems, anyone could help me?
Thanks!!!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: How to solve the problems of FLTK in Code::Blocks
« Reply #1 on: June 18, 2021, 09:48:16 am »
If you're using GCC 5.1 it is probably too old to have support for this function. Are you using c++11 mode?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline hrz

  • Single posting newcomer
  • *
  • Posts: 7
Re: How to solve the problems of FLTK in Code::Blocks
« Reply #2 on: June 18, 2021, 10:25:57 am »
Yes! my gcc version is 5.1. I've updated to 8.1 now. The errors of <cmath> disapear. but it still fail.
Errors like this:
1.MinGW\include/winnt.h:2399:2: error: #error "undefined processor type"
#error "undefined processor type"
  ^~~~~

2.include/crtdefs.h:35:1: error: '__MINGW_EXTENSION' does not name a type; did you mean 'FL_MINOR_VERSION'
__MINGW_EXTENSION typedef unsigned __int64 size_t;
 ^~~~~~~~~~~~~~~~~
3.include/crtdefs.h:138:9: error: '__time64_t' does not name a type; did you mean '__time32_t'?
 typedef __time64_t time_t;
         ^~~~~~~~~~
4.include/stdlib.h:348:58: error: 'size_t' has not been declared
 _CRTIMP int __cdecl __MINGW_NOTHROW mblen  (const char*, size_t);
                                                          ^~~~~~
5.include/stdlib.h:356:47: error: 'size_t' was not declared in this scope
_CRTIMP void* __cdecl __MINGW_NOTHROW malloc (size_t) __MINGW_ATTRIB_MALLOC;
                                               ^~~~~~
............
Process terminated with status 1 (0 minute(s), 10 second(s))
50 error(s), 2 warning(s) (0 minute(s), 10 second(s))

It still have 50 errors,but this time isn't  the <cmath>.

Thank you very much!!!

Offline hrz

  • Single posting newcomer
  • *
  • Posts: 7
Re: How to solve the problems of FLTK in Code::Blocks
« Reply #3 on: June 18, 2021, 01:12:13 pm »
If you're using GCC 5.1 it is probably too old to have support for this function. Are you using c++11 mode?

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 753
Re: How to solve the problems of FLTK in Code::Blocks
« Reply #4 on: June 18, 2021, 02:24:08 pm »
Did you remove 5.1 version completely?

Post a full rebuild log, read this

Offline hrz

  • Single posting newcomer
  • *
  • Posts: 7
Re: How to solve the problems of FLTK in Code::Blocks
« Reply #5 on: June 18, 2021, 05:26:28 pm »
Did you remove 5.1 version completely?

Post a full rebuild log, read this
I am so sorry that I make a mistake! The stroutrup has said:   Beware: this is code recovered from a loss of my previous website and my contain errors. Bug fixes and corrections are welcome. But I haven seen it. I am so sorry!

Offline hrz

  • Single posting newcomer
  • *
  • Posts: 7
Re: How to solve the problems of FLTK in Code::Blocks
« Reply #6 on: June 18, 2021, 06:07:46 pm »
Did you remove 5.1 version completely?

Post a full rebuild log, read this
I have changed the code now. But I still failed. The compile message is:
1.clang++ -L/home/hrz/fltk-sdk/lib -o bin/Debug/graph obj/Debug/Graph.o obj/Debug/GUI.o obj/Debug/main.o obj/Debug/Simple_window.o obj/Debug/Window.o  /usr/local/lib/libfltk.a -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lpthread -ldl -lm -lX11  /home/hrz/fltk-sdk/lib/libfltk.a /home/hrz/fltk-sdk/lib/libfltk_forms.a /home/hrz/fltk-sdk/lib/libfltk_gl.a /home/hrz/fltk-sdk/lib/libfltk_images.a
/usr/bin/ld: /home/hrz/fltk-sdk/lib/libfltk_images.a(Fl_JPEG_Image.cxx.o): in function `Fl_JPEG_Image::Fl_JPEG_Image(char const*)':
Fl_JPEG_Image.cxx:(.text+0xea): undefined reference to `jpeg_std_error'
/usr/bin/ld: Fl_JPEG_Image.cxx:(.text+0x1b7): undefined reference to `jpeg_finish_decompress'
/usr/bin/ld: Fl_JPEG_Image.cxx:(.text+0x1e3): undefined reference to `jpeg_destroy_decompress'


I still can't solve it!
« Last Edit: June 18, 2021, 06:15:52 pm by hrz »

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 753
Re: How to solve the problems of FLTK in Code::Blocks
« Reply #7 on: June 18, 2021, 06:25:17 pm »
Quote
I have changed the code now

Well, you have changed the code, the compiler (MiinGW to Clang) and the OS (Windows to Linux) in a row.

You must add a jpeg library to the linker, probably libjpeg.so

Offline hrz

  • Single posting newcomer
  • *
  • Posts: 7
Re: How to solve the problems of FLTK in Code::Blocks
« Reply #8 on: June 18, 2021, 08:28:47 pm »
Quote
I have changed the code now

Well, you have changed the code, the compiler (MiinGW to Clang) and the OS (Windows to Linux) in a row.

You must add a jpeg library to the linker, probably libjpeg.so
I don't know how to add it. In my FLTK library, I can't find anyone who's name just like libjpeg.
I read the codes in "libfltk_jpeg.h", the functon proto just match it. So i think it is the problem of code::blocks setting.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7176
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org