未定义的引用为exp在Ubuntu(包括文件math.h和-lm链接) [英] Undefined reference to exp on Ubuntu (including math.h and linking with -lm)
本文介绍了未定义的引用为exp在Ubuntu(包括文件math.h和-lm链接)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些麻烦试图编译在Ubuntu上使用EXP功能的程序。我得到这个错误来自海湾合作委员会:
selied @阿波罗:〜/ Dropbox的/ practicas UAM /神经/ practica3 $化妆
gcc的-lm -o retropropagacion retropropagacion.o
retropropagacion.o:在函数'主':
/家庭/ selied / Dropbox的/ practicas UAM /神经/ practica3 / retropropagacion.c:177:未定义的参考`EXP
/家庭/ selied / Dropbox的/ practicas UAM /神经/ practica3 / retropropagacion.c:186:未定义的参考`EXP
/家庭/ selied / Dropbox的/ practicas UAM /神经/ practica3 / retropropagacion.c:297:未定义的参考`EXP
/家庭/ selied / Dropbox的/ practicas UAM /神经/ practica3 / retropropagacion.c:306:未定义的参考`EXP
collect2:LDdevolvióEL斯卡德萨利达1
使:*** [retropropagacion]错误1
在这里,我告诉你我的makefile。
CC = GCC
LDLAGS = -lm
CFLAGS = -Wall -g
EXE = retropropagacion normalizar
OBJ =
INC =编译:$(EXE)清洁:
@echo Borrando archivos temporales ...
RM -f *〜*的.o核心$(EXE)帮帮我 :
@回声反向传播:
./retropropagacion entrada.txt 0 0 salida.txt和:
./retropropagacion and.dat 0 0 salida_and.txt$(EXE):%:%的.o $(OBJ)
$(CC)$(LDLAGS)-o $ @ $ @。Ø$(OBJ)%的.o:%.C $(INC)
$(CC)$(CFLAGS)-c $<
另外,我也包括我的头文件的顶部,它的工作原理另一台计算机上。
你知道发生了什么事?
解决方案
$(CC)$(LDLAGS)-o $ @ $ @。Ø$(OBJ)
应
$(CC)-o $ @ $ @。Ø$(OBJ)$(LDLAGS)
无论 -l </ code>标志可以目标文件之前给出依赖于GCC的版本。
I'm having some trouble trying to compile a program that uses exp function on Ubuntu. I get this error from gcc:
selied@Apolo:~/Dropbox/practicas UAM/Neuro/practica3$ make
gcc -lm -o retropropagacion retropropagacion.o
retropropagacion.o: In function `main':
/home/selied/Dropbox/practicas UAM/Neuro/practica3/retropropagacion.c:177: undefined reference to `exp'
/home/selied/Dropbox/practicas UAM/Neuro/practica3/retropropagacion.c:186: undefined reference to `exp'
/home/selied/Dropbox/practicas UAM/Neuro/practica3/retropropagacion.c:297: undefined reference to `exp'
/home/selied/Dropbox/practicas UAM/Neuro/practica3/retropropagacion.c:306: undefined reference to `exp'
collect2: ld devolvió el estado de salida 1
make: *** [retropropagacion] Error 1
Here I show you my makefile.
CC = gcc
LDLAGS = -lm
CFLAGS = -Wall -g
EXE = retropropagacion normalizar
OBJ =
INC =
compile : $(EXE)
clean :
@echo Borrando archivos temporales...
rm -f *~ *.o core $(EXE)
help :
@echo
backpropagation :
./retropropagacion entrada.txt 0 0 salida.txt
and :
./retropropagacion and.dat 0 0 salida_and.txt
$(EXE) : % : %.o $(OBJ)
$(CC) $(LDLAGS) -o $@ $@.o $(OBJ)
%.o : %.c $(INC)
$(CC) $(CFLAGS) -c $<
Also I have include at the top of my header file and it works on another computer.
Do you know what's happening?
解决方案
$(CC) $(LDLAGS) -o $@ $@.o $(OBJ)
should be
$(CC) -o $@ $@.o $(OBJ) $(LDLAGS)
Whether -l
flags can be given before object files depends on the GCC version.
这篇关于未定义的引用为exp在Ubuntu(包括文件math.h和-lm链接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文