I have been using Fedora for 3 years, but I still get confused about how the installation of a package works. For example, what is the relationship between package and package-devel? In what cases should I install both package and package-devel?
In many cases where I could not get the package working, I just need to install package-devel and then the problem is gone. If someone told me this when I first started using Fedora, my life would have been much easier.
Most times you just need Package. Package-devel becomes necessary when you are compiling another code that uses parts of Package.
Here is a crude example:
Lets say you want to install an App called ‘Bobo’ (you know I am kidding, right?). You discover that Bobo is not provided as a package (rpm) in the repository but you have access to its source-code (perhaps from git, or mecurial). So, You decide to compile Bobo so that you can use it on your machine. However, the developers of Bobo included bits of another software project while developing Bobo … and the other App or project is ‘Moss’ (this is just another name I cooked up).
Let’s assume that Moss is already in the repository. Your compiler will be needing Moss-devel to compile Bobo instead. Why? Moss-devel contains the development headers referenced by Bobo(remember that the developers used bits of Moss – so they used the headers from Moss). Usually when you install Moss-devel, it pulls in Moss (the rest of it) as well.
So you find that often when you install a package like OpenImageIO-devel, … OpenImageIO will also install with it.
I am not sure I explained this well … I am willing to try another approach but did this even make any sense?
You explained it pretty well, but to simplify things.
Usually when a package needs additional files the package manager (dnf, yum, etc) knows the dependencies required to work properly and if you do for example
dnf install example-package
it will also install any needed dependencies and the newly installed package will just work.
OTOH, if you are compiling the package from source it is almost certain that you need the package-devel installed so you have the needed header and source code files before the compile will complete successfully.
An example when other package-devel files are needed is installing/compiling kernel modules which requires the kernel-devel package as well as the module -src and -devel packages.
I use an NVIDIA video and to keep up to date with the drivers, each time the kernel is updated the video driver has to be updated to match. I have the akmod-nvidia package installed which will automatically recompile the nvidia driver with each kernel update but that requires the kernel-devel package to support the recompile.
Each package may have different requirements, but usually if you install from the official repo the package manager will handle everything for you.