Does it make any difference (dependencies/installed software etc.) when
gcc was installed before build-essential?
To be more specific, is it any difference between:
apt install gcc apt install build-essential
apt install build-essential
For the specific case of
build-essential from the Ubuntu repositories, there is only one difference: Explicitly installing
apt install gcc or
apt install gcc build-essential) marks it as manually installed. This means that using
apt autoremove after uninstalling
build-essential (and any other packages depending on
gcc) will not remove
gcc or any of its dependencies.
In the general case, nothing more can be definitely said about installing a dependency X first and then the dependent package Y. It's possible that X is one of many fulfilling the particular dependency, and installing Y directly could have caused another package to be installed instead of X.