Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Linux] SFML 2.0 won't link properly  (Read 4095 times)

0 Members and 1 Guest are viewing this topic.

cgonz905

  • Guest
[Linux] SFML 2.0 won't link properly
« on: May 04, 2013, 05:31:55 pm »
I'm trying to run the tutorial sample code from here: http://www.sfml-dev.org/tutorials/2.0/start-linux.php
It compiles successfully, but when I run:
 g++ main.o -o app -lsfml-graphics -lsfml-window -lsfml-system
I get these errors:

/usr/bin/ld: warning: libjpeg.so.62, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_finish_compress@LIBJPEG_6.2'
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_write_scanlines@LIBJPEG_6.2'
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_std_error@LIBJPEG_6.2'
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_set_quality@LIBJPEG_6.2'
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_set_defaults@LIBJPEG_6.2'
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_CreateCompress@LIBJPEG_6.2'
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_start_compress@LIBJPEG_6.2'
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_destroy_compress@LIBJPEG_6.2'
/usr/lib/gcc/x86_64-linux-gnu/4.6/libsfml-graphics.so: undefined reference to `jpeg_stdio_dest@LIBJPEG_6.2'
collect2: ld returned 1 exit status


Can someone please help me get this working? Thank you so much in advance.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10826
    • View Profile
    • development blog
    • Email
Re: [Linux] SFML 2.0 won't link properly
« Reply #1 on: May 04, 2013, 06:34:40 pm »
You miss the jpeg library (see here for the full dependency list).
You should be able to grab it from your distros package manager.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cgonz905

  • Guest
Re: [Linux] SFML 2.0 won't link properly
« Reply #2 on: May 04, 2013, 07:10:23 pm »
I installed "libjpeg-dev" and I keep getting the same errors. Is that the wrong package?
« Last Edit: May 04, 2013, 07:15:35 pm by cgonz905 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10826
    • View Profile
    • development blog
    • Email
Re: [Linux] SFML 2.0 won't link properly
« Reply #3 on: May 04, 2013, 08:14:22 pm »
So from where did you get SFML? Have you built it yourself?
If not, then the versions might not be the same. Which version of libjpeg-dev have you installed?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cgonz905

  • Guest
Re: [Linux] SFML 2.0 won't link properly
« Reply #4 on: May 04, 2013, 08:28:36 pm »
I install SFML via apt-get (sudo apt-get install libsfml-dev) and JPEG via apt-get (sudo apt-get install libjpeg-dev)

I'm not entirely sure what versions, but that's what I did.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10826
    • View Profile
    • development blog
    • Email
Re: [Linux] SFML 2.0 won't link properly
« Reply #5 on: May 04, 2013, 08:55:00 pm »
From the command I guess you're on a Debian like distro and from what I know, none of them have already update their packages to SFML 2, so you essentially end up with SFML 1.6.
You should either get the binary from the download page or even better build SFML yourself. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cgonz905

  • Guest
Re: [Linux] SFML 2.0 won't link properly
« Reply #6 on: May 04, 2013, 09:16:08 pm »
I took your advice and I downloaded the SDK instead. I placed the lib, include and share folders inside of usr/local. After doing that, I compiled the sample program successfully but I ran into the same errors when I tried linking.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10826
    • View Profile
    • development blog
    • Email
Re: [Linux] SFML 2.0 won't link properly
« Reply #7 on: May 04, 2013, 09:39:13 pm »
Make sure to uninstall the libsfml-dev package, otherwise the compiler *might* use the old libs.
Also make sure to do a clean build.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cgonz905

  • Guest
Re: [Linux] SFML 2.0 won't link properly
« Reply #8 on: May 06, 2013, 11:08:36 pm »
I fixed the problem. I ended up switching OSes anyways, so I had a clean install of everything. So in Lubuntu 13.04 I simply downloaded SFML 2.0 then compiled with:
 
g++ main.o -o sfml-app -L<sfml-install-path>/lib -lsfml-graphics -lsfml-window -lsfml-system
And I installed the JPEG library via "sudo apt-get install libjpeg62-dev"

But now I'm getting these errors:

/usr/bin/ld: warning: libGLEW.so.1.5, needed by /home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so, not found (try using -rpath or -rpath-link)
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewUniform1fARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__GLEW_ARB_shader_objects'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewGetObjectParameterivARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__GLEW_ARB_vertex_shader'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewFramebufferTexture2DEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewUniformMatrix4fvARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewGenFramebuffersEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewUniform3fARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewRenderbufferStorageEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__GLEW_ARB_fragment_shader'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewActiveTextureARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewShaderSourceARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `glewInit'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewBindFramebufferEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewFramebufferRenderbufferEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewLinkProgramARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewUseProgramObjectARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewBlendFuncSeparateEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewGenRenderbuffersEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewUniform2fARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewUniform4fARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewCreateProgramObjectARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `glewGetErrorString'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewCompileShaderARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewDeleteRenderbuffersEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewDeleteObjectARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewGetUniformLocationARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewGetInfoLogARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__GLEW_EXT_blend_func_separate'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewDeleteFramebuffersEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewCheckFramebufferStatusEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewUniform1iARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__GLEW_ARB_texture_non_power_of_two'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__GLEW_ARB_shading_language_100'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewCreateShaderObjectARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewBindRenderbufferEXT'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__GLEW_EXT_framebuffer_object'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewAttachObjectARB'
/home/christian/Documents/C++/Libraries/SFML/lib/libsfml-graphics.so: undefined reference to `__glewGetHandleARB'
collect2: error: ld returned 1 exit status

I'm assuming I'm missing GLEW, but when I entered: "sudo apt-get install libglew-dev" it still doesn't work. Did I install the wrong library? Or am I totally off here?
« Last Edit: May 06, 2013, 11:20:11 pm by cgonz905 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10826
    • View Profile
    • development blog
    • Email
Re: [Linux] SFML 2.0 won't link properly
« Reply #9 on: May 06, 2013, 11:28:46 pm »
Seems like sfml-graphics was built with GLEW 1.5 and your OS probably uses a newer version.
You've now the option to build SFML new or get the 1.5 version (if that's possible).
I suggest to build SFML newly, just because, you'll then know that all the dependencies match. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cgonz905

  • Guest
Re: [Linux] SFML 2.0 won't link properly
« Reply #10 on: May 07, 2013, 02:48:45 am »
Seems like sfml-graphics was built with GLEW 1.5 and your OS probably uses a newer version.
You've now the option to build SFML new or get the 1.5 version (if that's possible).
I suggest to build SFML newly, just because, you'll then know that all the dependencies match. ;)

If I'm gonna build from source, I have to install all the dependencies. But I can't find the xlib dependency. After "apt-cache search libxlib" I get these results:

libbox-dev - Boxlib: C++ Block-structured finite difference algorithms library
libevas1-engines-x - Evas module providing the X11 engines
libexene-smlnj - Concurrent ML library for the X Window System
libforms2 - The XForms graphical interface widget library
libformsgl2 - The OpenGL XForms graphical interface widget library
libghc-x11-dev - Haskell X11 binding for GHC
libghc-x11-doc - Haskell X11 binding for GHC; documentation
libghc-x11-prof - Haskell X11 binding for GHC; profiling libraries
libhugs-x11-bundled - A binding to the X11 graphics library
libmixlib-authentication-ruby - Transitional package for ruby-mixlib-authentication
libmixlib-authentication-ruby1.8 - Transitional package for ruby-mixlib-authentication
libmixlib-cli-ruby - Transitional package for ruby-mixlib-cli
libmixlib-cli-ruby1.8 - Transitional package for ruby-mixlib-cli
libmixlib-cli-ruby1.9.1 - Transitional package for ruby-mixlib-cli
libmixlib-config-ruby - Transitional package for ruby-mixlib-config
libmixlib-config-ruby1.8 - Transitional package for ruby-mixlib-config
libmixlib-log-ruby - Transitional package for ruby-mixlib-log
libmixlib-log-ruby1.8 - Transitional package for ruby-mixlib-log
libomxil-bellagio0-components-xvideo - XVideo components for Bellagio OpenMAX IL
libvia-dev - library for volumetric image analysis
libvia2 - library for volumetric image analysis
libxdo-dev - library for simulating X11 keyboard/mouse input
libxdo2 - library for simulating X11 keyboard/mouse input

Which library is it? It seems like it could be any one of them.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: [Linux] SFML 2.0 won't link properly
« Reply #11 on: May 07, 2013, 07:54:46 am »
libx11-dev ;)
Laurent Gomila - SFML developer

cgonz905

  • Guest
Re: [Linux] SFML 2.0 won't link properly
« Reply #12 on: May 08, 2013, 11:42:24 pm »
libx11-dev ;)

Thank you! One last questions. I built SFML 2.0 via cmake and everything compiles and links correctly with the test "main.cpp", my only problem is when I run it the app, I have to run via "export LD_LIBRARY_PATH=<sfml-install-path>/lib && ./sfml-app"

How do I solve this problem? I compiled and linked without having to specify which directory the "SFML Build" was located, but I do when it comes to running the app? I also compiled SFML (The library, not the app) via "make all" then "make install" if that helps at all.

Any ideas?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: [Linux] SFML 2.0 won't link properly
« Reply #13 on: May 09, 2013, 08:58:05 am »
This is because the library loader (ld) doesn't know <sfml-install-path>/lib. You should search on Google the way to add a path permanently to ld (I never remember ;)).
Laurent Gomila - SFML developer

cgonz905

  • Guest
Re: [Linux] SFML 2.0 won't link properly
« Reply #14 on: May 09, 2013, 05:27:13 pm »
This is because the library loader (ld) doesn't know <sfml-install-path>/lib. You should search on Google the way to add a path permanently to ld (I never remember ;)).

Oh, silly mistake on my end. Turns out once you run:  "export LD_LIBRARY_PATH=<sfml-install-path>/lib" you only have to do that once. So I'm okay now. Thank you all for your help!