简体   繁体   English

SFML链接器错误:无法解析的外部符号_WinMain @ 16,Visual Studio 2012

[英]SFML linker error: unresolved external symbol _WinMain@16, Visual Studio 2012

I was able to get tutorial #1 to compile fine. 我能够获得教程#1进行编译。 But I can't get the 2nd one to compile. 但是我无法编译第二个

When you do new -> Project, maybe one of those settings are interfering? 当您新建-> Project时, 这些设置之一可能会干扰吗? Pretty sure I did empty project, else console. 可以肯定,我没有做空项目,否则没有控制台。

What's wrong? 怎么了? compile error: 编译错误:

Error   1   error LNK2019: unresolved external symbol _WinMain@16 referenced in function
___tmainCRTStartup  C:\...\02-videomode-iterate\MSVCRTD.lib(crtexew.obj)    02-videomode-iterate
Error   2   error LNK1120: 1 unresolved externals   C:\...\Debug\02-videomode-iterate.exe   02-videomode-iterate

entire source: 整个来源:

#include <SFML/Window.hpp>

int main()
{
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML-tut: 02");

    bool Running = true;
    while (Running)
    {
        App.Display();
    }

    return EXIT_SUCCESS;
}

Project settings: 项目设置:

include dir, lib: dir set correctly. include dir,lib:dir设置正确。

c++ -> preprocessor -> preprocessor definitions: C ++->预处理程序->预处理程序定义:

SFML_DYNAMIC SFML_DYNAMIC

linker -> input 链接器->输入

tried: sfml-window.lib and sfml-window-d.lib ( visual studio seems to always use debug mode at start? but tutorial #1 only worked when I didn't use -d version. 尝试过: sfml-window.libsfml-window-d.lib (Visual Studio似乎总是在开始时使用调试模式?但是,教程#1仅在我不使用-d版本时有效。

subsystem: 子系统:

/SUBSYSTEM:WINDOWS /子系统:WINDOWS

When you set the /SUBSYSTEM:WINDOWS flag, the linker will look for a WinMain function rather than the conventional main . 设置/SUBSYSTEM:WINDOWS标志时,链接器将查找WinMain函数而不是常规的main You have two options: 您有两种选择:

  1. Change to /SUBSYSTEM:CONSOLE . 更改为/SUBSYSTEM:CONSOLE You will get an annoying (or perhaps helpful) console window, which you can get rid of with FreeConsole . 您将获得一个烦人的(或可能有用的)控制台窗口,您可以使用FreeConsole摆脱FreeConsole
  2. Change main to WinMain with the following signature: 使用以下签名将main更改为WinMain

     int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ); 

    Unless you need to access argc and argv , this change shouldn't cause too much trouble. 除非您需要访问argcargv ,否则此更改不会引起太多麻烦。


Edit: Perhaps this is worth a look too (copied from the second tutorial): 编辑:也许这也值得一看(从第二篇教程中复制):

Under Windows operating systems, you may have created a "Windows Application" project, especially if don't want the console to show up. 在Windows操作系统下,您可能已经创建了“ Windows应用程序”项目,尤其是在不想显示控制台的情况下。 In such case, to avoid replacing main by WinMain, you can link with SFML_Main static library and keep a standard and portable main entry point. 在这种情况下,为避免用WinMain替换main,可以与SFML_Main静态库链接,并保留一个标准且可移植的main入口点。

So, I suppose that boils down to adding sfml-main.lib (or similar) to the list of libraries to link with. 因此,我想归结为将sfml-main.lib (或类似文件)添加到要链接的库列表中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Visual Studio 2010中使用OpenGL-错误LNK2019:函数___tmainCRTStartup中引用了无法解析的外部符号_WinMain @ 16 - Using OpenGL in Visual Studio 2010 - error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup 错误 LNK2019:未解析的外部符号 _WinMain@16 在 function ___tmainCRTStartup 中引用 - error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup LNK2019的另一个错误:函数____tmainCRTStartup中引用了无法解析的外部符号_WinMain @ 16 - Another error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup 帮助解决错误 LNK2019:function ___tmainCRTStartup 中引用的未解析外部符号 _WinMain@16 - help with error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup 构建错误“LNK2019:未解析的外部符号_WinMain @ 16” - Build Error “LNK2019: unresolved external symbol _WinMain@16” MSVCRTD.lib(crtexew.obj):错误LNK2019:函数___tmainCRTStartup中引用的未解析的外部符号_WinMain @ 16 - MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup 链接器错误未定义引用`WinMain @ 16&#39; - Linker error undefined reference to `WinMain@16' LNK2019:函数___tmainCRTStartup中引用的未解析的外部符号_WinMain @ 16 - LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup C++ LNK1120 和 LNK2019 错误:“未解析的外部符号 WinMain@16” - C++ LNK1120 and LNK2019 errors: "unresolved external symbol WinMain@16" Linker 错误:切换到 unicode 构建给出:未解析的外部符号 WinMain - Linker error: switch to unicode build gives: unresolved external symbol WinMain
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM