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?
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.
I bielive in newer version of the uuid the header is <uuid/uuid.h>
Related
I am trying to build glib-networking-2.40.1. I am having trouble with the make step.
Configure step
~/gstreamer/plugins/recommended/good/glib-networking-2.40.1 $ sudo ./configure --disable-glibtest --host=arm-linux-gnueabi --prefix=$DISCIMAGE/usr/local/ --includedir=$DISCIMAGE/usr/include/glib-2.0 --libdir=$DISCIMAGE/usr/lib/arm-linux-gnueabi --libdir=$DISCIMAGE/usr/lib --exec-prefix=$DISCIMAGE/usr/local/ --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/include --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/glib --with-ca-certificates=/etc/ssl/ca-bundle.crt --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/good/gnutls-3.3.7/ --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/ --with-gnutls=/home/ubuntu/gstreamer/plugins/recommended/good/gnutls-3.3.7/ --libdir=/usr/lib/arm-linux-gnueabihf/ --libdir=/usr/lib --libdir=/usr/lib/arm-linux-gnueabi --libdir=/usr/lib/arm-linux-gnueabihf/ --libdir=/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/.libs/
then I try
sudo make
and I get the error
CC gnutls-module.lo
gnutls-module.c:22:21: fatal error: gio/gio.h: No such file or directory
gio.h is located at
/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/
which is included in my configure step
also I have libgio-2.0.so located at
/usr/lib/libgio-2.0.so
and
/usr/lib/arm-linux-gnueabihf/gio/libgio-2.0.so.0
and
/usr/lib/libgio-2.0.so.0
all of which are included in configure
pkg-config gives
sudo pkg-config --libs --cflags gio-2.0
-pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgio-2.0 -lgobject-2.0 -lglib-2.0
Any help would be greatly appreciated
The --includedir and --libdir arguments to configure are supposed to tell your package where to install its own headers and libraries, not where to find other headers and libraries. You should not normally need to use those arguments.
Making that mistake when you compiled GLib is presumably why your gio.h is located at /home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/ instead of at /usr/include or /usr/local/include.
Instead, the output of pkg-config should tell your program where to find headers and libraries. If you've installed your package properly, then pkg-config's output should be correct. The idea is that instead of you researching where all the libraries live and passing those paths to configure, each library installs a pkg-config file that has that information, so if you know where the pkg-config files are, then you don't need to know anything else.
So probably you should uninstall, recompile, and reinstall all the packages you've been compiling, reconfiguring them without the --include and --libdir arguments.
may be this is a stupid question but I don't find a solution for my own. For a very simple application I use a few functions gdk_window_reparent() and gtk_widget_get_window().
But: against what library do I need to link in order to resolve these dependencies?
-lgtk
does not do the trick, the name must be something different...
Thanks!
You use a program called pkg-config to generate the compiler and linker flags you need to build GTK+ software.
pkg-config --cflags gtk+-3.0 # compiler flags only
pkg-config --libs gtk+-3.0 # linker flags only
pkg-config --cflags --libs gtk+-3.0 # both
If you are building from a shell or a makefile, you can use backticks to capture the output from these programs and add them to the current command line. If you are using a build system, see how it integrates with pkg-config.
I am trying to cross compile libpng for RaspberryPi on Ubuntu 14.04 (x_64) with zlib
but configure fails with
configure:11400: arm-linux-gnueabihf-gcc -o conftest -g -O2 -I/home/user/RPI_DEV/lib/include conftest.c -lz -lm >&5
/home/user/RPI_DEV/xtools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
configure:11400: $? = 1
configure: failed program was:
....
Because I am using toolchain for arm, arm-ld cant find zlib.
Is there any option for configure not to compile with shared lib but to try with static lib (eg. -static -lz).
Command is
./configure --enable-static=true --enable-shared=false --with-zlib-include="/home/user/RPI_DEV/lib/include" --with-zlib-lib="/home/user/RPI_DEV/lib/lib" LDFLGS="-L/home/user/RPI_DEV/lib/lib" CPPFLAGS="-I/home/user/RPI_DEV/lib/include" -enable-static --host=arm-linux-gnueabihf --prefix=/home/user/RPI_DEV/lib --exec-prefix=/home/user/RPI_DEV/lib
You need to cross build and install zlib into your toolchain before trying to use it in another project.
What you are doing might work but only if you spell LDFLAGS correctly:
LDFLGS="-L/home/user/RPI_DEV/lib/lib"
Note the missing 'A'. I don't know why your second attempt worked, given you had the same misspelling; possibly you had a correct LDFLAGS in your environment?
Anyway there should be a Ubuntu cross-development guide somewhere that explains how to do this. It's slightly off topic but for Gentoo you use 'crossdev' to install the toolchain then a crossdev specific version of the normal package installation mechanism ([host]-emerge) to install zlib into the toolchain.
Also, the arguments --with-zlib-include and --with-zlib-lib are not supported by any current version of libpng I can find. If you are cross-compiling libpng for an RPi (or, indeed, any ARM system) you should be using the latest version of 1.6 that you can find.
Unless someone solves this the RIGHT way, this is hack I've done.
Open configure.ac file
Find and comment out line
AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed]))
Configure will pass wihout check for zlib and then add zlib by hand
LDFLGS="-L/home/user/RPI_DEV/lib/lib -L/home/user/RPI_DEV/lib/lib/libz.a"
Run autoconf
Run ./configure ...
I would like to install the nccmp program to compare netCDF files.
Checking the documentation, the installation follows the typical structure:
./configure
make
make check
make install
make clean
However, I'm stuck in the first step because the configure is not able to find my netCDF libraries. But I don't know why.
My libs are not in the default folder, I've installed them in /opt. But I've included the path of the netCDF libs in my LD_LIBRARY_PATH variable.
I tried also to create a link in the default lib folder to my netCDF libs
ln /opt/netcdf-4.2.1.1/lib/libnetcdf.so /usr/lib/libnetcdf.so
ln /opt/netcdf-4.2.1.1/lib/libnetcdff.so /usr/lib/libnetcdff.so
ln /opt/netcdf-4.2.1.1/lib/libnetcdf.a /usr/lib/libnetcdf.a
ln /opt/netcdf-4.2.1.1/lib/libnetcdff.a /usr/lib/libnetcdff.a
But it doesn't work either. I explicitly used the path in the call
./configure --libdir=/opt/netCDF/
I set LIBS and LDFLAGS to
LDFLAGS=-L/opt/netcdf-4.2.1.1/lib/
LIBS=/opt/netcdf-4.2.1.1/lib/
and execute configure then, but with the same bad results:
checking for nc_open in -lnetcdf... no
configure: error: in `/opt/nccmp':
configure: error: Required NetCDF library not found!
In the config.log I see:
configure:3763: gcc -o conftest -g -O2 conftest.c -lnetcdf -lm >&5
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libnetcdf.a(libnetcdf4_la-nc4file.o): In function nc4_rec_read_types':
/opt/NETCDF_BUILD/netcdf-4.2.1.1/libsrc4/nc4file.c:1850: undefined reference toH5Gget_create_plist'
and many more similar lines like that one...
I don't know what else to try, so any help would be really appreciated.
Thanks.
I already found the problem... I needed, as expected, to define LDFLAGS and CFLAGS in my shell and export them to allow the access of configure to those variables.
I have an autotools project that compiles just fine on the Mac, but under Linux (Ubuntu 12.04.1 LTS) the command lines passed to gcc have the libraries out of order relative to the object files. For example, autotools generates the following command to compile my code, a single file named test.c into a binary named test:
gcc -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -O2 -lglib-2.0 -o test test-test.o
This command line fails with:
/home/user/glib-test/test.c:4: undefined reference to `g_malloc`
/home/user/glib-test/test.c:5: undefined reference to `g_free`
However, if I compile from the command line and switch it up so the library reference is after the object files it works just fine:
gcc -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -O2 -o test test-test.o -lglib-2.0
The challenge is that I can't figure out how to force Autotools to generate the command line in the right order. For the sake of clarity, I've reproduced the simple test case here. First up is configure.ac:
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(glib-test, 1.0)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE()
AC_PROG_CC
AM_PROG_CC_C_O
PKG_CHECK_MODULES(GLIB, glib-2.0 > 2.0)
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
Next is the simple Makefile.am:
CFLAGS=-Wall
bin_PROGRAMS=test
test_CFLAGS=$(GLIB_CFLAGS)
test_LDFLAGS=$(GLIB_LIBS)
test_SOURCES=test.c
Finally, the source code to this minimal test case, test.c:
#include <glib.h>
int main(int argc, char **argv) {
gchar *foo = g_malloc(100);
g_free(foo);
return 0;
}
Compilation is then achieved using the following series of commands:
touch NEWS README AUTHORS ChangeLog
aclocal
autoconf
automake --add-missing
./configure
make
I should be clear, I understand why my code won't compile, I'm just wondering how to get automake to put the libraries at the end of the command line so gcc will execute and link properly. It should be noted that gcc on Mac OS X Lion doesn't seem to have this problem.
The solution turned out to be the difference between LDFLAGS and LDADD. In short LDFLAGS is added before the object files on the command line and LDADD is added afterwards. Thus, changing Makefile.am to the following solved the problem:
CFLAGS=-Wall
bin_PROGRAMS=test
test_CFLAGS=$(GLIB_CFLAGS)
test_LDADD=$(GLIB_LIBS)
test_SOURCES=test.c
It only took tracking down a GCC developer at work to solve. Also, this example I provided is rather poor because test has a defined meaning in some contexts of autotools.
I solved a similar problem. The ./configure script in question was unable to complete a check for presence of a function due to a missing symbol. If I added the correct library to $LDFLAGS or such like, it was added before the .c file and the library was ignored.
The names of functions to check are first added to ac_func_list and then there is a loop in the body of the ./configure that for each of them calls ac_fn_c_check_func () and that in turns calls ac_fn_c_try_link ()
the checking function ac_fn_c_try_link () uses a command of this pattern:
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS \
$LDFLAGS conftest.$ac_ext $LIBS >&5'
$LDADD is completely ignored here. Therefore the only solution here is to add the -l flags to variable $LIBS.