From: Cristiano <cri...@br...> - 2004-06-30 22:50:15
|
This question may already been posted to list, put since a couldn't find the answear in the list archive, here it go: gcc now has on option -shared. If I use it I don't need to declare my functions with: extern __declspec(dllexport) right? I only need to declare my function as export and gcc -shared do the rest? -- ################################# # Cristiano Costa Neves # AQX Instrumentação. # Engenharia em Aquisição de Dados # Site: www.aqx.com.br # Email: in...@aq... # Fone: (48) 2107-2724 # Fax: (48) 333-3745 ################################# |
From: Greg C. <chi...@mi...> - 2004-07-01 14:49:04
|
Cristiano wrote: > gcc now has on option -shared. Yes, MinGW has supported '-shared' for several years. Always use it for creating DLLs. Whether to declare functions as import or export is a separate issue. > If I use it I don't need to declare my functions with: > extern __declspec(dllexport) > > right? You should be able to omit that and just use the automatic import options: search for things like --enable-auto-import --enable-runtime-pseudo-reloc That way is convenient and simple once you get it working. But it may be less robust than using __declspec attributes, for instance if you export data or function pointers--this may have been improved, but it definitely caused problems in the past. Personally, I prefer to use __declspec: although it seems laborious, it is more robust and works with more compilers other than gcc. > I only need to declare my function as export and gcc -shared do the rest? 'export' is a C++ keyword that means something else. If you want to explicitly declare that a function is to be exported or imported, then use __declspec(dllexport) or __declspec(dllimport). Or don't use those attributes at all, and use the automatic import options instead. If you would like to see some sample code, try this: http://www.mingw.org/MinGWiki/index.php/sample%20DLL |