Allegro5 和 MS Visual Studio 2010
最近我想将 Allegro5 库添加到 Visual Studio 2010 中。我访问了 allegro.cc 并下载了名为:allegro-5.0.4-msvc-10.0 的包(按照名称,我认为这是正确的),提取后,我复制了:
/bin to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
/include to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
/lib to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
Allegro's dlls to C:\Windows\System32
I also added "alld.lib" in project -> properties -> linker -> input
当我尝试在我的项目中使用 Allegro 时,我可以包含 Allegro 的标头,但当我尝试输入一些简单的内容时,这是一个错误
#include <allegro5\allegro.h>
int main()
{
allegro_init();
return 0;
}
:错误(打字模式下的红色下划线):未定义的标识符“allegro_init”。 有人能给我提示一下这个配置可能有什么问题吗? 我将非常高兴获得所有提示和解决方案。 问候,
recently I treid to add Allegro5 library to Visual Studio 2010. I visited allegro.cc and downloaded package called: allegro-5.0.4-msvc-10.0 (following the name, I think it's correct one) and after extracxtion, and I copied:
/bin to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
/include to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
/lib to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
Allegro's dlls to C:\Windows\System32
I also added "alld.lib" in project -> properties -> linker -> input
And when I tried to use Allegro in my project, I could included Allegro's headers but it's an error when I tried to type something simple like:
#include <allegro5\allegro.h>
int main()
{
allegro_init();
return 0;
}
It generates an error (red underline in typing mode) : undefinded identifier "allegro_init".
Would anyone give me a tip what might be wrong in this configuration?
I'll be very glad for all hints and solutions.
Greetings,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 wiki 上有关 Allegro 5 和 Visual Studio 2010 的文档。特别注意不要像您已经完成的那样修改系统文件夹。
无论如何,这里的问题是您正在尝试编写 Allegro 4 代码,但您已经安装了 Allegro 5。两者不兼容。 Allegro 5 完全重写并专为现代硬件而设计。正确的等效程序是:
另外,根据文件名判断,您正在与 Allegro 4 链接。 此处描述了二进制包中包含的库。有许多不同的版本用于调试、静态运行时等。
alld.lib
最直接的等效版本是allegro-5.0.4-monolith-md-debug.lib
代码>.您可以在这里找到手册:http://www.allegro.cc/manual/5/
Please see the documentation on the wiki for Allegro 5 and Visual Studio 2010. Especially note the bit about not modifying system folders like you have already done.
Anyway, the problem here is that you are trying to write Allegro 4 code but you've installed Allegro 5. The two are not compatible. Allegro 5 is completely rewritten and designed for modern hardware. The correct equivalent program is:
Also, you are linking with Allegro 4, judging by the name of the file. The libraries as included in the binary package are described here. There are many different versions included for debugging, for static run times, etc. The most direct equivalent for
alld.lib
isallegro-5.0.4-monolith-md-debug.lib
.You can find the manual here: http://www.allegro.cc/manual/5/
我猜你的大问题是你实际上并没有告诉链接器如何加载 DLL。
您可以使用 LoadLibrary 手动执行此操作 和 GetProcAddress。
然而,大多数时候,当您构建 DLL 时,您会发现您得到了一个为您处理所有上述动态链接的库。因此,您会发现将该库添加到链接器“输入”中要容易得多。
Well your big problem is, I'd guess, that you aren't actually telling the linker how to load the DLL.
You could do it manually using LoadLibrary and GetProcAddress.
However most of the time when you build a DLL you'll find you get a library which handles all the above dynamic linking for you. As a result you'll find its much easier to just add that lib to the linker "inputs".