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

Author Topic: Undefined refence to "_imp___ZN2s*****" on build  (Read 2937 times)

0 Members and 1 Guest are viewing this topic.

Tafe_Warrior

  • Newbie
  • *
  • Posts: 1
    • View Profile
Undefined refence to "_imp___ZN2s*****" on build
« on: August 26, 2024, 09:50:39 am »
I have been trying to get SFML to work for the last few hours.
https://en.sfml-dev.org/forums/index.php?topic=13304.0
https://en.sfml-dev.org/forums/index.php?topic=27427.0
These two posts had a similar issue but did not help resolve mine.
c++ code:
#include <SFML/Graphics.hpp>

int main() {
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
    return 0;
}
Build log:
C:\MinGW\bin\g++.exe -fdiagnostics-color=always -g "C:\Users\aleki\Documents\UQ\COSC3500 (High Performance Computing)\COSC3500-Flocking\visualiser.cpp" -o "C:\Users\aleki\Documents\UQ\COSC3500 (High Performance Computing)\COSC3500-Flocking\visualiser.exe" -I C:\SFML-2.6.1\include -L C:\SFML-2.6.1\lib -lsfml-graphics -lsfml-window -lsfml-system
C:\Users\aleki\AppData\Local\Temp\cckkE4nr.o: In function `main&#39;:
C:/Users/aleki/Documents/UQ/COSC3500 (High Performance Computing)/COSC3500-Flocking/visualiser.cpp:4: undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale&#39;
C:/Users/aleki/Documents/UQ/COSC3500 (High Performance Computing)/COSC3500-Flocking/visualiser.cpp:4: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj&#39;
C:/Users/aleki/Documents/UQ/COSC3500 (High Performance Computing)/COSC3500-Flocking/visualiser.cpp:4: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE&#39;
C:/Users/aleki/Documents/UQ/COSC3500 (High Performance Computing)/COSC3500-Flocking/visualiser.cpp:4: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev&#39;
collect2.exe: error: ld returned 1 exit status

Build finished with error(s).

I am using VSCode on Windows, with SFML version 2.6.1. I am completely new to using 3rd party c++ libraries so please be understanding. I have tried my best to link the right files but I know I could be at fault here.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Undefined refence to "_imp___ZN2s*****" on build
« Reply #1 on: August 26, 2024, 10:48:23 am »
For VS Code I highly recommend to install the CMake extension and use the SFML CMake Template.

That way you don't have to manually craft compile/build commands and it's guaranteed that SFML is built with the compiler you're using. Among other things like automatic debug/release switching.

For the given error, since you're using the -g debug flag, you'll also need to link the SFML debug libraries, i.e. the ones with the -d suffix.
And probably more importantly, your compiler has to match 100% the one used to build the SFML binaries. Best you download the compiler linked on the SFML download page.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything