我最近尝试使用 code::blocks 编译在 Mongoose 项目网站上链接的示例,但遇到了某些错误。由于我不知道我哪里出错了,我将列出我在此过程中所做的一切。
- 在 Code::Blocks for Windows 中创建了一个新的 C++ 控制台应用程序项目
- 将此示例中的粘贴代码复制到我的 main.cpp https://github.com/valenok/mongoose/blob/master/examples/hello.c
- 创建并添加了一个名为 mongoose.h 的新 C++ 头文件,并从项目网站上链接的 mongoose.h 文件中复制粘贴的代码:https ://github.com/valenok/mongoose/blob/master/mongoose.h
- 创建并添加了一个名为 mongoose.h 的新 C 文件,并从项目网站上链接的 mongoose.c 文件复制粘贴的代码:https ://github.com/valenok/mongoose/blob/master/mongoose.c
- 保存所有文件和项目
- 单击 Code::Blocks for Windows 上的编译按钮
使用的操作系统:Microsoft Windows 8(64 位)
正在使用的 Code::Blocks 版本:codeblocks-12.11 with MinGW
Code::Blocks 使用的编译器:GNU GCC 编译器
以下是 Code::Blocks 生成的构建消息:
D:\pdthrow\cppprojects\server\mongoose.c|176|warning: "INT64_MAX" redefined [enabled by default]| e:\8\code blocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\..\include\stdint.h|95|note: this is the location of the previous definition|
D:\pdthrow\cppprojects\server\mongoose.c||In function 'set_ports_option':|
D:\pdthrow\cppprojects\server\mongoose.c|4626|warning: format '%d' expects argument of type 'int', but argument 6 has type 'DWORD' [-Wformat]|
D:\pdthrow\cppprojects\server\mongoose.c||In function 'getreq':|
D:\pdthrow\cppprojects\server\mongoose.c|5027|warning: implicit declaration of function '_strtoi64' [-Wimplicit-function-declaration]| obj\Debug\mongoose.o||In function `sockaddr_to_string':|
D:\pdthrow\cppprojects\server\mongoose.c|614|undefined reference to `inet_ntoa@4'| obj\Debug\mongoose.o||In function `poll':|
D:\pdthrow\cppprojects\server\mongoose.c|1258|undefined reference to `select@20'|
D:\pdthrow\cppprojects\server\mongoose.c|1260|undefined reference to `__WSAFDIsSet@8'| obj\Debug\mongoose.o||In function `set_non_blocking_mode':|
D:\pdthrow\cppprojects\server\mongoose.c|1374|undefined reference to `ioctlsocket@12'| obj\Debug\mongoose.o||In function `push':|
D:\pdthrow\cppprojects\server\mongoose.c|1499|undefined reference to `send@16'| obj\Debug\mongoose.o||In function `pull':|
D:\pdthrow\cppprojects\server\mongoose.c|1526|undefined reference to `recv@16'| obj\Debug\mongoose.o||In function `conn2':|
D:\pdthrow\cppprojects\server\mongoose.c|2596|undefined reference to `gethostbyname@4'|
D:\pdthrow\cppprojects\server\mongoose.c|2598|undefined reference to `socket@12'|
D:\pdthrow\cppprojects\server\mongoose.c|2603|undefined reference to `htons@4'|
D:\pdthrow\cppprojects\server\mongoose.c|2605|undefined reference to `connect@12'|
D:\pdthrow\cppprojects\server\mongoose.c|2608|undefined reference to `closesocket@4'| obj\Debug\mongoose.o||In function `prepare_cgi_environment':|
D:\pdthrow\cppprojects\server\mongoose.c|3298|undefined reference to `ntohs@4'| obj\Debug\mongoose.o||In function `get_remote_ip':|
D:\pdthrow\cppprojects\server\mongoose.c|4274|undefined reference to `ntohl@4'| obj\Debug\mongoose.o||In function `redirect_to_https_port':|
D:\pdthrow\cppprojects\server\mongoose.c|4422|undefined reference to `ntohs@4'| obj\Debug\mongoose.o||In function `close_all_listening_sockets':|
D:\pdthrow\cppprojects\server\mongoose.c|4542|undefined reference to `closesocket@4'| obj\Debug\mongoose.o||In function `parse_port_string':|
D:\pdthrow\cppprojects\server\mongoose.c|4568|undefined reference to `htonl@4'|
D:\pdthrow\cppprojects\server\mongoose.c|4569|undefined reference to `htons@4'|
D:\pdthrow\cppprojects\server\mongoose.c|4580|undefined reference to `htons@4'| obj\Debug\mongoose.o||In function `set_ports_option':|
D:\pdthrow\cppprojects\server\mongoose.c|4611|undefined reference to `socket@12'|
D:\pdthrow\cppprojects\server\mongoose.c|4615|undefined reference to `setsockopt@20'|
D:\pdthrow\cppprojects\server\mongoose.c|4622|undefined reference to `bind@12'|
D:\pdthrow\cppprojects\server\mongoose.c|4624|undefined reference to `listen@8'|
D:\pdthrow\cppprojects\server\mongoose.c|4627|undefined reference to `closesocket@4'|
D:\pdthrow\cppprojects\server\mongoose.c|4632|undefined reference to `closesocket@4'| obj\Debug\mongoose.o||In function `close_socket_gracefully':|
D:\pdthrow\cppprojects\server\mongoose.c|4913|undefined reference to `setsockopt@20'|
D:\pdthrow\cppprojects\server\mongoose.c|4917|undefined reference to `shutdown@8'|
D:\pdthrow\cppprojects\server\mongoose.c|4932|undefined reference to `closesocket@4'| obj\Debug\mongoose.o||In function `mg_connect':|
D:\pdthrow\cppprojects\server\mongoose.c|4972|undefined reference to `closesocket@4'|
D:\pdthrow\cppprojects\server\mongoose.c|4977|undefined reference to `closesocket@4'|
D:\pdthrow\cppprojects\server\mongoose.c|4987|undefined reference to `getsockname@12'| obj\Debug\mongoose.o||In function `worker_thread':|
D:\pdthrow\cppprojects\server\mongoose.c|5175|undefined reference to `ntohs@4'|
D:\pdthrow\cppprojects\server\mongoose.c|5178|undefined reference to `ntohl@4'| obj\Debug\mongoose.o||In function `set_sock_timeout':|
D:\pdthrow\cppprojects\server\mongoose.c|5238|undefined reference to `setsockopt@20'|
D:\pdthrow\cppprojects\server\mongoose.c|5239|undefined reference to `setsockopt@20'| obj\Debug\mongoose.o||In function `accept_new_connection':|
D:\pdthrow\cppprojects\server\mongoose.c|5249|undefined reference to `accept@12'|
D:\pdthrow\cppprojects\server\mongoose.c|5250|undefined reference to `ntohl@4'|
D:\pdthrow\cppprojects\server\mongoose.c|5253|undefined reference to `closesocket@4'|
D:\pdthrow\cppprojects\server\mongoose.c|5260|undefined reference to `getsockname@12'|
D:\pdthrow\cppprojects\server\mongoose.c|5267|undefined reference to `setsockopt@20'| obj\Debug\mongoose.o||In function `mg_stop':|
D:\pdthrow\cppprojects\server\mongoose.c|5384|undefined reference to `WSACleanup@0'| obj\Debug\mongoose.o||In function `mg_start':|
D:\pdthrow\cppprojects\server\mongoose.c|5397|undefined reference to `WSAStartup@8'| ||=== Build finished: 41 errors, 3 warnings (0 minutes, 3 seconds) ===|
请帮助我了解我哪里出错了。我的动机是在我目前正在进行的项目中使用适用于 Windows 和 Linux 的 Mongooser Web 服务器 API。