Compiling libspotify - linking a FreeBSD binary to a linux library

I am trying to compile the example files for libspotify, but am getting caught with errors.

First: libspotify is a Linux library. I have downloaded and extracted it onto my 9.1-RELEASE box. I have copied the libraries to /compat/linux/usr/local and done the linking which the install script would normally do, and have called /compat/linux/sbin/ldconfig to update, and the libraries show up in the output.

When I attempt to compile the example files, after some additional editing for FreeBSD's sake, I get the following output. gmake LIBSPOTIFY_PATH=/compat/linux/usr/local/ results in:
Code:
for a in spshell ; do gmake -C $a LIBSPOTIFY_PATH="/compat/linux/usr/local" all; done
gmake[1]: Entering directory `$BUILD/libspotify-12.1.51-Linux-i686-release/share/doc/libspotify/examples/spshell'
cc -I/compat/linux/usr/local/include -Wall   -c -o spshell.o spshell.c
cc -I/compat/linux/usr/local/include -Wall   -c -o spshell_posix.o spshell_posix.c
cc -I/compat/linux/usr/local/include -Wall   -c -o appkey.o ../appkey.c
cc -I/compat/linux/usr/local/include -Wall   -c -o cmd.o cmd.c
cc -I/compat/linux/usr/local/include -Wall   -c -o browse.o browse.c
cc -I/compat/linux/usr/local/include -Wall   -c -o search.o search.c
cc -I/compat/linux/usr/local/include -Wall   -c -o toplist.o toplist.c
cc -I/compat/linux/usr/local/include -Wall   -c -o inbox.o inbox.c
cc -I/compat/linux/usr/local/include -Wall   -c -o star.o star.c
cc -I/compat/linux/usr/local/include -Wall   -c -o playlist.o playlist.c
playlist.c: In function 'cmd_playlists':
playlist.c:94: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type 'sp_uint64'
playlist.c:101: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type 'sp_uint64'
cc -I/compat/linux/usr/local/include -Wall   -c -o test.o test.c
cc -I/compat/linux/usr/local/include -Wall -Wl,-rpath,/compat/linux/usr/local/lib -L/compat/linux/usr/local/lib -L/usr/local/lib/ spshell.o spshell_posix.o appkey.o cmd.o browse.o search.o toplist.o inbox.o star.o playlist.o test.o -lreadline -lspotify -o spshell
/usr/bin/ld: skipping incompatible /compat/linux/usr/local/lib/libspotify.so when searching for -lspotify
/usr/bin/ld: cannot find -lspotify
gmake[1]: *** [spshell] Error 1
gmake[1]: Leaving directory `$BUILD/libspotify-12.1.51-Linux-i686-release/share/doc/libspotify/examples/spshell'
gmake: *** [all] Error 2

The error which is persistent is the one regarding incompatibility of libspotify.so when searching for -lspotify. It seems that the file is being found, but not properly used. The only reason that I could think of was that the library is a 32-bit Linux library and my FreeBSD installation is amd64.

Does anyone have any insight to share? Where can I continue looking for the root-source of the error, what can I do to get around it? Has anyone had similar problems? I was unable to find anything useful using Google.

It seems to be similar to http://forums.freebsd.org/showthread.php?t=5032, but I was not able to learn anything useful from there.
 
Do you have a Linux C compiler installed inside the /compat/linux environment? That's the first requirement to compile Linux binaries using the Linuxator. The other way would be hacking together a full Linux cross-compiler for FreeBSD that produces Linux binaries.
 
kpa said:
Do you have a Linux C compiler installed inside the /compat/linux environment? That's the first requirement to compile Linux binaries using the Linuxator. The other way would be hacking together a full Linux cross-compiler for FreeBSD that produces Linux binaries.

I don't however want Linux binaries, but FreeBSD binaries.

There is no native FreeBSD client for Spotify. There is however a library that one can use to write an own client. So I wanted to write a simple client that I could use. But I need to link to the libspotify library.

Compile on FreeBSD: source-code plus libspotify for Linux -> FreeBSD binary.

But thanks for the comment anyway.
 
You can't link together binaries/libraries that are for different platforms, it's just not going to work.
 
Back
Top