1

I'm doing a project in C++ for school in which I decided to use LastFM's library (github repo). I followed the instructions and installed it and all the dependencies but when I put LIBS += -llastfm in the .pro file in Qt as stated in the 'Using liblastfm' section from the repo, I get the error "File liblastfm.so.1 could not be found".

I went to the library's folder in '/usr/include' (as far as I remember) and found three files:

  1. liblastfm.so
  2. liblastfm.so.1
  3. liblastfm.so.1.0.8

These files were organized as following: liblastfm.so was a link to liblastfm.so.1 and liblastfm.so.1 was a link to liblastfm.so.1.0.8 which was, in fact, the library file. I'm assuming they did this for easy maintenance when it comes to updates but as far as I could tell QtCreator doesn't know how the follow the link since it's finding the liblastfm.so but can't reach liblastfm.so.1.

I tried to delete the .so and .so.1 files and then rename the .so.1.0.8 file into just liblastfm.so but it still said that it can't find the .so.1 file, which was kinda' confusing.

I also tried addid the library manually by right clicking the project and select "Add library" but when I reached the liblastfm's folder, only the liblastfm.so file was recognized as a library file and if I added it, the same error occured.

So, any help would be appreciated!

László Papp
  • 51,870
  • 39
  • 111
  • 135
Bogdan Raducan
  • 177
  • 2
  • 11

1 Answers1

0

Based on the comment about the installed location, it seems you would need to add this in your qmake project file:

LIBS += -L/usr/local/lib/i386-linux-gnu/ -llastfm

The reason is that, you seem to have installed lastfm into a "custom" location which is not in the library path by default. Hence, you need to tell qmake where to look for the lastfm libraries.

László Papp
  • 51,870
  • 39
  • 111
  • 135
  • I added and still the same error: `/home/bogdan/build-lastfm_api_test_v4-Desktop_Qt_5_2_0_GCC_32bit-Debug/lastfm_api_test_v4: error while loading shared libraries: liblastfm.so.1: cannot open shared object file: No such file or directory Press to close this window...` – Bogdan Raducan Jan 09 '14 at 20:37
  • @BogdanRaducan: what is lastfm_a‌​pi_test_v4? Can you provide a self-contained example to reproduce the issue? – László Papp Jan 09 '14 at 20:43
  • *lastfm_api_test_v4* is the name of my project. That's the standard error printing in the console: *project_name: error*. It's simply a new Qt Console Application project in which I ONLY try to include the library. I don't understand what you mean by 'self-contained example'. – Bogdan Raducan Jan 09 '14 at 20:50
  • Ok, I understand. The self-contained example is very simple. On a machine with *Linux Mint 16* I make a new **Qt Console Application** named *lastfm_api_test_v4* and in the **.pro** file I have [.pro file content](http://pastebin.com/fzGVkvL4). – Bogdan Raducan Jan 09 '14 at 20:55
  • I cannot reproduce your issue... In any case, install lastfm from your package manager, not with a custom build... – László Papp Jan 09 '14 at 21:14
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/44915/discussion-between-bogdan-raducan-and-laszlo-papp) – Bogdan Raducan Jan 09 '14 at 21:26
  • I don't really understand how to install the lastfm library from my package manager. I simply downloaded the archive from the github repo and installed it with cmake. Is there another way? – Bogdan Raducan Jan 09 '14 at 21:41
  • @BogdanRaducan: which distribution are you using? – László Papp Jan 10 '14 at 00:04
  • Also, why would you include the dependencies of your dependencies in _your_ application? – László Papp Jan 10 '14 at 03:30
  • Because that's what it said in the GitHub repo. _Your link line needs to include the following: -llastfm -lQtCore -lQtNetwork -lQtXml_. I need to do this because the library uses, for example, QtNetwork and it can't do it unless I include the library in my project. I am using Linux Mint 16 on 32 bits. – Bogdan Raducan Jan 10 '14 at 12:48
  • @BogdanRaducan: have you resolved that nitty-gritty details I cannot ee? – László Papp Jan 22 '14 at 09:44
  • no, I eventually let it down; besides the library including problem, I discovered that the library was specially made for Qt 4 and was including some Qt libraries that were not working anymore in Qt 5. Thanks anyway for the help until now. – Bogdan Raducan Feb 14 '14 at 07:29