0

I am creating a batch file to automatically build my files but for some reason g++ cant actually get the files. What am I doing wrong?

Output:

g++: fatal error: no input files compilation terminated.

batch script:

@ECHO OFF

SET "build_type=O0"

SET "build_location=bin"

SET "app_name=learning_g++"
REM These for loops should be getting all the .cpp files in src but its not working for some reason
SET c_files=
FOR /R %%f in (%CD%\src\*.cpp) do (
    SET c_files="%c_files%" %%f
)

SET h_files=
FOR /R  %%f in (%CD%\src\*.h) do (
    SET h_files=%h_files% %%f
)

SET lib_h_files=
FOR /R  %%f in (%CD%\include\headers\*.h) do (
    SET lib_h_files=%lib_h_files% %%f
)

SET lib_files=
FOR /R  %%f in (%CD%\include\libs\*.a) do (
    SET lib_files=%lib_files% %%f
)

REM Builds the files using g++
CALL g++ %c_files% -I%h_files% -I%lib_h_files% -L%lib_files% -%build_type% -o %build_location%/%build_type%/%app_name%.exe
ECHO "BUILT FILES!"

REM Starts the executable that is generated from the g++ command
ECHO "STARTING APPLICATION"
START %build_location%/%build_type%/%app_name%.exe

PAUSE
Funny Dude
  • 11
  • 1
  • 2
    Does this answer your question? [Variables are not behaving as expected](https://stackoverflow.com/questions/30282784/variables-are-not-behaving-as-expected) Specifically, after you enable delayed expansion, when you're appending values in the `for` loops, you need to use `set "c_files=!c_files! %%f"`, `set "h_files=!h_files! %%f"`, etc. – SomethingDark Jan 18 '22 at 03:55

0 Answers0