在windows中编译linux gcc - 在windows中编译nvcc [英] Compile linux gcc in windows - nvcc in windows

查看:1890
本文介绍了在windows中编译linux gcc - 在windows中编译nvcc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是一个有趣的问题,如果回答积极,将使交叉编译一个很容易。

here is an interesting question that, if answered positively, would make cross compiling a whole lot easier.

由于gcc是用C ++编写的,因此可以在Windows MinGW G ++或VSC ++编译器上重新编译Linux gcc编译器,以便生成的Windows可执行文件编译c代码到linux程序?

Since gcc is written in C++, would it be possible to recompile the Linux gcc compiler on Windows MinGW G++ or VSC++ compiler, so that the resulting Windows executable would be able to compile c code to linux programs?

如果是这样,需要做什么?

If so, what would be needed to do that?

做。

mingw32-g++ gcc.cpp -o gcc.exe

该命令可能不会工作,因为它可能已经做了之前,如果这很容易。我要求的是这个概念是否可能。

The command will probably not work because it would probably have been done before if it were that easy. What I ask is if this concept would be even possible.

编辑:感谢并将问题扩展到NVCC

fvu能够回答gcc编译器的问题(请使用下面的答案按钮),所以如果你有同样的问题,你可以感谢他(或她)。

fvu was able to answer the question for the gcc compiler (please use the answer button next time), so if you had the same question you can thank him (or her) .

作为问题的扩展,是否可以编辑或重新编译nvcc或它使用的东西,以便nvcc.exe可以从CUDA C代码创建一个linux程序?我读到nvcc的windows变体只能使用Visual Studio cl.exe,而不是MinGW或CygWin。

As an extention to the question, would it be possible to edit or recompile nvcc or the things it uses so that nvcc.exe can create a linux program from CUDA C code? I read that the windows variant of nvcc can only use the Visual Studio cl.exe and not MinGW or CygWin.

是否可以使用cl.exe创建linux程序?如果是这样,可以用nvcc.exe生成linux程序吗?

Is it possible to create linux programs with cl.exe? And if so, could that be used to generate linux programs with nvcc.exe?

推荐答案

gcc手册,gcc的架构使得很容易设置一个目标与开发机器不同的工具链。

Read the chapter on cross compiling in the gcc manual, gcc's architecture makes it quite easy to set up a toolchain where the target is different from the development machine.

我从来没有走过你描述的确切路由,但是我在Windows下构建了工具链,目标是ARM9嵌入式Linux机器,就像一个charm--使用cygwin btw。请观看此处,轻松介绍。此外,非常有用的信息此处

I never went the exact route you describe, but I have built toolchains under Windows that target ARM9 embedded Linux machines, works like a charm - using cygwin btw. Look here for a gentle introduction. Also very useful info here.

我不会评论关于nvcc可以做什么,CUDA是在我的(长)列表中的东西修改...

I am not going to comment on what can be done with respect to nvcc, CUDA is somewhere on my (long) list of stuff to tinker with...

现在,可以生成Linux二进制文件吗?这个问题的答案是排序:只要目标处理器来自cl支持的处理器系列,它生成的目标文件可能不会包含任何阻止其在Linux上执行的内容,因为它们会只包含机器码。这就是理论。然而:

Now, can cl generate Linux binaries? The answer to this question is "sort of" : as long as the target processor is from a processor family that's supported by cl, the object files generated by it should probably not contain anything that would inhibit its execution on Linux, as they'll just contain machine code. That's the theory. However:


  • 因为Linux使用另一种可执行格式,您将需要一个Windows托管的链接器,了解Windows样式对象文件(afaik,COFF) ,并将它们链接到一个Linux风格(ELF)可执行文件。我从来没有听说过这样的野兽,虽然在理论上它可能存在

  • 启动代码(一个微小的程序,包裹你的主要功能)也将是不同的,需要写

  • 还有一些,例如图书馆相关问题

>回答是没有,虽然它可能是一个很好的夏天项目为无聊的学生:)

So, the practical answer is no, although it might be a nice summer project for a bored student :)

这篇关于在windows中编译linux gcc - 在windows中编译nvcc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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