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

Author Topic: CSFML "Undefined Reference to sf::..."  (Read 8847 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
    • View Profile
CSFML "Undefined Reference to sf::..."
« on: March 12, 2020, 01:32:11 pm »
Hi, I'm trying to use CSFML in c with Linux and gcc, the problem is that it sends me an error when i compile:
"Undefined Reference to sf :: RenderWindow :: ~ RenderWindow ()"
This means that it cannot find the SFML library in C++ (the binding library)

So, I added the SFML library in C++ in addition to the CSFML and I integrated it into my makefile

main.o: main.c main.h
 gcc -c main.c -I ./Libraries/CSFML/CSFML/include/ -I ./Libraries/SFML/SFML/include/
class.o: class.c class.h
 gcc -c class.c -I ./Libraries/CSFML/CSFML/include/ -I ./Libraries/SFML/SFML/include/
build: main.o class.o
 gcc -ansi -Wall main.o class.o -o program -L ./Libraries/CSFML/CSFML/lib/ -L ./Libraries/SFML/SFML/lib/  -lsfml-graphics -lsfml-window -lsfml-system -lcsfml-graphics -lcsfml-window -lcsfml-system

The problem is that it still can't find the reference, do you know how to fix it?
Is the Binding Library integration also done with the -L and -I command?
« Last Edit: March 12, 2020, 01:36:33 pm by maximekahn »


  • SFML Team
  • Hero Member
  • *****
  • Posts: 10893
    • View Profile
    • development blog
    • Email
Re: CSFML "Undefined Reference to sf::..."
« Reply #1 on: March 12, 2020, 01:47:55 pm »
You SFML is not linked statically into CSFML, then you need to link both SFML and CSFML, but as with any library/object file with GCC, the link order matters. As the rule of thumb goes, if X depends on Y, X needs to come before Y. Since CSFML depends on SFML, you need to specify CSFML libraries before the SFML libraries.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
Dev Blog: https://duerrenberger.dev/blog/