MVS中的SDL奇怪的链接器错误 [英] SDL strange linker error in MVS

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

问题描述

在尝试将SDL库与MVS 2010中的新C ++ Win32控制台应用程序链接时,我很沮丧.

I'm stumped trying to link the SDL libraries against a new C++ Win32 Console application in MVS 2010.

我下载了最新的SDL开发库,并执行了通常的步骤:

I downloaded the latest SDL development libraries, and did the usual steps:

  1. 将包含项添加到包含路径中( pic ) #include文件]
  2. 添加了SDL的库路径( pic )此附加路径给出错误错误LNK1104:无法打开文件'SDL.lib'"]
  3. 将SDL.lib和SDLmain.lib添加到链接器的其他依赖项( pic )
  1. Added the includes to the include path (pic) [This works fine, as MVS finds the #include files]
  2. Added the library path for SDL (pic) [This seems to work fine, as removing this additional path gives the error "error LNK1104: cannot open file 'SDL.lib'"]
  3. Added SDL.lib and SDLmain.lib to the linker additional dependencies (pic)

我编辑了主文件以包含一些测试代码,使其看起来像这样:

I edited the main file to have some test code, leaving it looking like this:

#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include "SDL.h"

int _tmain(int argc, _TCHAR* argv[])
{
int a;

SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO);

std::cout << "Pong" << std::endl;
std::cin >> a;

return 0;
}

当我编译时,出现以下链接器错误:

And when I compile I get the following linker errors:

Error   1   error LNK2019: unresolved external symbol _SDL_Init referenced in function _wmain   D:\All\Proyects\PFC\RT-Pong\RT-Pong\RT-Pong\RT-Pong.obj RT-Pong
Error   2   error LNK1120: 1 unresolved externals   D:\All\Proyects\PFC\RT-Pong\RT-Pong\Debug\RT-Pong.exe   1   1   RT-Pong

如果我的.lib损坏,我从0开始重新下载了整个文件,并得到了相同的结果.老实说,我很沮丧,这很像是我忽略的一个粗心的简单错误.因此,如果有人对此事有新的见解,那真的会让我感到高兴.

In case I had a corrupted .lib, I downloaded the whole thing again, starting from 0, and got the same result. I'm honestly stumped, and it reeks of being a careless simple mistake that I'm overlooking. So if anyone has some fresh input on the matter, it would really make my day.

谢谢, 海梅

推荐答案

我认为由于在SDL的库路径中定义的路径错误"而导致链接错误

I think you got linking error due to "wrong path defined at library path for SDL"

Project->Properties->Configuration Properties->Linker->General->Additional Library Directories

更改路径:D:\All\Proyects\PFC\RT-Pong\SDL-1.2.15\lib\x64

此:D:\All\Proyects\PFC\RT-Pong\SDL-1.2.15\lib\x86

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

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