Compiler says uuid.h not found but apt-get says it is

12,900

Solution 1

I bielive in newer version of the uuid the header is <uuid/uuid.h>

Solution 2

The package's file list shows that it contains /usr/include/uuid/uuid.h. Since your default include path looks for files relative to /usr/include, you'd need to either write <uuid/uuid.h>, or add -I/usr/include/uuid to your compile options.

However, the package also provides a .pc file for use with pkg-config, which is meant to abstract the details of which compiler options you need to build a program against a library. If you run pkg-config --cflags uuid you get get the output -I/usr/include/uuid, and if you run pkg-config --libs uuid, you get the output -luuid. These are meant to be incorporated into your program's build.

Since it looks like you're using Make, you should add these lines to your Makefile:

CFLAGS += `pkg-config --cflags uuid`
LDFLAGS += `pkg-config --libs uuid`

That'll incoroporate the necessary -I and -l options into your compile commands automatically — and it'll also work on other systems where the UUID library might be installed in a different location.

Share:
12,900

Related videos on Youtube

sazr
Author by

sazr

Updated on June 04, 2022

Comments

  • sazr
    sazr almost 2 years

    When compiling my C++ project that includes uuid.h I get the compile error:

    fatal error: uuid.h: No such file or directory

    I'm not sure whats going wrong. It could be my compiler instructions are wrong or that I indeed dont have that file installed (but I don't think thats the problem).

    sudo apt-get install uuid-dev

    The above command outputs: uuid-dev is already the newest version

    My makefile is simply this:

    all:
        g++ -o bin/myapplication src/main.cpp -std=c++11
    

    Edit: In .h file:

    #include <uuid.h>
    

    Any ideas what the issue could be?

    • Deryck
      Deryck almost 8 years
      are you including it like <uuid.h> or "uuid.h"
    • sazr
      sazr almost 8 years
      @Deryck I am doing #include <uuid.h>