Traditionally, using GCC to compile Max externals for Windows meant using the Cygwin environment.  
If you want to use GCC 4, however, then you will not be able to use the Cygwin environment because 
Cygwin's build of GCC 4 no longer supports the required -mno-cygwin flag. 

Instead you can use MSys/Mingw, as described here.  This is not intended to be a throrough treatment
of this subject matter, but as a rough guide to get interested users started on a path that may
meet their needs.


SETTING UP THE ENVIRONMENT

	1.	Automated Mingw installer (MinGW 5.1.6)
			select "full" install when prompted
			accept default install location
		
	2.	MSYS-1.0.11.exe
			accept default install location
			installer will launch a command prompt and then wait for mingw to be installed
	
	3.	Start MSys:
			$ cd /etc
			$ cp fstab.sample fstab
			$ e fstab
				(make appropriate edits -- if you don't have the 'e' editor, another editor will do)
				(quit msys)
				(start it again)
			$ gcc -v
				(should see a version number)
	
	4.	Download gcc-full-4.4.0-mingw32-bin.tar.lzma
			$ unarchive over the old installation
			$ lzma -dv gcc-full-4.4.0-mingw32-bin.tar.lzma
			$ tar -xf gcc-full-4.4.0-mingw32-bin.tar
	
	5.	GDB for debugging
			$ tar -xf gdb-7.0-mingw32-bin.tar
	
	6.	restart mysys
			$ gcc -v
			$ gdb -v
				(results of these commands should show the correct versions)
	

BUILDING THE 'COLLECT' EXAMPLE WITH GCC

	1.	build this example
			$ cd <sdk-path>/collect
			$ make
		
	Note: The -fvisibility=hidden option does not apply on Windows when compiling with GCC.
	Instead, all symbols are exported unless there is a .def file passed to the linker, 
	or symbols are exported in the source code using __declspec(dllexport).
		
	You can use the Visual Studio Command Prompt (assuming you have visual studio installed) 
	to see what symbols are really exported:
		  $ dumpbin /exports collect.mxe > exports.txt
		

DEBUGGING WITH GDB

	1.	Launch the Max Runtime

	2.	The object has to be loaded before the debugger tries to attach.  So you have a couple of options:
			a. place your object in the Cycling '74/extensions folder 
			b. after the runtime has launched, load your object (probably by opening a patcher with your object) in the runtime

	3.	Determine runtime info:
			$ id
				(This will let you know your user id.  Use that below in place of '500')

			$ ps -Wf -u500
				(This way you can find the process id for the Max Runtime application.
				 For the purposes of this text, we will assume the process id is 2336)
		
	4.	Command:
			$ gdb collect.mxe
		
			(gdb) attach 2336
			(gdb) b collect_bang
			(gdb) c
		
			The above first attaches to the process by process id number, 
			then it sets a breakpoint at the start of the collect_bang() method,
			and then continues with the execution of the runtime (which was halted when we attached)

	5.	Trigger the breakpoint by clicking the button the Max patcher that sends a 'bang'	to the collect object.
			GDB should stop execution of the program and allow you to explore the current state of the execution.
	
			Because Max does not have symbols available, some commands (like 'bt' (backtrace)) will not provide 
			a wealth of information.  You can see the local data for your object, however.
			
			
USING THE CODE::BLOCKS IDE

	1.	From the menu, choose "Settings > Compiler & Debugger"

	2.	Set the Toolchain Executables folder to your MinGW folder installed earlier in this document.
	
	3.	Also in the Toolchain Executables make sure that the correct selections are made for the various tools.  
			It is *especially important* that the mingw32-make.exe is used for make.
	
	4.	Open 'collect.cbp' in Code::Blocks.  Build.
	
			Note that this cbp file does not actually define the settings for the compiler directly.  
			Instead, it simply invokes the same Makefile that is used when building from the command-line as above.
			For many, however, the environment will feel more comfortable and the error reporting will be easier to navigate.

	5.	Debugging
	
			This is a gui for GDB, and so one would expect the same process as above, condensed here as:
			
			A.	Launch the Runtime
			B.	Load your object in the Runtime (open collect.maxhelp)
			C.	Attach to the Runtime using the "Debug > Attach to Process..." menu item in Code::Blocks
			D.	Set a breakpoint
			E.	Continue
			F.	Trigger the breakpoint with an action in the Max Runtime

			Unfortunately, this doesn't appear to work at the present time.  Instead, Code::Blocks insists on 
			*restarting* the executable when you choose to "Continue" instead of simply continuing.  In the
			process the symbols for the DLL/MXE are lost and your breakpoints will never halt the execution of Max.
