_main_getcmdline 中的链接器错误 _SDL_main 未解决 [英] Linker error _SDL_main unresolved in _main_getcmdline

查看:68
本文介绍了_main_getcmdline 中的链接器错误 _SDL_main 未解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 LazyFoo 的 SDL2 教程.我完成了前十节课,现在我收到了这个错误(在我编译之前,我没有收到来自 VS 的任何错误).

I'm following LazyFoo's tutorial for SDL2. I went through the first ten lessons, and now i'm getting this error (until i compile i don't get any errors from VS).

1>------ Inizio compilazione: Progetto: yetANewSDLProj, Configurazione: Debug Win32 ------
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: riferimento al simbolo esterno _SDL_main non risolto nella funzione _main_getcmdline
1>Compilazione progetto "yetANewSDLProj.vcxproj" NON COMPLETATA.
========== Compilazione: 0 completate, 1 non riuscite, 0 aggiornate, 0 ignorate ==========

在函数_SDL_getcmdline"中未解析对外部符号_SDL_main"的引用

"Reference to external symbol "_SDL_main" unresolved in the function "_SDL_getcmdline"

在我看来,错误不在我的代码中,而是在 SDL 的文件之间,但我无法弄清楚 Visual Studio 没有找到哪个文件或原因.我创建了一个新的空项目,我唯一的代码(一个文件,main.cpp)是:

It seems to me that the error is not in my code but rather between SDL's files but i can't figure out which file supposedly Visual Studio doesn't find or why. I created a new empty project, the only code i have (one file, main.cpp) is:

#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>

int main(int argc, char* argv[])
{
    SDL_Init(SDL_INIT_VIDEO);
    while(1){}
    SDL_Quit();
    return 0;
}

包含文件在路径:"C:\vs_dev_lib\include"
DLL/lib 文件:C:\vs_dev_lib\lib\x86"
两个路径都插入到VC++ 目录"(包括目录/库目录)中.
我还复制了 System32 和 SysWOW64 中的所有 DLL.
我还尝试在我的项目目录中复制 DLL 和 .lib 文件.
头文件、dll 和 lib 文件来自 SDL2、SDL2 图像、Mixer 和 TTF(在所有情况下都是 Windows 的开发库(Visual C++ 32/64 位).

The include files are in the path: "C:\vs_dev_lib\include"
The DLL/lib files: "C:\vs_dev_lib\lib\x86"
Both paths are inserted in "VC++ Directories" (Include Directories / Library Directories).
I also copied all DLLs in both System32 and SysWOW64.
I also tried copying DLLs and .lib file in my project directory.
The headers, dll and lib files are from SDL2, SDL2 image, Mixer and TTF (in all cases development libraries for windows (Visual C++ 32/64-bit).

链接器/输入/附加依赖项如下所示:

Linker/Input/Additional Denpendencies look like this:

SDL2.lib
SDL2main.lib
SDL2_image.lib
SDL2_ttf.lib
SDL2_mixer.lib

链接器/系统/子系统设置为控制台(/SUBSYSTEM:CONSOLE)"

Linker/System/Subsystem is set to "Console(/SUBSYSTEM:CONSOLE)"

字符集是多字节字符集"(翻译的,不确定它的英文拼写如何).

Character set is "Multibyte character set" (translated, not sure how exactly it's spelled in english).

提前致谢,如果您需要任何其他信息,请告诉我.谷歌搜索没有给我带来任何运气,过去两天我一直在坚持这个:/

Thanks in advance, if you need any other info let me know. Googling didn't bring me any luck, i've been stuck with this for the past two days :/

推荐答案

如果您要手动提供入口点,请尝试在包含 sdl 标头之前定义 #define SDL_MAIN_HANDLED.

Try defining #define SDL_MAIN_HANDLED prior to including sdl headers if you are going to manually provide an entry point.

#define SDL_MAIN_HANDLED
#include "SDL.h"

int main(int argc, char *argv[])
{
    SDL_SetMainReady();
    SDL_Init(SDL_INIT_VIDEO);
...

这篇关于_main_getcmdline 中的链接器错误 _SDL_main 未解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆