Question: How to change #include statements with relative paths in c++ files so they work when compiling?
0
gravatar for Pawel Osipowski
4.1 years ago by
Poland, Warsaw
Pawel Osipowski20 wrote:

Hi,

 I have no suitable background to deal with such cases on my own. I've got this soft LoRDEC, which needs gatb-core to work. When compiling it all #include statements from gatb files in c++ generate error because of relative path in them: etc. 

fatal error: hdf5/hdf5.h: No such file or directory

I could change those paths manually but it seems tedious. Is there any clever way to deal with it?

Thanks,

c++ gatb-core • 2.5k views
ADD COMMENTlink modified 4.1 years ago by Jean-Karim Heriche18k • written 4.1 years ago by Pawel Osipowski20
2

This is pretty off-topic, but you generally just want to add an appropriate -I option to the Makefile (or whatever else it's using).

ADD REPLYlink written 4.1 years ago by Devon Ryan88k

For gatb-core I downloaded binaries. I've got some options in Makefile of LoRDEC.:

GATB = /home/pawel/biosoft/assembly/gatb-core-1.0.6-Linux
PPFLAGS = -I$(GATB)/include/ -std=c++0x -O3 -g #-DOLD_GATB
LDFLAGS = -L$(GATB)/lib/ -lgatbcore -lhdf5 -ldl -lz -lpthread -std=c++0x
CXX     = g++
RM      = rm -f 

Do you mean something else?

ADD REPLYlink written 4.1 years ago by Pawel Osipowski20

If hdf5.h is under $(GATB)/include/hdf5/ then that should work. If you post the gcc or cc line that produces that error then we'll be able to determine better what's wrong.

ADD REPLYlink written 4.1 years ago by Devon Ryan88k

Typically "-I/path/to/include/dir" goes to CPPFLAGS (cpp=c-preprocessor, not c-plus-plus) and "-std=c++0x -O3 -g" to CXXFLAGS. Nonetheless, the naming is defined in Makefile. A lot of makefiles do not follow this convention. Another makefile-independent approach is to specify "export CPLUS_INCLUDE_PATH=/path/to/include/dir:$CPLUS_INCLUDE_PATH".

ADD REPLYlink modified 4.1 years ago • written 4.1 years ago by lh331k

UNIX is your friend. sed will make it easy for you. Once you determine how to exactly identify these lines, what needs to be replaced and what should take its place, a combination of find and sed can do this in a few milliseconds for you :)

ADD REPLYlink written 4.1 years ago by RamRS20k

This seems quite difficult (for me) as there are functional characters like "/" in paths and this <<sed 's/old/new/g'>> won't work. Could you give me example how to do this: eg. change '#include <gatb/bank/impl/BankFasta.hpp>' on '#include </home/../gatb/bank/impl/BankFasta.hpp>' with sed command?

ADD REPLYlink written 4.1 years ago by Pawel Osipowski20
1

Use backslash to escape meta-characters.

sed 's/#include <gatb\/bank\/impl\/BankFasta.hpp>/whatever/'
ADD REPLYlink written 4.1 years ago by RamRS20k
2
gravatar for Jean-Karim Heriche
4.1 years ago by
EMBL Heidelberg, Germany
Jean-Karim Heriche18k wrote:

First check that you've installed the hdf5 library. Then if the software has a configure script, check if you can specify the path to the hdf5 library as part of the configuration. Otherwise you could try setting LDFLAGS on the command line before compiling e.g. (for Bash)

export LDFLAGS="-L/path/to/hdf5/lib"
./configure
make
make install
ADD COMMENTlink written 4.1 years ago by Jean-Karim Heriche18k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2514 users visited in the last hour