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

Author Topic: Compiling with g++ (undefined reference to `_imp___ZN2sf5ClockC1Ev')  (Read 2031 times)

0 Members and 1 Guest are viewing this topic.

jagudo

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
I'm really sorry to post this as I suppose you've already heard about a 1000 times but I really do not find a solution in the forum,

I'm using:
D:\Projects\cppcon\code>g++ --version
g++ (rev5, Built by MinGW-W64 project) 4.8.1

and I specify in g++ all paths and libraries.

g++ -I. -ID:/ExternalLibs/SFML-2.1-windows-gcc-4.7-mingw-32bits/SFML-2.1/include -LD:/ExternalLibs/SFML-2.1-windows-gcc-4.7-mingw-32bits/SFML-2.1/lib -lsfml-graphics-d -lsfml-window-d -lsfml-system-d ./main.cpp -o ./main.exe
C:\Users\jagudo\AppData\Local\Temp\cc3rZFLw.o:main.cpp:(.text+0x1e): undefined reference to `_imp___ZN2sf5ClockC1Ev'


The code is the one in the examples:

#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.getElapsedTime() < sf::seconds(5.f))
    {
        std::cout << Clock.getElapsedTime().asSeconds() << std::endl;
        sf::sleep(sf::seconds(0.5f));
    }

    return 0;
}


Once again, sorry if it has been asked a thousand times.


Regards,

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: Compiling with g++ (undefined reference to `_imp___ZN2sf5ClockC1Ev')
« Reply #1 on: October 10, 2014, 04:02:59 pm »
The main.cpp needs to stand before the -lsfml-xyz
Also if you link against the debug libs you need to build a debug binary, add -g
« Last Edit: October 10, 2014, 04:27:12 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jagudo

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Compiling with g++ (undefined reference to `_imp___ZN2sf5ClockC1Ev')
« Reply #2 on: October 12, 2014, 12:40:52 pm »
Thanks a lot! It fixed the problems.

Regards,
Jagudo