Control Linux dynamic link library export Function
In Linux, we can control the export function through-fvisibility = default | internal | hidden | protected.
The GCC help document-fvisibility = default | internal | hidden | protected has the following description:
A superior solution made possible by this option to marking things hidden when the default is public is to make the default hidden and mark things public. this is the norm with DLL's on Windows and with-fvisibility = hidden and "_ attribute _ (visibility (" default "))) "instead of" _ declspec (dllexport) "You get almost identical semantics with identical syntax. this is a great boon to those working with cross-platform projects.
In Linux, all functions in the source file have a default visibility attribute, that is, public. Add the-fvisibility = hidden parameter to the compilation command, changes all default public attributes to hidden. In this case, if the _ attribute _ (visibility ("default") parameter is set for the function, the specific function is still processed according to the default public attribute, the-fvisibility = hidden parameter does not work for this function. Therefore, after the-fvisibility = hidden parameter is set, only functions with _ attribute _ (visibility ("default") are visible.