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

Author Topic: static linking  (Read 1622 times)

0 Members and 2 Guests are viewing this topic.

daniel08

  • Newbie
  • *
  • Posts: 3
    • View Profile
static linking
« on: October 12, 2023, 11:08:34 pm »
why does it say undefined reference when static linking.
im trying to create a sf::tcpsocket
it says exit code 1

Thrasher

  • SFML Team
  • Jr. Member
  • *****
  • Posts: 57
    • View Profile
Re: static linking
« Reply #1 on: October 13, 2023, 06:34:17 am »
Did you remember to define SFML_STATIC?

daniel08

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: static linking
« Reply #2 on: October 13, 2023, 03:30:41 pm »
ye i have SFML_STATIC and linked sfml-network-s

daniel08

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: static linking
« Reply #3 on: October 13, 2023, 03:31:52 pm »
error message is:
Quote
g++.exe -DSFML_STATIC -ID:\SFML\include -c C:\Users\Daniel\OneDrive\Desktop\projects\learn.cpp -o C:\Users\Daniel\OneDrive\Desktop\projects\learn.o
g++.exe -LD:\SFML\lib -o C:\Users\Daniel\OneDrive\Desktop\projects\learn.exe C:\Users\Daniel\OneDrive\Desktop\projects\learn.o   -lsfml-graphics-s -lsfml-audio-s -lsfml-network-s -lsfml-window-s -lsfml-system-s
C:\Users\Daniel\OneDrive\Desktop\projects\learn.o:learn.cpp:(.text+0x16): undefined reference to `sf::TcpSocket::TcpSocket()'
C:\Users\Daniel\OneDrive\Desktop\projects\learn.o:learn.cpp:(.text$_ZN2sf9TcpSocketD1Ev[__ZN2sf9TcpSocketD1Ev]+0x26): undefined reference to `sf::Socket::~Socket()'
collect2.exe: error: ld returned 1 exit status

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: static linking
« Reply #4 on: October 16, 2023, 11:19:51 pm »
Are you using SFML master, i.e. SFML 3 which is still in development?

If so, keep in mind, that we changed the API quite a bit in some places.
For you, I personally recommend to stick to SFML 2.6, which has up-to-date documentation and yields a lot more search results.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything