无法在 Mingw 上进行 fltk
Posted
技术标签:
【中文标题】无法在 Mingw 上进行 fltk【英文标题】:Not able to make fltk on Mingw 【发布时间】:2019-09-21 01:41:10 【问题描述】:我正在尝试在 Windows10 上以 Mingw-32 位安装 fltk。
我从here 下载了fltk-1.3.5,解压缩,cd 到文件夹并运行命令make
来构建它。但它给了我以下错误:
$ 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
Mingw-64 位出现类似错误。
问题出在哪里,如何解决?
编辑:我尝试了@jacob 在他的回答中给出的方法,但出现以下错误:
$ 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】:我能够在 MSYS2 中使用 MinGW-w64(64 位)编译 Fltk 1.3.5,没有任何警告。我是这样处理的:
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
除了编译器本身,关键包是mingw64/mingw-w64-x86_64-cmake
和mingw64/mingw-w64-x86_64-make
。
【讨论】:
我尝试了这种方法,但它不起作用..请参阅上面我的问题中的编辑。mingw64/mingw-w64-x86_64-cmake
和 mingw64/mingw-w64-x86_64-make
都已安装。
似乎选错了cmake
。您确定使用的是正确的(来自/mingw64/bin
)吗?以上是关于无法在 Mingw 上进行 fltk的主要内容,如果未能解决你的问题,请参考以下文章