Bugster
Bugster

Reputation: 1594

C++ SFML qt creator unresolved externals

I've been trying to set up qt creator with SFML for the past 2 weeks to no avail... Here's my .pro file:

TEMPLATE = app
CONFIG += console
CONFIG -= qt

SOURCES += main.cpp

INCLUDEPATH += C:\SFML\include
LIBS += C:\SFML\lib\libsfml-system.a \
    C:\SFML\lib\libsfml-window.a \
    C:\SFML\lib\libsfml-graphics.a \
    C:\SFML\lib\libsfml-audio.a \
    C:\SFML\lib\libsfml-network.a

And my code:

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

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

But I'm getting these errors:

main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl sf::Sleep(float)" (?Sleep@sf@@YAXM@Z) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "public: float __thiscall sf::Clock::GetElapsedTime(void)const " (?GetElapsedTime@Clock@sf@@QBEMXZ) referenced in function _main
debug\SfmlLearning.exe:-1: error: LNK1120: 3 unresolved externals
debug\SfmlLearning.exe:-1: error: LNK1120: 3 unresolved externals

Any idea what may be causing them?

Upvotes: 0

Views: 348

Answers (1)

alexisdm
alexisdm

Reputation: 29886

The .a files are for the gcc compiler only. As you are compiling with VC++, you should be using the .lib.

If you didn't build SFML yourself, these files are in a separate archive on the SFML website.

Upvotes: 1

Related Questions