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

Author Topic: Unexpected Errors with SFML in VSCode  (Read 1173 times)

0 Members and 1 Guest are viewing this topic.

symt0p

  • Newbie
  • *
  • Posts: 1
    • View Profile
Unexpected Errors with SFML in VSCode
« on: May 05, 2023, 06:25:14 pm »
Hello, I'm having errors with building with SFML. For context, I downloaded the most recent 64-bit Visual C++ 15 (2017) version of SFML, and I'm currently using VSCode, with the MinGW compiler. This error occurs whenever I write any line regarding SFML, in this case it's just :

VideoMode vm(1920, 1000);

I'm compiling on the  terminal with this command:

g++ src/main.cpp -o main -I"SFML/include" -L"SFML/lib" -lopenal32 -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system -o main

and I'm getting this error back:

c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\shiya\AppData\Local\Temp\cc4H6TOZ.o:main.cpp:(.text+0x28): undefined reference to `__imp__ZN2sf9VideoModeC1Ejjj'

The compiler seems to recognize all the files I've linked, so I'm unsure as to where this undefined reference is coming from. I've also copied all the dll files from SFML/bin into my project folder. Thanks in advance.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Unexpected Errors with SFML in VSCode
« Reply #1 on: May 06, 2023, 10:30:48 am »
Why do you download the Visual Studio pre-built package when you then use MinGW?

Compilers have to match exactly with the one you want to use. We recommend to use CMake, e.g. with the CMake SFML Template, which also automatically build SFML for you with whatever compiler you've chosen.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything