我在Visual Studio 2013中使用SDL 2.0.1收到LNK2019错误 [英] I'm getting LNK2019 errors using SDL 2.0.1 in Visual Studio 2013

查看:137
本文介绍了我在Visual Studio 2013中使用SDL 2.0.1收到LNK2019错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是错误代码,并且此处
[VectorEngine.h]

Here are the error codes and here [VectorEngine.h]

#ifndef _CAPP_H_
#define _CAPP_H_
#include  <SDL.h>

class VectorEngine
{
    private:

        bool        running;
        SDL_Window* Surf_Display;

    public:
        VectorEngine();
        void onExecute();
        bool OnInit();
        void OnEvent(SDL_Event* Event);
        void OnTick();
        void OnRender();
        void OnCLeanup();
};
#endif

[Main.cpp]

#include"VectorEngine.h"
#include <Windows.h>

const int TICKS_PER_SECOND = 25;
const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
const int MAX_RENDERSKIPS = 5;

VectorEngine::VectorEngine()
{
    Surf_Display = NULL;
    running = true;
    OnInit();
    onExecute();
}

void VectorEngine::onExecute()
{
    SDL_Event Event;
    DWORD next_game_tick = GetTickCount();
    while (running)
    {
        int skippedRenders = 0;
        while (GetTickCount()> next_game_tick && skippedRenders < MAX_RENDERSKIPS)
        {
            OnTick();
            next_game_tick += SKIP_TICKS;
            skippedRenders++;
        }
        OnRender();
    }
}

int main (int argc, char* argv[])
{
    VectorEngine  *vecEngine = new VectorEngine();
    return 0;
}

[Oninit.cpp]

#include "VectorEngine.h"

bool VectorEngine::OnInit()
{
    SDL_Init(SDL_INIT_EVERYTHING);
    Surf_Display = SDL_CreateWindow("My Game Window",
                                    SDL_WINDOWPOS_UNDEFINED,
                                    SDL_WINDOWPOS_UNDEFINED,
                                    640, 480,
                                    SDL_WINDOW_SHOWN| SDL_WINDOW_OPENGL);
    return true;
}

[OnCLeanup.cpp]

#include"VectorEngine.h"

void VectorEngine::OnCLeanup()
{
    SDL_Quit();
}

这是指向所有代码的链接,在此处[)。

This is the link to all the code an [here]().

这是所有链接器设置的链接:

This is the link to all the linker settings:

Error    5    error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup    C:\Users\XSoloDoloX\Desktop\VecEng\GameForReal\GameForReal\MSVCRTD.lib(crtexew.obj)    GameForReal

Error    2    error LNK2019: unresolved external symbol _SDL_Quit referenced in function "public: void __thiscall VectorEngine::OnCLeanup(void)" (?OnCLeanup@VectorEngine@@QAEXXZ)    C:\Users\XSoloDoloX\Desktop\VecEng\GameForReal\GameForReal\OnCleanup.obj    GameForReal

Error    4    error LNK2019: unresolved external symbol _SDL_Init referenced in function "public: bool __thiscall VectorEngine::OnInit(void)" (?OnInit@VectorEngine@@QAE_NXZ)    C:\Users\XSoloDoloX\Desktop\VecEng\GameForReal\GameForReal\OnInit.obj    GameForReal

Error    3    error LNK2019: unresolved external symbol _SDL_CreateWindow referenced in function "public: bool __thiscall VectorEngine::OnInit(void)" (?OnInit@VectorEngine@@QAE_NXZ)    C:\Users\XSoloDoloX\Desktop\VecEng\GameForReal\GameForReal\OnInit.obj    GameForReal

Error    6    error LNK1120: 4 unresolved externals    C:\Users\XSoloDoloX\Desktop\VecEng\GameForReal\Debug\GameForReal.exe    1    1    GameForReal


推荐答案

好,所以出于某种原因,我发现使用x64库会导致错误,因此使用x86可以解决问题!

Ok So I figured it out for some reason using the x64 libraries was causing the errors so using x86 fixed the problems!

这篇关于我在Visual Studio 2013中使用SDL 2.0.1收到LNK2019错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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