- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 SFML 库的新手。我正在尝试编译示例程序。
我从 SFML 官方文档中得到了以下示例代码:
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Load a sprite to display
sf::Texture texture;
if (!texture.loadFromFile("cute_image.jpg"))
return EXIT_FAILURE;
sf::Sprite sprite(texture);
// Create a graphical text to display
sf::Font font;
if (!font.loadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::Text text("Hello SFML", font, 50);
// Load a music to play
sf::Music music;
if (!music.openFromFile("nice_music.ogg"))
return EXIT_FAILURE;
// Play the music
music.play();
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
window.close();
}
// Clear screen
window.clear();
// Draw the sprite
window.draw(sprite);
// Draw the string
window.draw(text);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}
我试着用下面的命令编译它:
g++.exe code.cpp -s -lsfml-main -lsfml-audio-s -lflac \
-lvorbisenc -lvorbisfile -lvorbis -logg -lsfml-network-s \
-lws2_32 -lsfml-graphics-s -lfreetype -lglew32 -ljpeg \
-lsfml-window-s -lopengl32 -lgdi32 -lsfml-system-s -lwinmm \
-lgdi32 -luser32 -lkernel32 -lcomctl32 -lmingw32 \
-luser32 -lgdi32 -ldxguid -mwindows \
-std=c++11 -o code.exe
但是我遇到了这些链接器错误(路径缩短):
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x6de): undefined reference to `_imp__alSourcePlay'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x7c8): undefined reference to `_imp__alSourcePause'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xa66): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xb7a): undefined reference to `_imp__alBufferData'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xb96): undefined reference to `_imp__alSourceQueueBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xc9d): undefined reference to `_imp__alBufferData'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xcb9): undefined reference to `_imp__alSourceQueueBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xdd8): undefined reference to `_imp__alGenBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xdfd): undefined reference to `_imp__alSourcePlay'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xed0): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xf0b): undefined reference to `_imp__alSourceUnqueueBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xfed): undefined reference to `_imp__alGetBufferi'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x100a): undefined reference to `_imp__alGetBufferi'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x1160): undefined reference to `_imp__alSourceStop'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x1180): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x11b8): undefined reference to `_imp__alSourceUnqueueBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x11ef): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x1204): undefined reference to `_imp__alDeleteBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x126d): undefined reference to `_imp__alSourcePause'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x12e7): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x12f1): undefined reference to `_imp__alSourceUnqueueBuffers'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0xe): undefined reference to `_imp__alcOpenDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x2c): undefined reference to `_imp__alcCreateContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x42): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x9b): undefined reference to `_imp__alListenerf'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0xc6): undefined reference to `_imp__alListener3f'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0xdb): undefined reference to `_imp__alListenerfv'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x19c): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x1ae): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x1c0): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x1f9): undefined reference to `_imp__alListenerf'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x24e): undefined reference to `_imp__alListener3f'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x2e4): undefined reference to `_imp__alListenerfv'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x384): undefined reference to `_imp__alListenerfv'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x445): undefined reference to `_imp__alGetEnumValue'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x47d): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x48f): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x4a9): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x501): undefined reference to `_imp__alGetEnumValue'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x521): undefined reference to `_imp__alGetEnumValue'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x541): undefined reference to `_imp__alGetEnumValue'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x59e): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x5b8): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x5d2): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x6be): undefined reference to `_imp__alIsExtensionPresent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x6e2): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x6f4): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x70d): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x7ae): undefined reference to `_imp__alcIsExtensionPresent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x807): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x820): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x839): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text$_ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev[__ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev]+0x13): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text$_ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev[__ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev]+0x25): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text$_ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev[__ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev]+0x37): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x62): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x7a): undefined reference to `_imp__alDeleteSources'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x132): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x14a): undefined reference to `_imp__alDeleteSources'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x21b): undefined reference to `_imp__alGenSources'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x23b): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x2f1): undefined reference to `_imp__alGenSources'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x30b): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x330): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x356): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x412): undefined reference to `_imp__alGetSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x44b): undefined reference to `_imp__alSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x46e): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x58b): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x5c1): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x5fb): undefined reference to `_imp__alSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x63b): undefined reference to `_imp__alSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x66c): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x69b): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x6cb): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x6fb): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x72b): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x776): undefined reference to `_imp__alGetSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x7ab): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x7db): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x80b): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x82b): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x84f): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x8da): undefined reference to `_imp__alGetSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x906): undefined reference to `_imp__alSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x91e): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x941): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x9db): undefined reference to `_imp__alGetSourcei'
collect2.exe: error: ld returned 1 exit status
我认为这是由于编译命令中静态库的顺序不正确造成的。链接静态 SFML 库的正确顺序是什么?
最佳答案
您的图书馆订单没问题(只是快速浏览了一下)。您只是忘记链接 OpenAL(在 Windows 下这将是 -lOpenAL32
),这是需要注意的,因为所有 undefined reference 都以 _imp__al
开头。完成后,一切都应该按预期链接和运行。
关于c++ - 编译 SFML 时链接 'static libraries' 的顺序是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47816264/
我是 F# 的菜鸟,目前正在阅读 F# 3.0 中的专家。 它是我学习的第一种编译语言(我只知道用 R 编程) 在第 6 章第 117 页,我们没有太多仪式性地介绍 静态让和静态成员。我真的不明白它是
我很迷茫。我已经花几个小时广泛地复习了我的两个类(class)。没有什么是静态的,没有什么是静态引用的,但我无法摆脱这个错误。 A 类文件 (ClassA.php) privateVariable =
关于类公共(public)类声明,请看这两段代码: public class Helper { public static void CallMeganFox(string phoneNumb
我如何使用“super”关键字从父类(super class)(类“aa”)引用“a1” class aa { protected static int a1 = 2; } public class
class Perkusja { boolean talerze = true; boolean beben = true; void zagrajNaBebnie() { Sys
我试图在编译 C++ 程序时静态链接库。 g++ (GCC) 4.8.5 20150623(红帽 4.8.5-4) $ g++ -std=c++11 -I/home/jerry/Desktop/tin
$ javac TestFilter.java TestFilter.java:19: non-static variable this cannot be referenced from a sta
这个问题在这里已经有了答案: How do I create a global, mutable singleton? (7 个答案) How can you make a safe static
“覆盖”静态数组时我遇到了一个棘手的问题。我有静态数组(为简单起见),它们在不同的派生类中具有固定长度,但在编译时仍然知道所有大小。我在基类中也有一个虚函数,但我不知道如何解决在派生类中覆盖这些数组和
我刚刚在遗留代码中发现了这一点。我知道使用宏,每当使用名称时,它都会被宏的内容替换。它们最常用于为数字常量提供符号名称。我所知道的是预处理没有类型安全、范围的概念。 这样做的真正好处是什么? #def
将 Singleton 实例声明为 static 还是声明为 static final 更好? 请看下面的例子: 静态版本 public class Singleton { private s
问题: 我观察到的行为是 TypeScript 的预期行为吗? 我观察到的行为是 ECMAScript 6 的预期行为吗? 是否有一种简单的方法可以返回继承层次结构以处理每个级别的“myStatic”
在php中,访问类的方法/变量有两种方法: 1. 创建对象$object = new Class(),然后使用”->”调用:$object->attribute/functi
我尝试向 ExpandoObject 添加一个动态方法,该方法会返回属性(动态添加)给它,但它总是给我错误。 我在这里做错了吗? using System; using System.Collecti
我试图获得一个静态链接到我的程序的音频库。我用 this灵活的包。为了让它运行,我必须按照描述构建 soloud 库 here .下载后不久,我在“build”文件夹中运行了“genie --with
这是我的webpack.prod.config.js代码 const path = require('path'); const { CleanWebpackPlugin } = require('c
我想知道什么时候应该对变量和(或)方法使用静态、最终、静态最终参数。据我了解: final:类似于c++中的const参数。它基本上意味着值(或在方法中 - 返回值)不会改变。 静态:这意味着值(或方
我一直在阅读有关使用静态对象作为锁的内容,最常见的示例如下: public class MyClass1 { private static final Object lock = new Obje
在 Visual Basic 2008 中,我知道有两种不同的方法可以完成同一件事: 成员(member)级别的 Dim: Dim counter1 as integer = 0 Dim counte
static public final int i = 0; public static final int i = 0; 两者都工作正常。 为什么同样的事情可以用两种不同的风格来完成? 最佳答案 因
我是一名优秀的程序员,十分优秀!