Reputation: 173
I am trying to make a get request in vala following this: https://wiki.gnome.org/Vala/LibSoupSample. I do exactly what it says and the compiler throws this:
Connection.vala.c:(.text+0x76): undefined reference to `soup_session_new'
collect2: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
And this is the result from pkg-config --libs --cflags libsoup-2.4
-pthread -I/usr/include/libsoup-2.4 -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lsoup-2.4 -lgio-2.0 -lgobject-2.0 -lglib-2.0
I have vala 0.20.1. runing on elementaryos (the newest stable version). Any ideas?
Upvotes: 2
Views: 574
Reputation: 1103
I had the same issue earlier today. It seems like the example is out of date. It's no longer called soup_session_new
, the reference is now soup_session_sync_new
. Use new Soup.SessionSync ()
and it should work.
Here's a working example:
using Soup;
int main (string[] args) {
string url = "http://google.com";
stdout.printf ("Getting data from %s\n", url);
var session = new Soup.SessionSync ();
var message = new Soup.Message ("GET", url);
session.send_message (message);
stdout.write (message.response_body.data);
return 0;
}
Upvotes: 3