Как скомпилировать файл C без Visual Studio

Изучите Излишне любопытный: http://sourceforge.net/projects/snoopy/

6
задан avakar 12 July 2009 в 10:08
поделиться

6 ответов

Если у вас есть Visual Studio, у вас также есть компилятор командной строки C, который Visual Studio вызывает при сборке вашего проекта. Так что вам просто нужно вызвать его из командной строки.

Вы также можете бесплатно скачать компилятор C, доступно множество опций, таких как http://gcc.gnu.org/releases. html или см. http://www.thefreecountry.com/compilers/cpp.shtml

Если мы предполагаем, что вы используете компилятор Microsoft C / C ++ (cl.exe, который будет в VC подкаталог вашей установки Visual Studio), откройте командную строку Visual Studio (в ней будут установлены соответствующие пути). Чтобы скомпилировать файл с именем "helloworld.c", введите:

cl helloworld.c

Для получения дополнительной информации см. документацию MSDN .

9
ответ дан 9 December 2019 в 22:38
поделиться
%comspec% /k ""c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86

run above code in command prompt (visual studio 2010, editor: notepad.exe recommend)

c:\temp> cl.exe hello.c

1
ответ дан 9 December 2019 в 22:38
поделиться

If you're talking about not using the IDE GUI, an alternative is to set up a project for your C file as you normall would and call devenv.com to compile that project. It will then pass all the required paths and settings to the compiler and linker. We use that to compile some projects on our build servers. To learn more, type 'devenv.com /?'.

Regards,

Sebastiaan

1
ответ дан 9 December 2019 в 22:38
поделиться

Подробнее об этом здесь: http://msdn.microsoft.com/en-us/library/ms235639 (VS.80) .aspx

MSDN - отличный источник дополнительной информации.

0
ответ дан 9 December 2019 в 22:38
поделиться

Compiling the 'c' file from command line is easy and you have many answers to start with. However working with projects is a different thing and you will need to have a tool that will do it. Microsoft nmake was mentioned before, but i will suggest using gnu make utility that used for managing build. It is compiler independent, old (meaning proven) and very flexible tools that will allow you to create very robust build environment.

0
ответ дан 9 December 2019 в 22:38
поделиться

Lots of options out there. As mentioned by driis, there are lots of free c compilers available to download.

If you just want to compile code on a machine that has visual studio on it, microsoft offers several tools that allow command line use and project management:

  • Invoke the ide from the command line. You can use devenv.exe.
  • Use cl.exe directly (this is the c/c++ compiler and linker.
  • Microsoft offer a make tool (similar to the unix one) called NMake. Use this with makefiles for project management, in conjunction with cl.exe.

Microsoft have reference documents for command line building.

Another options is MonoDevelop - an open source ide that understand visual studio project files.

0
ответ дан 9 December 2019 в 22:38
поделиться
Другие вопросы по тегам:

Похожие вопросы: