简体   繁体   English

编译“stress-ng”包的静态链接可执行文件

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

相关问题 Stress-ng:使用execv编写应用程序以调用Stress-ng命令,如果成功或失败,则返回 - Stress-ng: Writing an application program using execv to invoke stress-ng commands and return if it is success or failure GDB 可以使用静态链接库重新加载可执行文件吗? - Can GDB reload executable with a statically linked library? 从可执行文件中提取静态链接库 - Extract statically linked libraries from an executable 在Windows上将EXPAT编译为静态链接的.a - Compile EXPAT to statically-linked .a on Windows 为什么可执行文件小于与应用程序项目静态链接的库? - why executable is smaller than the library which is statically linked with application project? 为什么动态链接的可执行文件明显慢于Linux中的静态链接? - Why is a dynamically linked executable noticeably slower than the statically linked one in Linux? 当一个C库静态链接时,整个库是否会被添加到可执行文件中? - When a C library is statically linked does the whole library get added to the executable? Linux上的C ++,确认库中的代码未静态链接到生成的可执行文件中 - C++ on Linux, confirm code from library is not being statically linked into resulting executable 静态链接的可执行文件的启动代码会发出如此多的系统调用? - Startup code of a statically-linked executable issues so many system calls? 数学库是静态链接的吗? - Is the math library linked statically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM