So I have managed to solve my issue with a help of another fellow in a Discord server, and I'm going to post the solution here to make the life of people in the future easier.
This guide is for Windows, and it was made mostly because there aren't any resources on how to build this stuff on Windows.
Step 1:
Clone both repositories to their default state. (gumbo-parser for C, gumbo-query for C++)
Important!
Make sure that both repositories are located in the same directory, as this tutorial assumes that the repositories' names are not changed and that they are located together in the same directory.
E.g. the following directory is a plausible location for each repository to reside.
C:\C++\gumbo_parser
C:\C++\gumbo_query
Step 2:
Copy this build script into the gumbo-parser\src
directory:
@echo off
cls
REM Build Script
REM Set Compiler Settings Here
set GCC=gcc
set AR=ar
set OUTPUT=libgumbo_parser.a
set DEBUGMODE=0
set REBUILD_LIBRARIES=0
set LINK_ONLY=0
set VERBOSE=0
set ASYNC_BUILD=1
set C_COMPILER_FLAGS=-std=c99 -Wall
set ADDITIONAL_LIBRARIES=
set ADDITIONAL_LIBDIRS=
set ADDITIONAL_INCLUDEDIRS=-I.
del %OUTPUT% 2>nul
setlocal enabledelayedexpansion
if %LINK_ONLY% GTR 0 (
goto linker
)
if %DEBUGMODE% GTR 0 (
set DEBUG_INFO=-g
) else (
set DEBUG_INFO=
)
if %ASYNC_BUILD% GTR 0 (
set WAIT=
) else (
set WAIT=/WAIT
)
if %REBUILD_LIBRARIES% GTR 0 (
del /S /Q "*.o" 2>nul
)
echo Building C Libraries...
for %%F in (*.c) do (
if not exist %%~nF.o (
echo Building %%~nF.o
start /B %WAIT% "%%~nF.o" %GCC% %ADDITIONAL_INCLUDEDIRS% %C_COMPILER_FLAGS% %DEBUG_INFO% -c %%F -o %%~nF.o
if %VERBOSE% GTR 0 (
echo %GCC% %ADDITIONAL_INCLUDEDIRS% %C_COMPILER_FLAGS% %DEBUG_INFO% -c %%F -o %%~nF.o
)
)
)
REM Wait for building process to finish
:loop
set /a count=0
for /f %%G in ('tasklist ^| find /c "%GCC%"') do ( set /A count=%count%+%%G )
if %count%==0 (
goto linker
) else (
timeout /t 2 /nobreak>nul
goto loop
)
:linker
set "files="
for /f "delims=" %%A in ('dir /b /a-d "*.o" ') do set "files=!files! %%A"
:link
echo Linking Executable...
if %VERBOSE% GTR 0 (
echo %AR% ru %OUTPUT% %files%
)
%AR% ru %OUTPUT% %files%
:finish
if exist .\%OUTPUT% (
echo Build Success!
) else (
echo Build Failed!
)
You'll need to make sure you're C compiler (MinGW) bin
directory is configured in your PATH environment; otherwise, configure the build script and set AR and GCC to the exact path where gcc is located.
E.g.
set GCC=E:\Programs\Qt\Tools\mingw810_64\bin\gcc
set AR=E:\Programs\Qt\Tools\mingw810_64\bin\ar
You will also want to run this script in a Windows CMD window, with elevated rights. It didn't work for me otherwise.
This will create a static library of gumbo parser.
Step 3:
Configure CMake for gumbo query.
Primarily, make sure the following variables are set when configuring gumbo_query:
Gumbo_INCLUDE_DIR <path-to-gumbo-parser>/src
Gumbo_LIBRARY <path-to-gumbo-parser>/src/libgumbo_parser.a
Gumbo_static_LIBRARY
This should already be set, but just in case make sure your C and C++ compilers are set correctly:
CMAKE_C_COMPILER <path-to-mingw>\bin\gcc.exe
CMAKE_CXX_COMPILER <path-to-mingw>\bin\g++.exe
CMAKE_CXX_COMPILER_AR <path-to-mingw>\bin\gcc-ar.exe
As well as the CMake program (you have to tick advanced for this):
CMAKE_MAKE_RPOGRAM <path-to-mingw>\bin\mingw32-make.exe
Make sure you're configuring the correct directory.
Set the build location to the build folder located in gumbo-query.


Step 4: Generate and run CMake.
CMake should be located in your MinGW bin folder
cd
to your gumbo-query/build
directory.
Then, run mingw32-make
to build the target libraries.
Once completed, you'll have both a dynamic and static library of gumbo query.
Where to find your build files and helpful directories:
Gumbo Query DLL gumbo-query\build\src\libgq.dll
Gumbo Query Static Library gumbo-query\lib\libgq.a
Gumbo Query DLL Import Library gumbo-query\lib\libgq.dll.a
Gumbo Parser Static Library gumbo-parser\src\libgumbo_parser.a
Gumbo Parser Header Files gumbo-parser\src
Step 5 (Optional): running example
To compile the example application found in gumbo-query, cd into the example directory and run the following commands:
g++ -c main.cpp -I..\src -I..\..\gumbo-parser\src
g++ -o test.exe main.o -L..\lib -L..\..\gumbo-parser\src -static -lgq -lgumbo_parser
Run: ./test
to test the final application.