0

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.

James Read
  • 419
  • 2
  • 7
  • 13
  • Are you linking with the library? – Shawn Aug 02 '19 at 08:05
  • 2
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Shawn Aug 02 '19 at 08:07

0 Answers0