I'm new in Ubuntu and trying to compile a C++ code on it. The code uses 2 dependencies (Cairographics and FFTW3). I have installed both of them using ./configure
, make
and make install
in directory $HOME/prefix/
(following the instruction given here How to install Cairo 1.8.10 )
Now I have in this directory 4 folders, namely bin
, include
, lib
and share
The make file of the code requires specifying the dependencies' directory. Like that
INC := -I$HOME/prefic/include
LIB := -L$HOME/prefic/lib
When I compile the code, I set the environment variables as
export PKG_CONFIG_PATH=$HOME/prefic/lib/pkgconfig
export LD_LIBRARY_PATH=$HOME/prefic/lib
and then use make. Linker gives "undefined reference to" functions from inside Cairo or FFTW
the make file I use
###################### user-configuration section #######################
INC := -I/opt/local/include
LIB := -L/opt/local/lib
# 32 bit
#MARCH := -m32
# 64 bit
MARCH := -m64
#########################################################################
CXX := g++
CXXFLAGS := -Wall -fopenmp
OPTFLAGS := -O3 $(MARCH)
LIB += -lfftw3 -lm -lcairo
CXXFILES := main.cpp fileio.cpp measurements.cpp spectralanalysis.cpp
OBJS := $(patsubst %.cpp, %.o, $(CXXFILES))
TARGET := psa
.PHONY: all clean cleanall rebuild
all: $(TARGET)
$(TARGET): $(OBJS)
@$(CXX) $(CXXFLAGS) $(OPTFLAGS) -o $(TARGET) $(LIB) $(OBJS)
%.o : %.cpp
@$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -o $@ -c $<
clean:
rm -rf *.o
cleanall: clean
rm -rf $(TARGET)
rebuild:
$(MAKE) cleanall
$(MAKE) all
I think I don't link the code with the dependencies correctly. Could someone help please.
The psa code I'm trying to compile is here http://code.google.com/p/psa/downloads/list