Skip to content

Instantly share code, notes, and snippets.

@weshouman
Last active May 19, 2016 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weshouman/2e251533a0cde1e692f63998220362fa to your computer and use it in GitHub Desktop.
Save weshouman/2e251533a0cde1e692f63998220362fa to your computer and use it in GitHub Desktop.
C++ compilation notes on windows and linux
clenvmin.bat ccdemowin.cpp && ccdemowin.exe
#include "iostream"
int main(void)
{
std::cout << "Hello! This is a C++ program.\n";
return 0;
}
g++ ccdemowin.cpp -o ccdemo && ./ccdemo
@echo off
:: Load compilation environment
:: note: we may need to extract the following call and execute it separately in the cli to avoid too long env variable
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
:: Invoke compiler with any options passed to this batch file
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe" %*
Windows steps:
make a clenvmin.bat next to the c++ file to be compiled, ensure you have the right path to cl.exe set in it
make a ccdemo.bat next to the c++ file
make your c++ file ie: the ccdemo.cpp here (note: in windows the extension must be cpp not c otherwise compilation errors will rise)
open a command line terminal where the files exist and run
$ ccdemo.bat
Linux steps:
run the ccdemo.sh which should be next to ccdemowin.cpp (note: any file type will work)
$ ccdemo.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment