2011-12-16 99 views
0

這是我的makefileMakefile文件編譯的問題

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) 

這是我得到的錯誤:

 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 

我從我的研究瞭解,這些都有可能連接的問題,但我不能爲生命我找出問題所在。有沒有人可以對此問題有所瞭解?

回答

3

如果你使用C++源代碼,你應該鏈接到g ++程序而不是gfortran。英特爾編譯器的情況正好相反。

因此改變:

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

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

試過了,它給了我現在的錯誤。我會看看我能找到什麼。/usr/bin/ld:tgemm.o:未定義的符號引用'_gfortran_set_options @@ GFORTRAN_1.0' /usr/bin/ld:注意:'_gfortran_set_options @@ GFORTRAN_1.0'在DSO/usr/lib64 /請嘗試將其添加到鏈接器命令行中 /usr/lib64/libgfortran.so.3:無法讀取符號:無效操作 – Tesomas 2011-12-16 00:31:57

1

我有一個類似的問題,我用的 'libgomp.dll.a' 文件鏈接解決了它 - 我用MinGW的4.4。 或者您只需添加到libirary以鏈接「-lgomp」,例如LIBS + = -lgomp