Some one told me that if you want to export a library you need use __declspec(dllexport)
, and when someone uses the library he or she needs to add __declspec(dllimport)
. But today I found that it is not necessary.
For what reason do we need a __declspec(dllimport)
?
From the documentation:
Using
__declspec(dllimport)
is optional on function declarations, but the compiler produces more efficient code if you use this keyword. However, you must use__declspec(dllimport)
for the importing executable to access the DLL's public data symbols and objects. Note that the users of your DLL still need to link with an import library.