How to compile C programs in Visual Studio 2019 without opening a project or solution?

Asked

Viewed 54 times

0

I’m new to programming and I’m trying to use Visual Studio 2019 to write C codes. But for that I need to create a project/solution within the IDE, Something that does not suit me because I am at all times creating new files to test functions and solve problems and apparently, Visual Studio compiles an entire solution, not being able to execute files . c separately (from what I understand reading some articles is this, if I’m wrong, please let me know). I would like to run my codes only by browsing folders, but unfortunately my codes do not compile.

Searching, I was able to discover that it is possible to run Rpgs without the need for a project/solution (Microsft’s own website says so). However, in the article I read, they don’t explain how to do that. I also heard about Cmake who compiles the code but I couldn’t configure it for my machine. I tried also Mingw but also could not configure it to compile my codes.

How I can compile and run programs . c in Visual Studio 2019 without a project/solution?

1 answer

2


Build Tools from Visual Studio 2019

You can use Visual Studio 2019 for editing only, if you prefer, and compile your codes using Build Tools from Visual Studio 2019.

To learn how to install and use a compiler from a program that allows access to your OS file system (I believe it’s Windows) by command line (such as the Powershell, for example), try this article. There is no need to create a project through the IDE, as you will almost always have extra files that are proprietary to the tool, such as configuration files. You can just create a directory with the files .c and compile one or more of them from the command line.

Considerations

From experience, I have two ways to compile code in C. The first is using an online compiler. It suits me when I just need to run a small block of code or a simple program. I edit the code on it or on Visual Studio Code.

For larger, more complex programs and/or programs that need to be compatible with more than one platform, I use the WSL, compiling the code with the GCC.

I hope I’ve helped in some way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.