fgvieira / ngsDist

Estimation of pairwise distances under a probabilistic framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bad CFLAGS for custom pkg-config gsl installation. compilation fails.

init-js opened this issue · comments

I've installed gsl via conda (package management), which places pkg-config .pc files and included libraries inside a subfolder of my home directory.

(ngsdist) [jslegare@host ngsDist]$ pkg-config --cflags gsl
-I/home/jslegare/miniconda2/envs/ngsdist/include
(ngsdist) [jslegare@host ngsDist]$ pkg-config --libs gsl
-L/home/jslegare/miniconda2/envs/ngsdist/lib -lgsl -lgslcblas -lm

Your Makefile LIB variable conflates CFLAGS and LDFLAGS for gen_func.cpp, which results in a compilation error:

/home/jslegare/miniconda2/envs/ngsdist/bin/x86_64-conda_cos6-linux-gnu-c++ -I./shared -O3 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -c ./shared/gen_func.cpp
In file included from ./shared/gen_func.cpp:1:0:
./shared/gen_func.hpp:12:10: fatal error: gsl/gsl_rng.h: No such file or directory
 #include <gsl/gsl_rng.h>
          ^~~~~~~~~~~~~~~

The following patch fixes the error.

diff --git a/Makefile b/Makefile
index 216bc2c..2d894c7 100644  
--- a/Makefile
+++ b/Makefile  
@@ -4,10 +4,10 @@ CXX?=g++
 SHARED_DIR = ./shared  
 SHARED_LIB = gen_func.cpp read_data.cpp threadpool.c
 
-CFLAGS = -I$(SHARED_DIR)
+CFLAGS = -I$(SHARED_DIR) $(shell pkg-config --cflags gsl)
 #DFLAGS = -g -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
 DFLAGS = -O3 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
-LIB = $(shell pkg-config --cflags --libs gsl) -lz -lpthread
+LIB = $(shell pkg-config --libs gsl) -lz -lpthread

This is with gsl 2.4 (1.15 wasn't available on the conda channel).

I can write a PR when I get around to it.

Thanks for the suggestion.
If you do a PR I'll gladly add it to the repo. If not, just let me know and I'll add those changes.

cheers,

Issue has been fixed.