SFML:对 _imp_ 的未定义引用 [英] SFML: undefined reference to _imp_

查看:17
本文介绍了SFML:对 _imp_ 的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 SFML 创建 C++ 应用程序.按照教程,为 Windows 安装了 MinGW.我的项目在其根文件夹中有一个 main.cpp 文件,并且 SFML 包含在 lib/sfml 中(相对于 main.cpp).

I'm trying to create a C++ application with SFML. Followed the tutorial, installed MinGW for Windows. My project has a main.cpp file in its root folder, and SFML is included in lib/sfml (relative to main.cpp).

我可以使用命令g++ -c main.cpp -g -o build/debug/game.o -Ilib/sfml/include

但是当我尝试使用命令 g++ build/debug/game.o -o build/debug/game.exe -Llib/sfml/lib -lsfml-graphics-d -lsfml 链接时,我得到了未定义的引用-window-d -lsfml-system-d

But I get undefined references when I try to link wit the command g++ build/debug/game.o -o build/debug/game.exe -Llib/sfml/lib -lsfml-graphics-d -lsfml-window-d -lsfml-system-d

一些错误:

C:UsersandreDocumentsReposGame/main.cpp:5: undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
C:UsersandreDocumentsReposGame/main.cpp:5: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:UsersandreDocumentsReposGame/main.cpp:5: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'

我已经搜索过了,但似乎没有任何帮助.我发现奇怪的是,在某些先前版本的 SFML 中,它在 lib 文件夹中带有更多库,例如 opengl32.lib.不过,它说,例如,我需要 sfml-graphics:

I've searched already and nothing seems to help me. What I found strange is that in some previous versions of SFML it came with more libs inside the lib folder, like opengl32.lib. Still, it says that, for example, sfml-graphics I need:

sfml-window-s.lib
sfml-system-s.lib
opengl32.lib
freetype.lib
jpeg.lib

唯一缺少的是opengl32.lib.如果我考虑 sfml-system 和 sfml-window,它也缺少 winmm.lib、gdi32.lib.我不知道这是否与错误有关,但欢迎提供任何帮助.

The only one missing is opengl32.lib. If I consider sfml-system and sfml-window, it is missing too winmm.lib, gdi32.lib. I don't know if this has something to do with the errors, but any help is welcome.

推荐答案

解决了,我的错.几天前我下载了 Visual C++ 编译器的 SFML 版本,但后来我放弃了 Visual Studio 2017 并决定将 Visual Studio Code 与 GCC 一起使用.所以我尝试使用我认为正确的 SFML.现在我已经下载了正确的版本,它运行良好.

Solved, my mistake. I downloaded some days ago the SFML version for Visual C++ compiler, but then I gave up on Visual Studio 2017 and decided to use Visual Studio Code with GCC. So I tried to use the SFML I had thinking it was the right one. Now I've downloaded the right version and it is working perfectly.

这篇关于SFML:对 _imp_ 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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