Re: [Vala] Using a C library



Thanks so much for the replies! I'm starting to make some slow progress,
but holy cow is that confusing coming from a friendlier language (at least
when it comes to library loading). Here's the stream of errors that I went
through:

1) Added the c-header bit to the namespace. Getting an "undefined reference
to `sp_error_message`".

2) Move the vala method for sp_error_message out of the enum, out of the
namespace, all over the place, did the hokey pokey, and turned myself
around.

3) Is the macro on the return types in libspotify/api.h messing with the
function names?!

4) Okay, let's go back to C and just print an error message from an
sp_error enum: "undefined reference to `sp_error_message`." Well, um, at
least the error is consistent.

5) Wait, I have to include the header *and* link the library in the
compiler? *rolls eyes* of course, that's so obvious... `gcc -llibspotify
test.c`: cannot find -llibspotify.

6) Mucks with ld. Mucks with gcc search-dirs. Still can't find library.

7) Wait, "lib" in "libspotify" is implied? *rolls eyes* of course, that's
so obvious... `gcc -lspotify test.c` -- compiles, and I can use
sp_error_message(). About freaking time.

8) `valac -lspotify spotify.vala`: unknown option -lspotify. Checks
manpage... `valac --library=spotify spotify.vala`: undefined reference to
`sp_error_message'. This couldn't be any less intuitive... Searches
internet. Duh, it's so obviously -Xcc=-lspotify. Stupid fandingo, how did
you not know better?

So, yeah, about one line in Vala to add the c-header, and like 3 hours
on-and-off of fighting with the compiler/linker. But hey, at least I feel
like I sort of know what I'm doing at this point.


@Jens, yes I did come across that version, but there were a few reasons I
didn't use it. It is quite out of date wrt libspotify, and doesn't compile.
I'm also more interested in my library being lgpl instead of gplv3.

Thanks again for the assistance.

-- Justin

On Mon, Apr 20, 2015 at 6:02 AM, Jens Georg <mail jensge org> wrote:

Hi,


I'm trying to wrap the proprietary libspotify C library. I've found this


Someone already did that:


https://gitorious.org/spotifyd/spotifyd/source/a3487ee9c56b816c120ad41855c02ad3471d1021:libspotify.vapi

I don't know how up-to-date this is, though.


_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]