As long as you know what -dev packages to install, along with the development tools. Heaven help you if the dependencies you need aren’t up-to-date enough to work, as then you have to build them from source, too. You might also want to put them in /usr/local (fortunately, most packages default to this when building from source) so as to not scribble over libraries that other existing packages depend on.
I’ve been down that rabbit hole before (and yes, I use Linux desktops as my daily drivers).
The problem gets worse when you use a distro that prizes stability (like RHEL-based, or Debian Stable). Getting an up-to-date Nextcloud instance running on CentOS 7 can be quite the chore.