我试图编译这个:
#include < SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
clang++-c main.cpp工作!啊!
clang++main.o-o sfml应用程序-lsfml图形-lsfml窗口-lsfml系统
给我衰减错误:
/usr/bin/ld: warning: libGLEW.so.1.5, needed by /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libjpeg.so.62, needed by /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_finish_compress@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_write_scanlines@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewUniform1fARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_std_error@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__GLEW_ARB_shader_objects'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewGetObjectParameterivARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__GLEW_ARB_vertex_shader'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewFramebufferTexture2DEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewUniformMatrix4fvARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_set_quality@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewGenFramebuffersEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewUniform3fARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_set_defaults@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewRenderbufferStorageEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_CreateCompress@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__GLEW_ARB_fragment_shader'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewActiveTextureARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_start_compress@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewShaderSourceARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `glewInit'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewBindFramebufferEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewFramebufferRenderbufferEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewLinkProgramARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewUseProgramObjectARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewBlendFuncSeparateEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewGenRenderbuffersEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewUniform2fARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_destroy_compress@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewUniform4fARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewCreateProgramObjectARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `glewGetErrorString'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewCompileShaderARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewDeleteRenderbuffersEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewDeleteObjectARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewGetUniformLocationARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewGetInfoLogARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__GLEW_EXT_blend_func_separate'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewDeleteFramebuffersEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewCheckFramebufferStatusEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewUniform1iARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__GLEW_ARB_texture_non_power_of_two'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `jpeg_stdio_dest@LIBJPEG_6.2'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__GLEW_ARB_shading_language_100'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewCreateShaderObjectARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewBindRenderbufferEXT'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__GLEW_EXT_framebuffer_object'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewAttachObjectARB'
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libsfml-graphics.so: undefined reference to `__glewGetHandleARB'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
最佳答案
正如前两行中的错误消息所表明的,您显然缺少libGLEW
和libjpeg
。您需要安装它们各自的开发包(或者自己下载、编译和安装它们)。
其他的错误只是缺少的函数,这些函数应该在依赖项libs中。
关于c++ - C++ SFML 2.1未定义对GLEW的引用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27505549/