With the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.21)
project(AdventOfCode2021)
set(CMAKE_CXX_STANDARD 14)
find_package(Boost 1.77.0 COMPONENTS REQUIRED)
include_directories(CppSrc)
add_executable(AdventOfCode2021
CppSrc/Day2.cpp
CppSrc/Day2.h)
Everything is fine. However, when I go to use boost in my Day5 code and want to use boost/algorithm/string_regex.hpp, I seem to need to modify my CMakeLists.txt to include Boost. So I followed this post, including installing the latest version of MinGW that they linked.
This results in a CMakeLists.txt:
project(AdventOfCode2021)
set(CMAKE_CXX_STANDARD 14)
set(Boost_INCLUDE_DIR C:/MinGW/include/)
set(Boost_LIBRARY_DIR C:/MinGW/lib/)
find_package(Boost 1.77.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
include_directories(CppSrc)
add_executable(AdventOfCode2021
CppSrc/Day5.cpp
CppSrc/Day5.h)
This CMake build does not work:
By removing system and filesystem from the find_package command, I can make the CMake build pass, but when I try to run my Day5 main I get all these errors:
"K:\Big Application\CLion 2021.3\bin\cmake\win\bin\cmake.exe" --build C:\Users\Kevin\AdventOfCode2021\cmake-build-debug --target AdventOfCode2021
[1/2] Building CXX object CMakeFiles\AdventOfCode2021.dir\CppSrc\Day5.cpp.obj
FAILED: CMakeFiles/AdventOfCode2021.dir/CppSrc/Day5.cpp.obj
C:\PROGRA~2\MICROS~3\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\cl.exe /nologo /TP -IC:\MinGW\include -IC:\Users\Kevin\AdventOfCode2021\CppSrc /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++14 /showIncludes /FoCMakeFiles\AdventOfCode2021.dir\CppSrc\Day5.cpp.obj /FdCMakeFiles\AdventOfCode2021.dir\ /FS -c C:\Users\Kevin\AdventOfCode2021\CppSrc\Day5.cpp
C:\MinGW\include\limits.h(34): warning C4068: unknown pragma
C:\MinGW\include\msvcrtver.h(35): warning C4068: unknown pragma
C:\MinGW\include\w32api.h(35): warning C4068: unknown pragma
C:\MinGW\include\sdkddkver.h(35): warning C4068: unknown pragma
C:\MinGW\include\w32api.h(186): warning C4005: '_EXTERN_C': macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\yvals_core.h(812): note: see previous definition of '_EXTERN_C'
C:\MinGW\include\stdlib.h(34): warning C4068: unknown pragma
C:\MinGW\include\stdlib.h(166): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(169): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(335): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(336): error C2062: type 'long' unexpected
C:\MinGW\include\stdlib.h(338): error C2062: type 'double' unexpected
C:\MinGW\include\stdlib.h(339): error C2062: type 'double' unexpected
C:\MinGW\include\stdlib.h(342): error C2062: type 'double' unexpected
C:\MinGW\include\stdlib.h(343): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(344): error C2062: type 'long' unexpected
C:\MinGW\include\stdlib.h(379): error C2062: type 'float' unexpected
C:\MinGW\include\stdlib.h(382): error C2062: type 'long double' unexpected
C:\MinGW\include\stdlib.h(385): error C2062: type 'long' unexpected
C:\MinGW\include\stdlib.h(386): error C2062: type 'unsigned long' unexpected
C:\MinGW\include\stdlib.h(395): error C2062: type 'long' unexpected
C:\MinGW\include\stdlib.h(398): error C2062: type 'unsigned long' unexpected
C:\MinGW\include\stdlib.h(400): error C2062: type 'double' unexpected
C:\MinGW\include\stdlib.h(407): error C2062: type 'float' unexpected
C:\MinGW\include\stdlib.h(410): error C2062: type 'long double' unexpected
C:\MinGW\include\stdlib.h(474): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdlib.h(474): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\MinGW\include\stdlib.h(474): error C2377: 'size_t': redefinition; typedef cannot be overloaded with any other symbol
predefined C++ types (compiler internal)(16): note: see declaration of 'size_t'
C:\MinGW\include\stdlib.h(474): error C2146: syntax error: missing ';' before identifier 'wcstombs'
C:\MinGW\include\stdlib.h(474): error C2061: syntax error: identifier 'size_t'
C:\MinGW\include\stdlib.h(475): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(477): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(478): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdlib.h(478): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\MinGW\include\stdlib.h(478): error C2146: syntax error: missing ';' before identifier 'mbstowcs'
C:\MinGW\include\stdlib.h(478): error C2061: syntax error: identifier 'size_t'
C:\MinGW\include\stdlib.h(479): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(481): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(482): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(484): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(485): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(486): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(487): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(488): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(489): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(495): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(496): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(503): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(506): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(509): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(510): error C2062: type 'long' unexpected
C:\MinGW\include\stdlib.h(522): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdlib.h(522): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\MinGW\include\stdlib.h(522): error C2377: 'div_t': redefinition; typedef cannot be overloaded with any other symbol
C:\MinGW\include\stdlib.h(519): note: see declaration of 'div_t'
C:\MinGW\include\stdlib.h(522): error C2146: syntax error: missing ';' before identifier 'div'
C:\MinGW\include\stdlib.h(523): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdlib.h(523): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\MinGW\include\stdlib.h(523): error C2377: 'ldiv_t': redefinition; typedef cannot be overloaded with any other symbol
C:\MinGW\include\stdlib.h(520): note: see declaration of 'ldiv_t'
C:\MinGW\include\stdlib.h(523): error C2146: syntax error: missing ';' before identifier 'ldiv'
C:\MinGW\include\stdlib.h(530): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(545): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(547): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(548): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(553): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdlib.h(553): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\MinGW\include\stdlib.h(553): error C2377: '_onexit_t': redefinition; typedef cannot be overloaded with any other symbol
C:\MinGW\include\stdlib.h(552): note: see declaration of '_onexit_t'
C:\MinGW\include\stdlib.h(553): error C2146: syntax error: missing ';' before identifier '_onexit'
C:\MinGW\include\stdlib.h(555): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(557): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(559): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(560): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(561): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(564): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(567): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(569): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(571): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(572): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(573): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(574): error C2062: type 'wchar_t' unexpected
C:\MinGW\include\stdlib.h(575): error C2062: type 'wchar_t' unexpected
C:\MinGW\include\stdlib.h(576): error C2062: type 'wchar_t' unexpected
C:\MinGW\include\stdlib.h(628): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(629): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(631): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(632): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(635): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(636): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(637): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(649): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(653): error C2062: type 'void' unexpected
C:\MinGW\include\stdlib.h(653): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdlib.h(653): error C2447: '{': missing function header (old-style formal list?)
C:\MinGW\include\stdlib.h(657): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdlib.h(657): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\MinGW\include\stdlib.h(657): error C2377: 'lldiv_t': redefinition; typedef cannot be overloaded with any other symbol
C:\MinGW\include\stdlib.h(656): note: see declaration of 'lldiv_t'
C:\MinGW\include\stdlib.h(657): error C2146: syntax error: missing ';' before identifier 'lldiv'
C:\MinGW\include\stdlib.h(659): error C2062: type '__int64' unexpected
C:\MinGW\include\stdlib.h(666): error C2062: type '__int64' unexpected
C:\MinGW\include\stdlib.h(667): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdlib.h(667): error C2447: '{': missing function header (old-style formal list?)
C:\MinGW\include\stdlib.h(671): error C2062: type '__int64' unexpected
C:\MinGW\include\stdlib.h(674): error C2062: type 'unsigned __int64' unexpected
C:\MinGW\include\stdlib.h(766): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(767): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(809): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(810): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdlib.h(810): error C2447: '{': missing function header (old-style formal list?)
C:\MinGW\include\stdlib.h(819): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(820): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(823): error C2062: type 'char' unexpected
C:\MinGW\include\stdlib.h(824): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdlib.h(824): error C2447: '{': missing function header (old-style formal list?)
C:\MinGW\include\stdlib.h(831): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(832): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(834): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(837): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(838): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdlib.h(838): error C2447: '{': missing function header (old-style formal list?)
C:\MinGW\include\stdlib.h(841): error C2062: type 'int' unexpected
C:\MinGW\include\stdlib.h(842): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdlib.h(842): fatal error C1003: error count exceeds 100; stopping compilation
ninja: build stopped: subcommand failed.
I've been trying to Google these problems without much luck. Any help would be appreciated.