• <legend id='jTqpv'><style id='jTqpv'><dir id='jTqpv'><q id='jTqpv'></q></dir></style></legend>

        <tfoot id='jTqpv'></tfoot>
      1. <i id='jTqpv'><tr id='jTqpv'><dt id='jTqpv'><q id='jTqpv'><span id='jTqpv'><b id='jTqpv'><form id='jTqpv'><ins id='jTqpv'></ins><ul id='jTqpv'></ul><sub id='jTqpv'></sub></form><legend id='jTqpv'></legend><bdo id='jTqpv'><pre id='jTqpv'><center id='jTqpv'></center></pre></bdo></b><th id='jTqpv'></th></span></q></dt></tr></i><div id='jTqpv'><tfoot id='jTqpv'></tfoot><dl id='jTqpv'><fieldset id='jTqpv'></fieldset></dl></div>

          <bdo id='jTqpv'></bdo><ul id='jTqpv'></ul>

        <small id='jTqpv'></small><noframes id='jTqpv'>

      2. 对 WinMain (C++ Mingw) 的未定义引用

        时间:2023-08-01
          <tfoot id='lPHgD'></tfoot>

              <i id='lPHgD'><tr id='lPHgD'><dt id='lPHgD'><q id='lPHgD'><span id='lPHgD'><b id='lPHgD'><form id='lPHgD'><ins id='lPHgD'></ins><ul id='lPHgD'></ul><sub id='lPHgD'></sub></form><legend id='lPHgD'></legend><bdo id='lPHgD'><pre id='lPHgD'><center id='lPHgD'></center></pre></bdo></b><th id='lPHgD'></th></span></q></dt></tr></i><div id='lPHgD'><tfoot id='lPHgD'></tfoot><dl id='lPHgD'><fieldset id='lPHgD'></fieldset></dl></div>

              • <bdo id='lPHgD'></bdo><ul id='lPHgD'></ul>
                  <tbody id='lPHgD'></tbody>

                  <legend id='lPHgD'><style id='lPHgD'><dir id='lPHgD'><q id='lPHgD'></q></dir></style></legend>

                  <small id='lPHgD'></small><noframes id='lPHgD'>

                1. 本文介绍了对 WinMain (C++ Mingw) 的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  目前我正在尝试使用 C++ 制作一个 Windows 应用程序.为了编译我的程序,我使用 Mingw GCC.顺便说一句,我在 Windows 10 上.但是一旦我使用 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) 而不是 int main() 编译器会显示以下消息:><块引用>

                  C:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e):对WinMain" collect2.exe 的未定义引用:错误:ld 返回 1退出状态终端进程以退出代码终止:1

                  我尝试编译的示例代码来自此 Windows 应用程序教程:示例代码

                  我已经尝试重新安装 mingw,但没有帮助.这就是为什么我希望这里有人可以帮助我解决我的问题.提前谢谢你!

                  解决方案

                  此示例代码使用 wWinMain

                  <块引用>

                  需要注意的一点是 Visual C++ 支持wWinMain"入口点其中lpCmdLine"参数是LPWSTR".您通常会使用入口点的_tWinMain"预处理器定义和声明LPTSTR lpCmdLine",以便您可以轻松地同时支持 ANSI和 Unicode 构建.但是,MinGW CRT 启动库没有支持 wWinMain,所以你必须坚持使用标准的WinMain"如果需要访问命令行,请使用GetCommandLine()"参数.

                  通过 使用 MinGW 构建 Win32 GUI 应用程序

                  在这种特定情况下,您可以改用 WinMain.这个程序不使用pCmdLine 值,所以当你把wWinMain 改为WinMainPWSTR pCmdLine 时它应该编译到 PSTR pCmdLine.

                  如果您以后需要 unicode 命令行,请使用 LPWSTR cmd_line = GetCommandLineW(); 而不是 WinMain 参数.

                  较新的 Mingw 版本还支持 -municode 链接器选项切换到备用启动代码,允许使用 wWinMain 而不是 WinMain(或 wmain 而不是 main).将其添加到命令行、IDE 或 makefile 中的链接器选项.

                  g++ other_options_and_arguments -municode

                  currently I am trying to make a windows application using c++. For compiling my program I use Mingw GCC. Btw I'm on Windows 10. But as soon as I use int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) instead of int main() the compiler shows me following message:

                  C:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain' collect2.exe: error: ld returned 1 exit status The terminal process terminated with exit code: 1

                  The example code I tried to compile I got from this Windows application tutorial: Example Code

                  I have already tried reinstalling mingw but it did not help. That's why i hoped someone here could help me with my problem. Thank you in advance!

                  解决方案

                  This example code uses wWinMain but

                  One thing to note is that Visual C++ supports a "wWinMain" entry point where the "lpCmdLine" parameter is a "LPWSTR". You would typically use the "_tWinMain" preprocessor definition for your entry point and declare "LPTSTR lpCmdLine" so that you can easily support both ANSI and Unicode builds. However, the MinGW CRT startup library does not support wWinMain, so you’ll have to stick with the standard "WinMain" and use "GetCommandLine()" if you need to access command line arguments.

                  via Building Win32 GUI Applications with MinGW

                  In this specific case, you can use WinMain instead. This program doesn't use pCmdLine value, so it should compile when you change wWinMain to WinMain and PWSTR pCmdLine to PSTR pCmdLine.

                  If you later would need unicode command line use LPWSTR cmd_line = GetCommandLineW(); instead of WinMain argument.

                  Newer Mingw versions also support -municode linker option switching to alternate startup code allowing to use wWinMain instead of WinMain (or wmain instead of main). Add it to your command line, linker options in IDE or makefile.

                  g++ other_options_and_arguments -municode
                  

                  这篇关于对 WinMain (C++ Mingw) 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在没有清单的情况下启用视觉样式 下一篇:如何查询正在运行的进程的参数列表?(窗口,C+

                  相关文章

                  最新文章

                    <bdo id='jltu8'></bdo><ul id='jltu8'></ul>

                  <tfoot id='jltu8'></tfoot>

                  1. <small id='jltu8'></small><noframes id='jltu8'>

                  2. <i id='jltu8'><tr id='jltu8'><dt id='jltu8'><q id='jltu8'><span id='jltu8'><b id='jltu8'><form id='jltu8'><ins id='jltu8'></ins><ul id='jltu8'></ul><sub id='jltu8'></sub></form><legend id='jltu8'></legend><bdo id='jltu8'><pre id='jltu8'><center id='jltu8'></center></pre></bdo></b><th id='jltu8'></th></span></q></dt></tr></i><div id='jltu8'><tfoot id='jltu8'></tfoot><dl id='jltu8'><fieldset id='jltu8'></fieldset></dl></div>
                    <legend id='jltu8'><style id='jltu8'><dir id='jltu8'><q id='jltu8'></q></dir></style></legend>