Search code examples
cgcccompilationgliblibtool

C Program Compilation issue involving Glib2 library?


I'm trying to compile the following project on a remote server.

I've git cloned the project on a folder called 'scode'.

The project requires glib2 and gsl libraries. Since I'm trying to compile on a remote server, I do not have sudo privileges. So I can't use a tool to install glib2 and gsl for me.

As a result, I've manually compiled both gsl and gslib2 under the folders 'scode/gsl' and 'scode/glib'.

I've had to modify the Makefile and add absolute paths to these directories as -I options.

Nonetheless, when I try to compile the final executable. I get the following error:

[dyuret@psglogin scode]$ make

gcc -O3 -D_GNU_SOURCE -Wall -std=c99 -I. -I /home-2/dyuret/scode/gsl -I /home-2/dyuret/scode/glib/ pkg-config --cflags glib-2.0 scode.o svec.o pkg-config --libs glib-2.0 -lm -lgsl -lgslcblas -o scode

//home-2/dyuret/scode/glib/glib/libglib-2.0.la: file not recognized: File format not recognized

collect2: error: ld returned 1 exit status make: * [scode] Error 1

I've researched the issue a bit. This link looks informative but I can't quite decipher what the author is saying, as I'm not that experienced with compilers, libtools and the compilation flow in general.

Any help would be much appreciated. I've already spent some time on this issue and I haven't been able to make much progress.


Solution

  • Someone at my group helped me with the problem. Here're the steps he roughly carried out:

    (1) Manually installed glib and additional libraries at $HOME directory - i.e. $HOME/lib, $HOME/include.

    (1.1) I think he did this by './configure prefix=$HOME', 'make', 'make install'.

    (2) Got rid of `pkg_config` usage, which was causing the problem I outlined originally. Here are his new CLFAGS and LIBS variables:

    CFLAGS=-O3 -D_GNU_SOURCE -Wall -std=c99 -I. -I$$HOME/include -I$$HOME/include/glib-2.0 -I$$HOME/lib/glib-2.0/include
    LIBS=-lglib-2.0 -lm -lgsl -lgslcblas -L$$HOME/lib -L/usr/local/cuda/lib64 -lcudart
    

    After this, the code compiled without additional problems.