Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 772
sazr Avatar asked May 11 '16 02:05

sazr


2 Answers

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.

like image 150
Wyzard Avatar answered Nov 16 '22 11:11

Wyzard


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

like image 3
Christopher Ian Stern Avatar answered Nov 16 '22 10:11

Christopher Ian Stern