Thread: How to use the boost that comes with nuwen_distro?

  1. #1
    Registered User
    Join Date
    Mar 2016
    Posts
    203

    How to use the boost that comes with nuwen_distro?

    I downloaded distro 14.0 from MinGW Distro - nuwen.net and according to its specs, also available through that link, the distro comes with Boost 1.61.0 – in fact I can see that boost has been downloaded as one of the subfolders in C:\MinGW\MinGW\include
    The compiler (gcc 6.1) is working fine without boost but whenever I #include a boost header I'm getting the error message:
    Code:
     fatal error: … No such file or directory #include <boost/...hpp>

    Would someone be able to advise what else needs to be done to get boost working with this compiler?
    Many thanks

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    You probably just need to add the include path. It's "-I/path/to/lib/directory"

  3. #3
    Registered User
    Join Date
    Mar 2013
    Posts
    63
    just add the boost include you want:
    #include "boost/variant.hpp"


    Make sure you call the set_distro_paths.bat first.


    James

  4. #4
    Registered User
    Join Date
    Mar 2016
    Posts
    203
    James – thank you, thank you, thank you! It works!!!
    to remind myself in future and for anyone else who might use this page now/later, here are the steps from the command line:
    1. go to the C: root directory
    2. cd mingw (change directory to mingw folder)
    3.cd mingw (further change directory to the mingw sub-folder)
    //this brings us the sub-directory where the set_distro_paths.bat file is saved
    4. set_distro_paths.bat (run the file)
    5. return to C: root directory within the same command window
    6 (a). cd users; (b) cd <myname_folder>//where the .cpp file is saved
    7. g++ -o input input1.cpp //yes, I should turn on adequate warnings, this was just testing
    9. now run the executable, input – voila!!!

    If I may, a quick follow-on question – what would be the cppreference.com equivalent for boost viz. a credible, (more/less) up-to-date website to navigate the boost library, with sample programs? Many thanks once again.

  5. #5
    Registered User
    Join Date
    Mar 2013
    Posts
    63
    I am really not versed in boost at all. I just use the NUWEN distro for specific projects.
    I primarily use Visual Studio 2017 Community but like to check things with the NUWEN distro.
    First I never use a c:\mingw folder for anything as I use a number of MinGW distros:
    Nuwen,TDM,and a couple of the older ones for various situations.
    I let the Nuwen setup create it's c:\MinGW folder but I always rename it to the current Nuwen version:
    C:\Nuwen-14.1
    I shell from my editor to a batch file similar to this:
    Because this was adapted for 32/64 compiling second parameter should be -m64


    :: ************************************************** *******************
    @setlocal enableextensions enabledelayedexpansion
    @ECHO OFF
    :: NUWENGPP.BAT -> create Windows GUI, CON, OBJ, or DLL using MinGW g++
    :: ************************************************** *******************
    :: Parameter 1 source file name no extension
    :: Parameter 2 should be -m64
    :: Parameter 3 should be CON for console GUI for windows OBJ for object module and dll for ...




    SET F=%~nx1


    IF [%2] == [] GOTO usage
    IF [%3] == [] GOTO usage


    SET STATICLIB=-static-libgcc -std=c++14
    IF /I NOT [%2] == [-m64] GOTO usage
    :: ************************************************** *******************
    :: Set the path to your Nuwen base folder.
    :: Mine is set in my editor before shelling to this batch file: C:\Nuwen-14.1
    ::
    SET MINGW=%NUWEN64%
    :: ************************************************** *******************
    SET DISTRO=NUWEN


    IF /I [%3] == [CON] (
    SET GCCCFL= %STATICLIB% -pipe -mconsole %2 -s -O2 -std=c++14
    SET FTYPE="Windows Console App"
    SET OUTFILE="%F%.EXE"
    )


    IF /I [%3] == [GUI] (
    SET GCCCFL= %STATICLIB% -pipe -mwindows %2 -s -O2 -std=c++14
    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


    :: --------------------------------------------------------------------
    :: MINGW is set above to one of the NUWEN distros
    :: --------------------------------------------------------------------
    :: 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++ -c %2 %F%.cpp -DWINVER=0x601 -D_WIN32_WINNT=0x601 %4 %5 %6 %7 %8 %9
    GOTO done
    )


    :: set LIB to the most common libraries
    SET LIBS=-lmingw32 -lgcc -lkernel32 -luser32 -lgdi32 -lcomctl32 -ladvapi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lwinmm -lcomdlg32 -limagehlp -lversion -limm32 -lwininet -lurlmon %LIBS%


    :: this batch file will also compile a resource file with the same name as the c++ file.
    :: it can be in folder res\ or the same folder as the c++ source


    IF EXIST "res\%F%.rc" (
    ECHO Compiling resources.....
    cd res
    windres -I. -DWINVER=0x601 -D_WIN32_WINNT=0x601 -i "%F%.rc" -o "%F%res.o"
    SET GRES="res\%F%res.o"
    cd ..
    ) ELSE (
    IF EXIST "%F%.rc" (
    ECHO Compiling resources.....
    windres -I. -DWINVER=0x601 -D_WIN32_WINNT=0x601 -i "%F%.rc" -o "%F%res.o"
    SET GRES="%F%res.o"
    )
    )


    ECHO Compiling "%F%.cpp" to a 64bit %FTYPE% Using %DISTRO% Distro


    g++ %GCCCFL% %INCLUDE% "%F%.cpp" -DWINVER=0x601 -D_WIN32_WINNT=0x601 -o %OUTFILE% %GRES% -static %4 %5 %6 %7 %8 %9 %LIBS%


    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

  6. #6
    Registered User
    Join Date
    Mar 2016
    Posts
    203
    James – thanks for sharing your set-up, it's enabled me to also download the distro 14.1 (gcc 6.3, boost 1.63) and have it running side-by-side with the previously installed distro 14.0. Now, of course, everything looks super simple but, until today, it's something I'd struggled with for long and am very grateful for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Do you use Boost?
    By sarah22 in forum C++ Programming
    Replies: 4
    Last Post: 06-04-2010, 02:15 PM
  2. boost libraries
    By herWter in forum C++ Programming
    Replies: 6
    Last Post: 07-15-2008, 05:35 PM
  3. boost optional
    By l2u in forum C++ Programming
    Replies: 0
    Last Post: 09-02-2007, 05:42 PM
  4. boost
    By siavoshkc in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 10:58 PM
  5. erasing elements from a boost::ptr_vector (boost n00b)
    By Marcos in forum C++ Programming
    Replies: 2
    Last Post: 04-04-2006, 12:54 PM

Tags for this Thread