在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,我试图将-lm参数插入CFLAGS的多个位置,但是仍然存在相同的错误。
任何想法 ???

顺便说一句,由于在CFLAGS中将它配置为-m64,因此我在64位ubuntu下编译了LinSched 3.3。在32位Ubuntu下进行的前编译会引发数据不兼容的错误(在elf64-x86-64和elf32-i386之间)

正如@ another.anon.coward所建议的那样,我检查了以后如何使用LFLAG,并发现它的使用方式很明显。作为解决方案,如何修改makefile以添加LFLAGS参数?

最佳答案

实际上,问题是链接器标志$ {LFLAGS}在/tools/linsched/tests/Makefile中使用不正确。

这是为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} [email protected]
        @echo CC TEST $@
        @${LD_PERCPU} -o [email protected] $^
-       @${CC} ${LFLAGS} -o $@ [email protected] -MMD
+       @${CC} -o $@ [email protected] ${LFLAGS} -MMD
        @rm [email protected]

clean:

10-08 07:28