1

I've got a problem. I need to compile C code for linux, but I am using a windows IDE that I'd really want to use. Therefore I need an commandline compiler executable like gcc that is capable of compiling C code. Furthermore I also need to be able to compile CUDA C code into a linux program. Therefore my question:

Is it possible to compile CUDA C code into a Linux program on a Windows machine?

If it is possible, could someone give a full description to set up the compiler?

Thanks!

Rik Schaaf
  • 1,101
  • 2
  • 11
  • 30
  • You might want `cygwin`: http://metamod-p.sourceforge.net/cross-compiling.on.windows.for.linux.html – lurker Feb 24 '14 at 14:31
  • 1
    you need a cross compiler, maybe this will help you http://stackoverflow.com/questions/4769968/c-cross-compiler-from-windows-to-linux – Boklucius Feb 24 '14 at 14:37
  • What is preventing you from compiling on a Linux machine? Typically cross-compiling requires going rather far out of your way to accomplish something done much more easily by simply compiling on the intended platform. – pattivacek Feb 24 '14 at 14:45
  • 2
    There is no officially supported method. The only [officially supported host code compiler on windows](http://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#supported-operating-systems-5-5) is `cl.exe`, the compiler that comes with visual studio, and it only targets windows platforms. On linux, the supported host compiler is gnu/gcc/g++, so the first step to trying this would be to get a version of gcc perhaps from cygwin or minGW on a windows machine. But I think you still have a long way to go from that point. – Robert Crovella Feb 24 '14 at 14:48
  • @patrickvacek I have to compile code for a scientifically used computer. I don't have the rights to install software like NVCC on that system, so I need to compile it on an other machine. – Rik Schaaf Feb 24 '14 at 22:45
  • @RobertCrovella would it be possible to compile the linux compiler on a windows c++ compiler so that the resulting executable would be able to compile c to linux code? For a more detaild question, look at [this question](http://stackoverflow.com/questions/22001048/compile-linux-gcc-in-windows). – Rik Schaaf Feb 24 '14 at 23:07
  • 1
    I think the challenge you are looking at here is substantial. For example, I find it difficult to build a binary that will run correctly on a RHEL 5.5 machine from a RHEL 6 machine (linux->linux). The issue I'm worried about is not the compiler, but all the associated libraries. I'm also puzzled at the nature of the linux machine that you cannot use it to compile, but can use it to run codes. You mention that you cannot install nvcc. If `nvcc` is not installed, it probably means that the cuda tookit is not installed, which means cuda runtime apps will not run on that machine. – Robert Crovella Feb 25 '14 at 00:19
  • @RobertCrovella it isn't really the case that nvcc is not installed. It's that it just doesn't work for some reason and I have verified that the written code is not to blame. However, with the broken installation of the toolkit, I am able to run the code. I hope this makes sense for you. – Rik Schaaf Feb 25 '14 at 00:26
  • @RobertCrovella Also, it is just easier to hit a compile button then to type in the whole command needed for my program. I like to hit that button and send the file directly over sftp, so I can use the program. Note that I can only set up an ssh or sftp connection in 2 stages, because of security restrictions of the server. Therefore basic tools using ssh to compile won't work. – Rik Schaaf Feb 25 '14 at 00:30
  • I'd go for virtual Ubunto Linux on top of Windows – TripleS Feb 25 '14 at 12:29
  • @TripleS I think that is a great suggestion. Load the same version of linux that you plan to use on the target machine in a virtual box or other virtual machine on Windows. Then use that as a compile-only environment. If you would post that as a possible answer, I would upvote it. – Robert Crovella Feb 26 '14 at 15:13
  • @coolcat Nobody says you have to type in the command over and over again. Nobody does that. – David Heffernan Feb 26 '14 at 20:18

1 Answers1

2

I'd go for virtual Ubunto Linux on top of Windows

You can do it using virtual box virtual machine

TripleS
  • 1,216
  • 1
  • 23
  • 39
  • 1
    Though I do not like the outcome of this question, I think that at the moment this is the easiest way of making possible what I asked in the question. Thanks for your answer – Rik Schaaf Mar 06 '14 at 19:39