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

Author Topic: Always running into "undefined reference to" errors  (Read 1269 times)

0 Members and 1 Guest are viewing this topic.

SlowestLoris

  • Newbie
  • *
  • Posts: 1
    • View Profile
Always running into "undefined reference to" errors
« on: September 07, 2019, 06:01:23 pm »
Details:
IDE: Visual Studio Code 2019
OS: Windows 10 (64-bit)
MinGW Builds 7.3.0 (64-bit)
SFML 2.5.1 (Visual C++ 15 2017 64-bit)

Terminal Output:
g++ -g -o main main.cpp -IC:/SFML-2.5.1/include -LC:/SFML-2.5.1/lib -lsfml-graphics -lsfml-window -lsfml-system <

C:\Users\zhang\AppData\Local\Temp\ccDcqIPC.o: In function `main':
C:\Development\Game1/main.cpp:7: undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
C:\Development\Game1/main.cpp:7: undefined reference to `__imp__ZN2sf9VideoModeC1Ejjj'
C:\Development\Game1/main.cpp:7: undefined reference to `__imp__ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
C:\Development\Game1/main.cpp:8: undefined reference to `__imp__ZN2sf11CircleShapeC1Efy'
C:\Development\Game1/main.cpp:9: undefined reference to `__imp__ZN2sf5Color5GreenE'
C:\Development\Game1/main.cpp:9: undefined reference to `__imp__ZN2sf5Shape12setFillColorERKNS_5ColorE'
C:\Development\Game1/main.cpp:11: undefined reference to `__imp__ZNK2sf6Window6isOpenEv'
C:\Development\Game1/main.cpp:14: undefined reference to `__imp__ZN2sf6Window9pollEventERNS_5EventE'
C:\Development\Game1/main.cpp:17: undefined reference to `__imp__ZN2sf6Window5closeEv'
C:\Development\Game1/main.cpp:20: undefined reference to `__imp__ZN2sf5ColorC1Ehhhh'
C:\Development\Game1/main.cpp:20: undefined reference to `__imp__ZN2sf12RenderTarget5clearERKNS_5ColorE'
C:\Development\Game1/main.cpp:21: undefined reference to `__imp__ZN2sf12RenderStates7DefaultE'
C:\Development\Game1/main.cpp:21: undefined reference to `__imp__ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
C:\Development\Game1/main.cpp:22: undefined reference to `__imp__ZN2sf6Window7displayEv'
C:\Development\Game1/main.cpp:7: undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
C:\Development\Game1/main.cpp:7: undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
C:\Users\zhang\AppData\Local\Temp\ccDcqIPC.o: In function `sf::CircleShape::~CircleShape()':
C:/SFML-2.5.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `__imp__ZTVN2sf11CircleShapeE'
C:/SFML-2.5.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `__imp__ZTVN2sf11CircleShapeE'
C:/SFML-2.5.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `__imp__ZN2sf5ShapeD2Ev'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1

I am using the tutorial's basic test code. Any help would be greatly appreciated!

Notes:
I have tried using other versions of Visual C++ under SFML 2.5.1 with no luck.
« Last Edit: September 07, 2019, 08:00:37 pm by SlowestLoris »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Always running into "undefined reference to" errors
« Reply #1 on: September 09, 2019, 08:58:49 am »
Since you're building your application in debug mode (-g) you should also use the SFML debug libraries - the ones with the -d suffix. The linking looks correct otherwise.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything