Not able to make fltk on Mingw

醉酒当歌 提交于 2019-12-13 19:12:12

问题


I am trying to install fltk in Mingw-32 bit on Windows10. I download fltk-1.3.5 from here, unzipped it, cd to folder and run command make to build it. But it gives me following error:

$ make
=== making jpeg ===
=== making zlib ===
=== making png ===
=== making src ===
=== making fluid ===
Compiling ExternalCodeEditor_WIN32.cxx...
ExternalCodeEditor_WIN32.cxx: In function ‘const char* get_ms_errmsg()’:
ExternalCodeEditor_WIN32.cxx:37:5: error: ‘_snprintf’ was not declared in this scope; did you mean ‘asnprintf’?
   37 |     _snprintf(emsg, sizeof(emsg), "Error Code %ld", long(lastErr));
      |     ^~~~~~~~~
      |     asnprintf
ExternalCodeEditor_WIN32.cxx: In function ‘int terminate_app(DWORD, DWORD)’:
ExternalCodeEditor_WIN32.cxx:116:60: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘DWORD’ {aka ‘unsigned int’} [-Wformat=]
  116 |       printf("WARNING: sent WIN_CLOSE, but timeout after %ld msecs.."
      |                                                          ~~^
      |                                                            |
      |                                                            long int
      |                                                          %d
  117 |              "trying TerminateProcess\n", msecTimeout);
      |                                           ~~~~~~~~~~~
      |                                           |
      |                                           DWORD {aka unsigned int}
ExternalCodeEditor_WIN32.cxx: In static member function ‘static const char* ExternalCodeEditor::tmpdir_name()’:
ExternalCodeEditor_WIN32.cxx:299:3: error: ‘_snprintf’ was not declared in this scope; did you mean ‘asnprintf’?
  299 |   _snprintf(dirname, sizeof(dirname), "%s.fluid-%ld",
      |   ^~~~~~~~~
      |   asnprintf
ExternalCodeEditor_WIN32.cxx: In member function ‘const char* ExternalCodeEditor::tmp_filename()’:
ExternalCodeEditor_WIN32.cxx:343:3: error: ‘_snprintf’ was not declared in this scope; did you mean ‘asnprintf’?
  343 |   _snprintf(path, sizeof(path), "%s\\%p%s", tmpdir, (void*)this, ext);
      |   ^~~~~~~~~
      |   asnprintf
ExternalCodeEditor_WIN32.cxx: In member function ‘int ExternalCodeEditor::start_editor(const char*, const char*)’:
ExternalCodeEditor_WIN32.cxx:422:3: error: ‘_snprintf’ was not declared in this scope; did you mean ‘asnprintf’?
  422 |   _snprintf(cmd, sizeof(cmd), "%s %s", editor_cmd, filename);
      |   ^~~~~~~~~
      |   asnprintf
make[1]: *** [../makeinclude:162: ExternalCodeEditor_WIN32.o] Error 1
make: *** [Makefile:24: all] Error 1

Similar error occurs on Mingw-64 bit.

Where is the problem and how can it be solved?

Edit: I tried method given by @jacob in his answer but got following error:

$ cmake -G "MinGW Makefiles" -D CMAKE_MAKE_PROGRAM=mingw32-make ..
CMake Error: Could not create named generator MinGW Makefiles

Generators
* Unix Makefiles               = Generates standard UNIX makefiles.
  Ninja                        = Generates build.ninja files.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.

回答1:


I was able to compile Fltk 1.3.5 with MinGW-w64 (64 bit) in MSYS2, without a single warning. I proceeded like this:

tar xvf fltk-1.3.5-source.tar.bz2
cd fltk-1.3.5
mkdir build
cd build
cmake -G "MinGW Makefiles" -D CMAKE_MAKE_PROGRAM=mingw32-make ..
mingw32-make

Aside from the compiler itself, the key packages were mingw64/mingw-w64-x86_64-cmake and mingw64/mingw-w64-x86_64-make.



来源:https://stackoverflow.com/questions/58036647/not-able-to-make-fltk-on-mingw

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!