How to change #include statements with relative paths in c++ files so they work when compiling?
1
0
Entering edit mode
9.2 years ago

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

gatb-core cpp • 6.2k views
ADD COMMENT
2
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode

Use backslash to escape meta-characters.

sed 's/#include <gatb\/bank\/impl\/BankFasta.hpp>/whatever/'
ADD REPLY
2
Entering edit mode
9.2 years ago

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 COMMENT

Login before adding your answer.

Traffic: 2659 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6