Last active
May 19, 2016 05:39
-
-
Save weshouman/2e251533a0cde1e692f63998220362fa to your computer and use it in GitHub Desktop.
C++ compilation notes on windows and linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clenvmin.bat ccdemowin.cpp && ccdemowin.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "iostream" | |
int main(void) | |
{ | |
std::cout << "Hello! This is a C++ program.\n"; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ ccdemowin.cpp -o ccdemo && ./ccdemo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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