编译独立的静态可执行文件 [英] Compile a Standalone Static Executable

查看:180
本文介绍了编译独立的静态可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译一个不使用动态加载器的可执行文件(ELF文件)。我构建了一个交叉编译器,编译来自linux的臀部,用于我做的模拟器。我断言标志-static-libgcc编译我的hello.cpp文件(hello世界程序)。显然这还不够。因为在我的可执行文件中还有一个段,它包含动态加载器的名称/路径。我使用什么标志来生成一个包含一切需要运行的可执行文件?

I'm trying to compile an executable (ELF file) that does not use a dynamic loader. I built a cross compiler that compiles mips from linux to be used on a simulator I made. I asserted the flag -static-libgcc on compilation of my hello.cpp file (hello world program). Apparently this is not enough though. Because there is still a segment in my executable which contains the name/path of the dynamic loader. What flags do I use to generate an executable which contains EVERYTHING needed to be run? Do I need to rebuild my cross compiler?

推荐答案

尝试使用 -static flag?

这篇关于编译独立的静态可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆