I have been having trouble linking sfml to qt creator I have downloaded the pre-compiled libraries and headers for MINGW on the sfml website here : http://www.sfml-dev.org/download/sfml/2.3.2/
This is my .pro file
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = SFML_MapEditor
TEMPLATE = app
SOURCES += main.cpp\
MainWindow.cpp
HEADERS += MainWindow.h
FORMS += MainWindow.ui
INCLUDEPATH += "C:\VsIncludes\SFML\SFML-2.3.2\include"
DEPENDPATH += "C:\VsIncludes\SFML\SFML-2.3.2\include"
LIBS += -LC:\VsIncludes\SFML\SFML_QT\SFMLLIBS\
CONFIG(debug, release|debug): LIBS += -lsfml-window-d -lsfml-audio-d -lsfml-graphics-d -lsfml-main-d -lsfml-system-d -lsfml-network-d
CONFIG(release, release|debug): LIBS += -lsfml-window -lsfml-audio -lsfml-graphics -lsfml-main -lsfml-system -lsfml-network
Here is the project files where the binaries are read
Now my problem lies in the loadFromFile() function. When I do run the program with the loadFromFile() function it will immediately give me this error:
C:\Users\Alex\Documents\QT_Projects\SFML_MapEditor\main.cpp:14: error: undefined reference to `_imp___ZN2sf7Texture12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_4RectIiEE'
However when I run the program without loadFromFile() it will run without a hitch
My main.cpp file
#include "MainWindow.h"
#include <iostream>
#include <QApplication>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <QDebug>
void SFML_Test()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "HELLO SFML");
sf::Texture tex;
if (!tex.loadFromFile("Default_Texture.png"))
{
return;
}
sf::Sprite sprite(tex);
while (window.isOpen())
{
sf::Event e;
while (window.pollEvent(e))
{
if (e.type == sf::Event::Closed)
{
window.close();
}
}
window.clear();
window.draw(sprite);
window.display();
}
}
int main(int argc, char *argv[])
{
/*
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
*/
SFML_Test();
return 0;
}
