[英]Compile a statically linked executable of the “stress-ng” package
I'm trying to compile the "stress-ng" package to produce a statically linked executable to use it inside GEM5 full system simulator. 我正在尝试编译“stress-ng”包以生成静态链接的可执行文件,以便在GEM5完整系统模拟器中使用它。
A tarball of this package can be downloaded here . 这个软件包的tarball可以在这里下载。 The version I'm trying to compile is 0.07.08.
我正在尝试编译的版本是0.07.08。
To compile a dynamically linked executable of this package, just "make". 要编译此包的动态链接可执行文件,只需“make”。 This works for me.
这适合我。
However, since I need to run the "stress-ng" exe from within a GEM5 full system simulation, I need to make sure that the exe is self-contained. 但是,由于我需要在GEM5完整系统模拟中运行“stress-ng”exe,我需要确保exe是自包含的。 This is usually done using the "-static" CFLAG option, however, for "stress-ng", I get an error when I try this option.
这通常使用“-static”CFLAG选项完成,但是,对于“stress-ng”,我在尝试此选项时出错。
Here is what to do in order to reproduce this error. 以下是重现此错误的方法。 Edit "Makefile" and add "-static" option at the end of line # 25. Line 25 should look like the following:
编辑“Makefile”并在第25行末尾添加“-static”选项。第25行应如下所示:
CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' -O2 -std=gnu99 -static
Save then make, you will see the error below: 保存然后制作,您将看到以下错误:
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpthread.a(lowlevellock.o): In function `__lll_lock_wait_private':
/build/eglibc-3GlaMS/eglibc-2.19/nptl/../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:78: multiple definition of `__lll_lock_wait_private'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libc.a(libc-lowlevellock.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpthread.a(lowlevellock.o): In function `__lll_unlock_wake_private':
/build/eglibc-3GlaMS/eglibc-2.19/nptl/../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:328: multiple definition of `__lll_unlock_wake_private'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libc.a(libc-lowlevellock.o):(.text+0x30): first defined here
collect2: ld returned 1 exit status
make: *** [stress-ng] Error 1
Finally, OS is Ubuntu 14.04 and cc version is 4.6.4. 最后,OS是Ubuntu 14.04,cc版本是4.6.4。
Am I missing some other CFLAG option(s) here? 我在这里错过了其他一些CFLAG选项吗?
I've pushed a new fix to the stress-ng repo that now allows static linking. 我已经推出了一个新的修复程序,现在允许静态链接的stress-ng repo。 The issue was that -lc was before -lpthread, which caused the problem.
问题是-lc在-lpthread之前,导致了这个问题。
Pull the latest changes and then build with: 拉出最新的更改然后构建:
STATIC=1 make STATIC = 1 make
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.