[英]math.h refer failure when compile LinSched 3.3 under 64-bit Ubuntu12.04
Compiling the LinSched 3.3 under 64-bit Ubuntu-12.04 throws me the following errors: 在64位Ubuntu-12.04下编译LinSched 3.3会引发以下错误:
******/home/xxxxx/Desktop/linsched_3.3/tools/linsched/tests/linsched_rand_test.c:169: undefined reference to `sqrt'
collect2: ld returned 1 exit status
make[1]: [linsched_rand_test] Error 1
make[1]: Leaving directory `/home/jianguo/Desktop/linsched_3.3/tools/linsched/tests'
make: [all] Error 2*
Seems there is a problem when refer/link to the math.h, which is: math: /usr/include/math.h
引用/链接到math.h时似乎存在问题,即:math:
/usr/include/math.h
From the make file of LinSched 3.3, the CFLAGS and LFLAGS are defined as follows, 从LinSched 3.3的make文件中,CFLAGS和LFLAGS的定义如下:
CC = ${CROSS_COMPILE}gcc
CFLAGS = -g -O2 -m64 -D__KERNEL__ -D__LINSCHED__ -Wall -Wundef -Wstrict-prototypes \
-Werror-implicit-function-declaration -fno-common \
-I${LINSCHED_DIR}/include -I${LINUXDIR}/include \
-I${LINUXDIR}/arch/linsched/include -I${LINSCHED_DIR}/ \
-include ${LINSCHED_DIR}/include/generated/autoconf.h \
-Wno-pointer-sign -include ${LINUXDIR}/include/linux/kconfig.h
CFLAGS_LINUX = $(CFLAGS) -nostdinc -isystem $(shell $(CC) -print-file-name=include) \
-include ${LINSCHED_DIR}/linux_linsched.h \
-Wno-unused -Wno-strict-aliasing
LFLAGS = -lm
....
...
...
LD_PERCPU = ${LD} -r -T ${LINSCHED_DIR}/linsched.lds
OBJ_FILES = ${LINSCHED_OBJS} ${LINUX_OBJS}
DEPS := ${OBJ_FILES:.o=.d}
-include ${DEPS}
TIME_HDR=${LINUXDIR}/kernel/timeconst.h
${TIME_HDR}: ${LINUXDIR}/kernel/timeconst.pl
@echo "(Generating timeconst.h)"
@perl ${LINUXDIR}/kernel/timeconst.pl 1000 > $@
${LINUX_OBJS}: %.o: %.c ${TIME_HDR}
@echo "CC KERNEL $<"
@${CC} -o $@ ${CFLAGS_LINUX} -c $< -MMD
%.o: %.c
@echo "CC SIM $<"
@${CC} ${CFLAGS} -o $@ -c $< -MMD
Someone on the web suggested to add -lm
into the CFLAGS, I tried to insert the -lm
parameter to several places of the CFLAGS, but the same errors persist. 网上有人建议将
-lm
添加到CFLAGS中,我试图将-lm
参数插入CFLAGS的多个位置,但是仍然存在相同的错误。 Any idea ??? 任何想法 ???
BTW, I compiled the LinSched 3.3 under 64-bit ubuntu becasue in the CFLAGS it is configured as -m64. 顺便说一句,由于在CFLAGS中将它配置为-m64,因此我在64位ubuntu下编译了LinSched 3.3。 And a former compile under 32-bit Ubuntu throws me error of data incompatibility(between elf64-x86-64 and elf32-i386)
在32位Ubuntu下进行的前编译会引发数据不兼容的错误(在elf64-x86-64和elf32-i386之间)
As suggested by @another.anon.coward, I checked how the LFLAGs is used later, and find it is vever used. 正如@ another.anon.coward所建议的那样,我检查了以后如何使用LFLAG,并发现它的使用方式很明显。 As a solution, how should I modify the makefile to add the LFLAGS parameter ???
作为解决方案,我应该如何修改makefile以添加LFLAGS参数?
Actually the issue was that linker flag ${LFLAGS} was used in /tools/linsched/tests/Makefile incorrectly. 实际上,问题是链接器标志$ {LFLAGS}在/ tools / linsched / tests / Makefile中使用不正确。
Here is the patch that fixes the math library link related build issue for linsched: 这是修复了Linsched的数学库链接相关构建问题的补丁:
diff --git a/tools/linsched/tests/Makefile b/tools/linsched/tests/Makefile
index 91bb8eb..8074c93 100644
--- a/tools/linsched/tests/Makefile
+++ b/tools/linsched/tests/Makefile
@@ -33,7 +33,7 @@ TEST_DEPS := ${TESTS:%=%.d}
${TESTS}: ${OBJ_FILES} $$@.o
@echo CC TEST $@
@${LD_PERCPU} -o $@.percpu $^
- @${CC} ${LFLAGS} -o $@ $@.percpu -MMD
+ @${CC} -o $@ $@.percpu ${LFLAGS} -MMD
@rm $@.percpu
clean:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.