0
votes

I am supposed to make an audio analysis programme. I have installed QT Creator successfully and I also managed to include SFML library.

Here is what i added to audioPlayer.pro file:

INCLUDEPATH += D:\qt\SFML-2.2\include\SFML

INCLUDEPATH += D:\qt\SFML-2.2\include

LIBS += D:\qt\SFML-2.2\bin\sfml-audio-d-2.dll

mainwidow.cpp:

void MainWindow::on_pushButton_clicked() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "C://", tr("Audio files (*.wav)"));

std::string file = fileName.toStdString();
sf::SoundBuffer buffer;
buffer.loadFromFile((file));

sf::Sound sound;
sound.setBuffer(buffer);
sound.play();

}

I believe that here its obvious whatts going on.

So, when i build my project i get 8 errors:

mainwindow.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Sound::Sound(void)" (__imp_??0Sound@sf@@QAE@XZ) referenced in function "private: void __thiscall MainWindow::on_pushButton_clicked(void)" (?on_pushButton_clicked@MainWindow@@AAEXXZ)

Those others are just the same, so i didnt paste them.

and here the last one:

debug\audioPlayer.exe:-1: error: LNK1120: 7 unresolved externals

So yeah. I have tried to manually include compilers in tools->options->build & run. I set the MinGw compiler. I have followed several tutorials on this site and others too, but I just cant figure it out.

I checked out these two links:

https://github.com/LaurentGomila/SFML/wiki/Tutorial:-Compile-and-Link-SFML-with-Qt-Creator https://github.com/LaurentGomila/SFML/wiki/Tutorial:-Link-SFML-with-Qt-Creator

But no success.

1
With Qt you don't really need SFML, it will be just overhead since Qt can mirror all its functionality. If you want professional audio support, just build and link RTAudio.dtech
can u give me some guide how to link it maybe? ..TreeZ
For me it has always worked to just use the Creator's "Add Library" wizard and provide the right libraries. 99% of the time the problem is with trying to use libs which are compiled with an incompatible compiler version. It is best to build the lib yourself with the same version Qt uses.dtech
i am not sure that i know how to do this :(TreeZ
I solved the problem by shifting to Linux Ubuntu and i successfully cofigured it using this link from above: github.com/LaurentGomila/SFML/wiki/…TreeZ

1 Answers

0
votes

I solved the problem by shifting to Linux Ubuntu and i successfully cofigured it using this link from above: https://github.com/LaurentGomila/SFML/wiki/Tutorial:-Compile-and-Link-SFML-with-Qt-Creator