gpt4 book ai didi

linux - 64位Ubuntu12.04下编译LinSched 3.3时math.h引用失败

转载 作者:太空宇宙 更新时间:2023-11-04 04:19:00 24 4
gpt4 key购买 nike

在 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*

引用/链接 math.h 时似乎存在问题,即:数学:/usr/include/math.h

从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

网上有人建议在CFLAGS中添加-lm,我尝试在CFLAGS的几个地方插入-lm参数,但仍然出现同样的错误。有什么想法吗???

顺便说一句,我在 64 位 ubuntu 下编译了 LinSched 3.3,因为在 CFLAGS 中它被配置为 -m64。以前在 32 位 Ubuntu 下编译时会出现数据不兼容的错误(elf64-x86-64 和 elf32-i386 之间)

根据@another.anon.coward的建议,我后来检查了LFLAG的使用方式,发现它从未被使用过。作为解决方案,我应该如何修改 makefile 以添加 LFLAGS 参数???

最佳答案

实际上,问题在于/tools/linsched/tests/Makefile 中错误地使用了链接器标志 ${LFLAGS}。

以下补丁修复了 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:

关于linux - 64位Ubuntu12.04下编译LinSched 3.3时math.h引用失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14733276/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com