I, like freddie, use batch files for both VC++ and the NUWEN distro
1. NUWEN it is not an upgrade.
2. If it was installed as part of the code::blocks installation and you are not going to use code::blocks
NO
3. For the NUWEN distro make sure you do not have a current C:\MinGW directory. If so rename it for now.
Run the NUWEN setup and rename the MinGW it creates. I renamed it to C:\Nuwen-14.0
If you had and renamed your mingw you can change it back now.
4. It's your choice on downloads. I already had git installed so I di not need the NUWEN git version.
If you plan on using git in your code development then by all means get the git version.
I have no idea how to use code::blocks without it's included mingw compiler.
As I use several different mingw compilers I NEVER set the path in the environment. If you have remove it.
This is my nuwen g++ batch file. As I said I use several different versions of MinGW g++ so it has provisions for both 32 and 64 bit compiles. The NUWEN distro is 64bit only so don't let that throw you.
It is also for Vista+
You need to set the environment variable NUWEN64 to your NUWEN distro before calling this batch file:
In my case:
SET NUWEN64=C:\Nuwen-14.0
Usage: NUWENGPP.BAT inputfile[no extension cpp assumed] -m64 [CON GUI DLL OBJ] ExtraFile1 ExtraFile2
Note: ExtraFiles can be .a (import or static libraries) and .o (objectfiles)
It will also compile and add a resource file to the exe if the resource file has the same base name as the c++ file.
James
Code:
@setlocal
@ECHO OFF
REM NO longer supporting XP need to redefine _WIN32_WINNT and NTDDI_VERSION
REM *********************************************************************
REM MINGWGPP.BAT -> create Windows GUI, CON, OBJ or DLL using MinGW g++
REM *********************************************************************
REM Parameter 1 source file name no extension
REM Parameter 2 should be -m64
REM Parameter 3 should be CON for console GUI for windows OBJ for object module and dll for ...
REM *********************************************************************
REM ==============================================================================
REM For use with Vista+
SET WIN_VER=-DWINVER=_WIN32_WINNT_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA
REM
REM ==============================================================================
SET F=%~nx1
REM *********************************************************************
IF [%2] == [] GOTO usage
IF [%3] == [] GOTO usage
SET STATICLIB=-static-libgcc -std=c++14
IF /I NOT [%2] == [-m64] GOTO usage
SET MINGW=%NUWEN64%
SET DISTRO=NUWEN
IF /I [%3] == [CON] (
SET GCCCFL= %STATICLIB% -pipe -mconsole %2 -s -O2 -std=c++14 %WIN_VER%
SET FTYPE="Windows Console App"
SET OUTFILE="%F%.EXE"
)
IF /I [%3] == [GUI] (
SET GCCCFL= %STATICLIB% -pipe -mwindows %2 -s -O2 -std=c++14 %WIN_VER%
SET FTYPE="Windows Gui App"
SET OUTFILE="%F%.EXE"
)
IF /I [%3] == [DLL] (
SET GCCCFL= %STATICLIB% -pipe -shared -s -O2 -std=c++14 %2 -Wl,--add-stdcall-alias,--output-def,"%F%.def",--out-implib,"lib%F%.a"
SET FTYPE="Windows Dll"
SET OUTFILE="%F%.DLL"
)
IF NOT DEFINED GCCCFL GOTO usage
IF NOT EXIST "%F%.cpp" GOTO usage
REM --------------------------------------------------------------------
REM MINGW is set above to one of the NUWEN distros
REM --------------------------------------------------------------------
REM first check to see if this is a nuwen distro and set paths
SET var=%cd%
CD /D %MINGW%
IF EXIST "set_distro_paths.bat" (
CALL set_distro_paths
SET DISTRO=NUWEN
)
CD /D %var%
SET PATH=%MINGW%\bin;%PATH%
SET INCLUDE=-I%MINGW%\include -I%MINGW%\include\sys
SET LIB=%MINGW%\lib
IF /I [%3] == [OBJ] (
g++ %WARN% -c %2 %F%.cpp %WIN_VER% %4 %5 %6 %7 %8 %9
GOTO done
)
IF NOT DEFINED GCCCFL GOTO usage
IF NOT EXIST "%F%.cpp" GOTO usage
SET LIBS=-lmingw32 -lgcc -lkernel32 -luser32 -lgdi32 -lcomctl32 -ladvapi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lwinmm -lcomdlg32 -limagehlp -lversion -limm32 -lwininet -lurlmon %LIBS%
IF [%2] == [-m32] (
SET RESTARGET=-Fpe-i386
)
REM --------------------------------------------------------------
REM always use the %F%.rc file in the Res Directory if it exists
REM this should handle both projects and individual files with resources
IF EXIST "res\%F%.rc" (
ECHO Compiling resources.....
cd res
windres -I. %WIN_VER% %RESTARGET% -i "%F%.rc" -o "%F%res.o"
SET GRES="res\%F%res.o"
cd ..
) ELSE (
IF EXIST "%F%.rc" (
ECHO Compiling resources.....
windres -I. %WIN_VER% %RESTARGET% -i "%F%.rc" -o "%F%res.o"
SET GRES="%F%res.o"
)
)
REM --------------------------------------------------------------
ECHO Compiling "%F%.cpp" to a 64bit %FTYPE% Using %DISTRO% Distro
g++ %WARN% %GCCCFL% %INCLUDE% "%F%.cpp" %WIN_VER% -o %OUTFILE% %GRES% -static %4 %5 %6 %7 %8 %9 %LIBS%
:fini
ECHO Finished!
IF EXIST "%GRES%" del "%GRES%"
IF EXIST "%F%.o" del "%F%.o"
IF EXIST libs.bat del libs.bat
GOTO done
:usage
ECHO **************************************************************
ECHO Usage: NUWENGPP.BAT MainFile -m64 [CON GUI DLL OBJ] ExtraFile1 ExtraFile2
ECHO Note: ExtraFiles can be .a (import or static libraries) and
ECHO .o (objectfiles)
ECHO Use this batch file to easily create your g++ program
ECHO **************************************************************
:done
endlocal