ublo
bogdan's (micro)blog

bogdan » using mingw with notepad++ and nppexec

11:28 pm on Dec 17, 2011 | read the article | tags:

first time i heard about mingw was from florin manea, then a lecturer at the university of bucharest, faculty of mathematics. i didn’t pay to much attention to it as i was a dedicated gentoo user. time has passed, and the table turned, me being the one to teach a small course on physical computing at the physics faculty. student’s have various backgrounds but none comes from a computer science oriented faculty, so i had to show them how to connect the μC serial output to their windows environment.

i know there are other ways, but i chose mingw combined with my favorite windows editor, notepad++.

here are the steps to install and make them play well together:

1. download mingw from here (no worries, this is the source-forge link). this is an automated installer and just click “next”, “next”, “next”… be careful to choose whichever compiler you need (there are plenty to choose from);

2. adjust the windows “path”. open the “Advanced Systems Settings” (on Vista and Win7) or just right-click the My Computer and choose properties. choose the “Advanced” tab, and the last button on the tab is “Environment Variables”. Click it and you’ll get a “User variables for username” where you need to edit the “PATH” variable adding “;C:\MinGW\bin” where this is the path to the “bin” directory from the MinGW install. if you’re not the only user who uses this, you should also edit the “System Variables” “Path”. If the variable is missing, create it and fill it in with “C:\MinGW\bin” only (don’t forget to put the real path in here).

3. close everything with “ok” and “apply” if needed. open notepad++ and be sure that you have the NppExec plugin installed (under the “Plugins” menu item). if not, just choose “Plugin Manager” from the same menu, then “Show Plugin Manager” and check the “NppExec” plugin followed by “Install” (needless to say you need internet connection to do so).

4. NppExec being installed, write a small program in notepad++, press the “F6” key and in the small window there copy/paste the following code:

cd $(CURRENT_DIRECTORY)
gcc -o $(NAME_PART).exe $(FILE_NAME)
$(CURRENT_DIRECTORY)\$(NAME_PART).exe

save it with a nice name. then just click “Ok”. you should see the console compiling and running the small program. you’re done!

possible errors: try to keep clean the names for any files or folders involved in your project. avoid spaces and punctuation. for example, i’m using “D:\Projects\MyProjectName\MyProjectName.c” and it works fine!

aceast sait folosește cookie-uri pentru a îmbunătăți experiența ta, ca vizitator. în același scop, acest sait utilizează modulul Facebook pentru integrarea cu rețeaua lor socială. poți accesa aici politica mea de confidențialitate.