I am trying to build a web crawler and need to parse URIs.
I have tried to compile some simple uriparser code which I copied and pasted from https://uriparser.github.io/doc/api/latest/
#include <uriparser/Uri.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
UriUriA uri;
const char * const uriString = "file:///home/user/song.mp3";
const char * errorPos;
if (uriParseSingleUriA(&uri, uriString, &errorPos) != URI_SUCCESS) {
/* Failure (no need to call uriFreeUriMembersA) */
return 1;
}
/* Success */
uriFreeUriMembersA(&uri);
}
The code doesn't compile and gives the following errors:
/tmp/ccWkKj10.o: In function `main':
uri.c:(.text+0x51): undefined reference to `uriParseSingleUriA'
uri.c:(.text+0x6b): undefined reference to `uriFreeUriMembersA'
collect2: error: ld returned 1 exit status
I have the latest version of liburiparser-dev
installed (0.9.3-2).
Any idea what I am doing wrong?
EDIT
Adding flag -luriparser
solved the problem.