1

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.

EDITユーザーマニュアル の指示に従ってコンパイルしようとしましたが、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 の例をコンパイルするために必要な手順について、誰か提案はありますか?

4

2 に答える 2

2

上記の 3 回目の試行の問題は、Visual Studio 10 で使用される C バージョンで「_snprintf」が廃止され、「_snprintf_s」に置き換えられたことであることがわかりました。 .

于 2013-03-20T18:03:15.703 に答える
-1

マングースのライブラリ(実際にはDLL)へのリンクを指定していないようです。そのため、未解決の外観があります。実行可能ファイルが実行時にそれらを見つけたり (動的にリンクされている場合)、コードを .exe に含めたり (静的にリンクされている場合) できるように、それらを見つける場所を知る必要があります。

于 2013-03-20T12:33:58.777 に答える