File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 11@ echo off
2+ setlocal enabledelayedexpansion
3+
24:: Compiler and flags
35set CXX = g++
4- set CXXFLAGS = -std=c++17 -Iinclude -Wall -Wextra -Werror
6+ set CXXFLAGS = -std=c++17 -Iinclude -Wall -Wextra -Werror -mthreads
57
68:: Directories
79set SRC_DIR = src
@@ -12,6 +14,11 @@ set OUTPUT_DIR=output
1214:: Target executable
1315set TARGET = scanner.exe
1416
17+ :: Clean old build files
18+ if exist " %BUILD_DIR% " rmdir /s /q " %BUILD_DIR% "
19+ if exist " %TARGET% " del " %TARGET% "
20+ mkdir " %BUILD_DIR% "
21+
1522:: Create necessary directories if they don't exist
1623if not exist " %BUILD_DIR% " mkdir " %BUILD_DIR% "
1724if not exist " %OUTPUT_DIR% " mkdir " %OUTPUT_DIR% "
@@ -21,6 +28,10 @@ echo Compiling source files...
2128for %%f in (%SRC_DIR% \*.cpp) do (
2229 echo Compiling %%f ...
2330 %CXX% %CXXFLAGS% -c %%f -o " %BUILD_DIR% \%%~nf .o"
31+ if errorlevel 1 (
32+ echo Failed to compile %%f .
33+ exit /b 1
34+ )
2435)
2536
2637:: Link object files into the target executable
@@ -29,7 +40,8 @@ set OBJS=
2940for %%f in (%BUILD_DIR% \*.o) do (
3041 set OBJS = !OBJS! %%f
3142)
32- %CXX% %CXXFLAGS% -o %TARGET% %OBJS%
43+ echo Object files: !OBJS!
44+ %CXX% %CXXFLAGS% -static -static-libgcc -static-libstdc++ -o %TARGET% !OBJS!
3345
3446if errorlevel 1 (
3547 echo Build failed.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments