--- Quote Start ---
You need first to make a distinction between vendor library and user library.
And in the case of vendor library you need to make distinction between HDL based files in folders named library and precompiled library.
For example if you look around you will see a folder named ieee that contains vhdl code. This is not what quartus or Modelsim will look at. Instead Quartus looks at precompiled version of it which - I believe - is done as part of installation and it knows where they are(not visible to user).
On the other hand ModelSim gives(or may) visibility and choice to where it is to be precompiled to and there you see some strange files with extensions like .dat, .dbs ..etc. I don't need to know what these do and I view them as precompiled intermediate products for final netlist with your code.
For user library in quartus you can just add it to project as any other vhdl module or apply use statements to specify target.
--- Quote End ---
Thanks very much, kaz. So the libraries are used in simulation are vendor libraries, and I think they are originally HDL files, but they need to be compiled before used.
What are libraries used in VHDL file? Like IEEE library, I think they are vendor libraries too.
The user libraries are created by ourselves, but I don't know when I need it.
For Vendor libraries, yes, I don't need to know what exactly they are after they are compiled. But I am curious is: what are they as HDL files? Are they just HDL design files for IP (modules in Verilog, entity in VHDL) wrote by vendors like the design files we wrote? Do we need them both in synthesis and simulation?
Thanks very much.