I recommend, to avoid path problems, to run Netbeans from cygwin shell. It works a bit like project in C development environmet. The export into common makefile is planned. You can create file performing steps above . Better documentation on makefile can be found here.
File extension is checked and file is put into proper file cathegory.
If the extension is not recognized, dialog considering this is shown. You will be asked if you really want to remove the file. If you answer yes, the link will be removed from makefile. Add to it library you need. Directory in which is each of this files is added to the includes search path for the compiler.