I didn't find any proper tutorials on installing this library. The closest I got was:
- Build
gumbo-parserusing the instructions in the readme (Linux) - Build
gumbo-queryusing the instructions in the readme (Linux) - Copy the lib folder to my windows machine
- Add these lines to my CMake file:
set(CMAKE_PREFIX_PATH "E:/Programs/gumbo-query")
include_directories("E:/Programs/gumbo-query/src")
set(LIBS ${LIBS} "E:/Programs/gumbo-query/src/lib")
But the problem is that when I try to include Document.h, it says gumbo.h: no such file or directory.
How would I solve this issue? Am I approaching this completely the wrong way?
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_parserC:\C++\gumbo_queryStep 2:
Copy this build script into the
gumbo-parser\srcdirectory:You'll need to make sure you're C compiler (MinGW)
bindirectory 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.
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>/srcGumbo_LIBRARY
<path-to-gumbo-parser>/src/libgumbo_parser.aGumbo_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.exeCMAKE_CXX_COMPILER
<path-to-mingw>\bin\g++.exeCMAKE_CXX_COMPILER_AR
<path-to-mingw>\bin\gcc-ar.exeAs well as the CMake program (you have to tick advanced for this): CMAKE_MAKE_RPOGRAM
<path-to-mingw>\bin\mingw32-make.exeMake 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
cdto yourgumbo-query/builddirectory. Then, runmingw32-maketo 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.dllGumbo Query Static Librarygumbo-query\lib\libgq.aGumbo Query DLL Import Librarygumbo-query\lib\libgq.dll.aGumbo Parser Static Librarygumbo-parser\src\libgumbo_parser.aGumbo Parser Header Filesgumbo-parser\srcStep 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\srcg++ -o test.exe main.o -L..\lib -L..\..\gumbo-parser\src -static -lgq -lgumbo_parserRun:
./testto test the final application.