简体   繁体   English

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

[英]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.

相关问题 在Linux上使用cin解析布尔值的g ++ 4.9消毒剂错误(ubuntu 12.04 64位) - g++ 4.9 sanitizer bug with cin parsing boolean on linux (ubuntu 12.04 64-bit) 如何从Ubuntu 12.04(64位)中删除所有Android -Tools(ADB和fastboot)以及SDK - How to Remove all Android -Tools (ADB and fastboot) plus SDK from Ubuntu 12.04 (64-bit) 如何在64位计算机上将libxml2和libcurl编译为32位? - How to compile libxml2 and libcurl to 32-bit under 64-bit machine? 如何使用自动工具,make和gcc在64位(Ubuntu 12.04LTS)Linux上编译和安装32Bit库? - How to compile and install a 32Bit library on a 64 Bit (Ubuntu 12.04LTS) Linux using autotools, make and gcc? 如何将我的Go程序从Mac OS X交叉编译为Ubuntu 64位 - How do I cross compile my Go program from Mac OS X to Ubuntu 64-bit Malloc在64位Ubuntu机器上失败 - Malloc Failing on 64-Bit Ubuntu box 在Ubuntu 12.04 64位上安装最新的Android SDK时出错 - Error when installing latest Android SDK on Ubuntu 12.04 64bit Linker 在使用 Clang 编译时无法在 64 位 Mint OS 下找到 32 位库 - Linker fails to find 32-bit libraries under 64-bit Mint OS when compiling with Clang 在 Ubuntu 64 上运行 ELF 64 位 LSB 可执行文件 - Run ELF 64-bit LSB executable on Ubuntu 64 gcc:在32位平台上编译64位二进制文​​件 - gcc: Compile a 64-bit binary on 32-bit platform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM