构建交叉编译器
我正在尝试编译 c++ 文件并生成要在 PSIM 中反汇编和运行的 asm 或 s 文件。每当我尝试这样做时,我都会遇到错误。我正在尝试编译为 mipsI-linux。我想我已经确定给我的交叉编译器由于某种原因无法正常工作。谁能帮我构建一个新的交叉编译器来生成正确的指令格式?我正在研究 MAC。
I'm trying to compile a c++ file and generate an asm or s file to be disassembled and run in PSIM. Whenever I try to do this I get errors. I am attempting to compile to mipsI-linux. I think I've determined that my cross compiler that was given to me is not working correctly for some reason. Can anyone give me some help building a new cross compiler that will generate the correct instruction format? I'm working on a MAC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能想看看crosstool-NG(基于crosstool)这似乎使构建交叉编译器工具链相对容易。
You probably want to take a look at crosstool-NG (based on crosstool) which seems to make building a cross-compiler toolchain relatively easy.
Cross Linux-From-Scatch 是一个很好的起点。它引导您完成的第一步是构建一个具有所有依赖项的交叉编译器。
A great place to start is Cross Linux-From-Scatch. The first step it walks you through is building a cross-compiler with all of its dependencies.
我尝试了多种方法,发现使用 Buildroot 是最简单、最可靠的方法。只需下载Buildroot,解压,cd到顶级目录并运行
make-menuconfig
即可。设置选项,例如您需要交叉编译器的目标机器,然后运行 make
。制作需要 15-20 分钟,并且需要有效的互联网连接,因为所有源都是从在线档案下载并构建的。构建完成后,您将获得:交叉编译器工具链(gcc、as、ld 等,以及 glibc 或 ulibc,无论您在选项中选择哪个)。在-linux-gcc、-linux-as 等)位于
make
之后,二进制文件(名为将此位置添加到您的
PATH
变量(对于 Linux 用户),仅此而已。编辑:抱歉,我刚才注意到这个问题是针对 MAC 的。 MAC 可能不正式支持 Buildroot。
I have tried a number of approaches and found that using Buildroot was the simplest and most reliable approach. Just download Buildroot, uncompress, cd to the top-level directory and run
make-menuconfig
. Set the options such as what target machine you need the cross compiler for, and runmake
.The make takes 15-20 mins and needs an active internet connection as all sources are downloaded from online archives and built. After the build you get: a cross compiler toolchain (gcc,as,ld etc, and glibc or ulibc whichever you choose in the options). After
make
, the binaries (named < arch >-linux-gcc, < arch >-linux-as etc) are located at<buildroot-top-directory>/output/host/usr/bin.
Add this location to your
PATH
variable (for linux users) and that's it.Edit: Sorry, I noticed just now that the question is for MAC. Buildroot may not be officially supported for MAC.