我正在尝试在 Windows 下从Mongoose编译包含的hello.c示例。我正在使用 Microsoft Visual 命令提示符,并且已将 mongoose.c 和 mongoose.h 复制到与 hello.c 示例相同的目录中。
当我写“cl hello.c”时,我得到以下输出/错误:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
hello.c
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:hello.exe
hello.obj
hello.obj : error LNK2019: unresolved external symbol _mg_stop referenced in function _main
hello.obj : error LNK2019: unresolved external symbol _mg_start referenced in function _main
hello.obj : error LNK2019: unresolved external symbol _mg_printf referenced in function _begin_request_handler
hello.obj : error LNK2019: unresolved external symbol _snprintf referenced in function _begin_request_handler
hello.obj : error LNK2019: unresolved external symbol _mg_get_request_info referenced in function _begin_request_handler
hello.exe : fatal error LNK1120: 5 unresolved externals
示例中包含一个Makefile,我尝试使用 Makefile 进行构建,但不明白如何执行此操作。如果我尝试“nmake hello.exe”。我得到以下输出/错误:
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
cl -W -Wall -I.. -pthread -g hello.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line error D8004 : '/W' requires an argument
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
编辑 我还尝试按照用户手册中的说明进行编译,在 Windows 上应转换为“cl hello.c mongoose.c -o hello.exe”,但随后出现以下错误消息:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
hello.c
mongoose.c
Generating Code...
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:hello.exe
/out:hello.exe
hello.obj
mongoose.obj
hello.obj : error LNK2019: unresolved external symbol _snprintf referenced in function _begin_request_handler
hello.exe : fatal error LNK1120: 1 unresolved externals
有没有人建议需要采取哪些步骤才能在 Windows 下为 Mongoose 编译 hello.c 示例?