There are many many guides for cross compiling and everyone does it slightly different.
Simplest one: https://hackaday.com/2016/02/03/code-cr ... pberry-pi/
But this does not give you access to any Raspbian libraries/header, only standard C/C++, but installs compilers from repo.
Another example here: https://mechatronicsblog.com/cross-comp ... pberry-pi/
You should only focus on step 3 (toolchain) and 4 (libraries) and you need to understand the link between step 1 and 4.
This guide prefers to just download the tools into a folder instead of installing packages, so you have to tell your IDE or makefile system to use those tools there instead of the system compilers. And you need to tell the compiler to use the Raspbian libraries in the "sysroot".
There are also ways of creating the sysroot from a Raspbian imagefile instead of copying it from a running Pi.