Tesomas
Tesomas

Reputation: 35

Makefile Compiling Issues

This is my makefile

   FC=gfortran
CC=gcc 
CPC=g++ 
FFLAGS = -O3 
LINK=g++
BLASF=dgemmf.o dgemmkernel2.o mult.o
BLASFSRC=dgemmf.f
TIMER=mytimer.o

TGEMM=tgemm
ALL= $(TGEMM)

LIBS = -lblas 

all: $(ALL)
mult.o: 
    $(CPC) -O3 -fopenmp -c mult.cpp

$(TGEMM): tgemm.o mult.o $(TIMER) $(BLASF)
    $(FC) $(FFLAGS) -o $(TGEMM) tgemm.o $(TIMER) $(BLASF) $(LIBS)

dgemmkernel2.o: dgemmkernel2.cpp 
    $(CPC) -O3 -c -fopenmp dgemmkernel2.cpp 
tgemm.o: tgemm.f $(INCLUDE)
    $(FC) $(FFLAGS) -c tgemm.f

clean:
    rm -rf *.o $(ALL)

This is what I get for errors:

     make -f makefile_gcc2
gfortran -O3  -c tgemm.f
g++  -O3 -fopenmp -c mult.cpp
gcc     -c -o mytimer.o mytimer.c
gfortran -O3   -c -o dgemmf.o dgemmf.f
g++  -O3 -c -fopenmp dgemmkernel2.cpp 
gfortran -O3  -o tgemm tgemm.o mytimer.o dgemmf.o dgemmkernel2.o mult.o -lblas 
dgemmkernel2.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
mult.o: In function `global constructors keyed to main':
mult.cpp:(.text+0x1a): undefined reference to `std::ios_base::Init::Init()'
mult.cpp:(.text+0x29): undefined reference to `std::ios_base::Init::~Init()'
mult.o: In function `_Z4multPdS_iS_iii.omp_fn.0':
mult.cpp:(.text+0x4f): undefined reference to `omp_get_num_threads'
mult.cpp:(.text+0x57): undefined reference to `omp_get_thread_num'
mult.o: In function `mult(double*, double*, int, double*, int, int, int)':
mult.cpp:(.text+0x175): undefined reference to `omp_get_num_threads'
mult.cpp:(.text+0x1b9): undefined reference to `GOMP_parallel_start'
mult.cpp:(.text+0x1c6): undefined reference to `GOMP_parallel_end'
mult.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [tgemm] Error 1

I understand from my research that these are likely linker issues, but I cannot for the life of me figure out what the problem is. Is there anyone out there who might have some insight into what the issue is?

Upvotes: 0

Views: 6936

Answers (2)

Sherif
Sherif

Reputation: 1279

I've got a similar problem and I solved it by linking with the 'libgomp.dll.a' file -- I use MinGW 4.4. Or you just have to add to the libirary to link with " -lgomp " e.g. LIBS += -lgomp

Upvotes: 1

tpg2114
tpg2114

Reputation: 15100

If you use C++ sources, you should link with the g++ program instead of gfortran. The opposite is true with Intel compilers.

So change:

$(TGEMM): tgemm.o mult.o $(TIMER) $(BLASF)
    $(FC) $(FFLAGS) -o $(TGEMM) tgemm.o $(TIMER) $(BLASF) $(LIBS)

to

$(TGEMM): tgemm.o mult.o $(TIMER) $(BLASF)
    $(LINK) $(FFLAGS) -o $(TGEMM) tgemm.o $(TIMER) $(BLASF) $(LIBS)

Upvotes: 3

Related Questions