Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build c++ code outside of microsoft visual studio

Tags:

(Noob here, so apologies for the very basic question). Currently I mostly use Sublime Text for editing code. However to compile I alt-tab to MSVC and compile there and then alt-tab again to a file browser and launch my .exe file. I am looking for a way to optimise this and not having to alt-tab all the time.

So first question is: Is there way to make Sublime Text compile a MSVC C++ project ? I know you can press Ctrl-B, but then you have to know how to set-up all the compiler options link all the libraries (and this was a total nightmare for me to do in MSVC, so preferrably I do not have to do this again for some other compiler).

Second question is: Once the .exe is compiled, is there way to make Sublime launch the .exe (now I have to look it up in my file browser each time, which is a huge pain).

like image 415
mnr Avatar asked May 17 '19 08:05

mnr


People also ask

Should I use Visual Studio for C?

Yes, you very well can learn C using Visual Studio. Visual Studio comes with its own C compiler, which is actually the C++ compiler. Just use the . c file extension to save your source code.

Can you compile C in Visual Studio Code?

C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.

Can you code C on Windows?

Two options. Great, now that Visual Studio Community is installed, you have two options for developing and running C programs on Windows. The first option involves using any text editor you like to write your source code, and using the "cl" command within the Developer Command Prompt to compile your code.


1 Answers

For once I do have a solution !

Here it is :

  • You have to be able to create shortcuts in ST to launch an external app I've tried this in ST3
  • You probably have Visual Studio solution at this point, so you need to create a shortcut to start MSBuild.exe
  • Create a shortcut to start your .exe

I found an old script that uses MSBuild to build an old solution like that :

%PATH_TO_MSBUILD%\MSBuild.exe %SLN_ABSOLUTE_PATH% /t:Clean /t:%TARGET% /p:Configuration=%MODE_COMPILATION%

Hope this helps.

like image 108
SOKS Avatar answered Nov 15 '22 04:11

SOKS