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

Author Topic: Configuration SFML on Debian under Codeblocks.  (Read 3523 times)

0 Members and 1 Guest are viewing this topic.

znyk

  • Newbie
  • *
  • Posts: 10
    • View Profile
Configuration SFML on Debian under Codeblocks.
« on: April 16, 2018, 05:32:05 pm »
I configured Codeblocks as well:
https://www.sfml-dev.org/tutorials/2.4/start-cb.php

When I compile example program

#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;
}

There are some errors:

 
------------- Build: Debug in testik (compiler: GNU GCC Compiler)---------------
>
g++ -L/home/znyk/SFML-2.4.2/lib -o bin/Debug/testik obj/Debug/tescik.o   /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a /home/znyk/SFML-2.4.2/lib/libsfml-audio-s-d.a /home/znyk/SFML-2.4.2/lib/libsfml-network-s-d.a /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a /home/znyk/SFML-2.4.2/lib/libsfml-system-s-d.a
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(Color.cpp.o): relocation R_X86_64_32 against hidden symbol `_ZN2sf5Color5BlackE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(RenderStates.cpp.o): relocation R_X86_64_32 against hidden symbol `_ZN2sf12RenderStates7DefaultE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(RenderTarget.cpp.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(RenderWindow.cpp.o): relocation R_X86_64_32S against hidden symbol `_ZTVN2sf12RenderWindowE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(Shader.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(Texture.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(TextureSaver.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(Transform.cpp.o): relocation R_X86_64_32 against hidden symbol `_ZN2sf9Transform8IdentityE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(GLLoader.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(Shape.cpp.o): relocation R_X86_64_32S against hidden symbol `_ZTVN2sf5ShapeE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(CircleShape.cpp.o): relocation R_X86_64_32S against hidden symbol `_ZTVN2sf11CircleShapeE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(VertexArray.cpp.o): relocation R_X86_64_32S against hidden symbol `_ZTVN2sf11VertexArrayE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(BlendMode.cpp.o): relocation R_X86_64_32 against hidden symbol `_ZN2sf10BlendAlphaE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(GLCheck.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(GLExtensions.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(Image.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(ImageLoader.cpp.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-graphics-s-d.a(Transformable.cpp.o): relocation R_X86_64_32S against hidden symbol `_ZTVN2sf13TransformableE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(Context.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(GlContext.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(GlResource.cpp.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0@@CXXABI_1.3' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(VideoMode.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(Window.cpp.o): relocation R_X86_64_32S against hidden symbol `_ZTVN2sf6WindowE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(WindowImpl.cpp.o): relocation R_X86_64_32S against hidden symbol `_ZTVN2sf4priv10WindowImplE' can not be used when making a shared object
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(VideoModeImpl.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(WindowImplX11.cpp.o): relocation R_X86_64_32 against undefined symbol `__pthread_key_create' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(GlxContext.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(GlxExtensions.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(JoystickManager.cpp.o): relocation R_X86_64_32 against undefined symbol `__pthread_key_create' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(SensorManager.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(Display.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(JoystickImpl.cpp.o): relocation R_X86_64_32 against undefined symbol `__pthread_key_create' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-window-s-d.a(Joystick.cpp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-system-s-d.a(Err.cpp.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-system-s-d.a(Lock.cpp.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0@@CXXABI_1.3' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-system-s-d.a(Mutex.cpp.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0@@CXXABI_1.3' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-system-s-d.a(String.cpp.o): relocation R_X86_64_32 against undefined symbol `__pthread_key_create' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-system-s-d.a(ThreadLocal.cpp.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0@@CXXABI_1.3' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/znyk/SFML-2.4.2/lib/libsfml-system-s-d.a(Time.cpp.o): relocation R_X86_64_32 against hidden symbol `_ZN2sf4Time4ZeroE' can not be used when making a shared object
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

HELP. :-[

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Configuration SFML on Debian under Codeblocks.
« Reply #1 on: April 17, 2018, 08:02:51 am »
Since you're linking statically you need to set SFML_STATIC.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

znyk

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Configuration SFML on Debian under Codeblocks.
« Reply #2 on: April 17, 2018, 12:08:02 pm »
I setup SFML_STATIC in Compiler settings -> #defines and have errors.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Configuration SFML on Debian under Codeblocks.
« Reply #3 on: April 18, 2018, 01:36:06 pm »
what errors?

if you're using Debian, you could just type in the terminal:
Quote
sudo apt-get install codeblocks gcc g++ libsfml-dev
then, in the menus "Project -> Build Options -> Linker Settings", you add these in the "Link libraries":
sfml-network
sfml-audio
sfml-graphics
sfml-window
sfml-system

and remove any other settings you have changed (unless you REALLY want to link SFML statically).
Visit my game site (and hopefully help funding it? )
Website | IndieDB

znyk

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Configuration SFML on Debian under Codeblocks.
« Reply #4 on: April 23, 2018, 07:35:25 am »
Code: [Select]
[dode]Cleaned "sfml - Release"

-------------- Build: Release in sfml (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -O2 -DSFML_STATIC -I../../SFML-2.4.2/include -c /home/znyk/Pulpit/sfml/main.cpp -o obj/Release/main.o
g++ -L../../SFML-2.4.2/lib -o bin/Release/sfml obj/Release/main.o  -s  -lsfml-network -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system
/usr/bin/ld: warning: libjpeg.so.8, needed by ../../SFML-2.4.2/lib/libsfml-graphics.so, not found (try using -rpath or -rpath-link)
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_std_error@LIBJPEG_8.0'
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_set_defaults@LIBJPEG_8.0'
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_start_compress@LIBJPEG_8.0'
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_set_quality@LIBJPEG_8.0'
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_stdio_dest@LIBJPEG_8.0'
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_finish_compress@LIBJPEG_8.0'
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_CreateCompress@LIBJPEG_8.0'
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_destroy_compress@LIBJPEG_8.0'
../../SFML-2.4.2/lib/libsfml-graphics.so: undefined reference to `jpeg_write_scanlines@LIBJPEG_8.0'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 2 second(s))
10 error(s), 1 warning(s) (0 minute(s), 2 second(s))
 

What is wrong ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Configuration SFML on Debian under Codeblocks.
« Reply #5 on: April 23, 2018, 07:42:25 am »
You're missing libjpeg.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/