2011-12-16 102 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