Re: [Dev-C++] =?GB2312?B?tPC4tDogW0Rldi1DKytdIEhvdyB0byBidWlsZCBh?= =?GB2312?B?IERMTCB3aXRoIGRlZiBm
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Thomas O'H. <To...@Re...> - 2006-08-18 12:53:42
|
I have "yet" to be able to export my own functions when trying to use WinPCap SDK. I am not sure this will be enough, but maybe if someone can write an "Hello World" DLL using a UDF I can finally see the light? I just want to see it work from an external program: MyFunc(@cBuffer) If cBuffer return "Hello World" I will be a happy camper. I know there is something severely stupid I am overlooking. Now I just must determine if it is my working environment or I have an option set wrong. OK, laugh, but I just need to figure out what really stupid mistake I made. In WinPCap it "seemed" that exported functions had to be in a LIB file to work. That is the only way I could get them to work in their samples. I am not sure what I am asking for will relate to WinPCap or not, but if someone has a few minutes... >From what I see on both this list & the WinPCap list, exporting functions seems to be a major topic. So at least I can have some comfort.... I also appear to see a glimpse of maybe the key is that many use MS Visual Studio, MS .Net, and of course Dev-C++. IOW, so many environments it is easy to create the wrong environment. I guess the best way, "if" someone can do this for me, is to zip the project and sent it to me off list. That is unless anyone else really wants to see it too. Way Too Frustrated & Growing too old too fast, ~ Thomas O'Hare ~ President, RedTile, Inc. - DBA: RedTile Software Web, Wireless, Network, Database & Systems Software +1.407.295.9148 ; +49.8651.717950 ; http://www.RedTile.Com/ Operations Manager; Virtual FoxPro User Group To...@VF... ; http://www.VFUG.Org/ HongQuan.Zhang wrote: > Hi, Thomas: > In fact,you don't have to add a def file to the project made by > Dev-Cpp ,you can refer to the attachment ,which is a email Per Westermark > send out and this perfect mail help me to solve my problem! > Hope this can help you! > > HongQuan > > -----邮件原件----- > 发件人: dev...@li... > [mailto:dev...@li...] 代表 Thomas O'Hare > 发送时间: 2006年8月11日 21:38 > 收件人: dev...@li... > 抄送: Dev...@li... > 主题: Re: [Dev-C++] How to build a DLL with def file? > > Hong, et. al. > > I used the common way as described below. But I swear I get different > results as my project continues. > > I had added the DEF file to the Linker and all was OK. Then at some point I > had to remove the DEF from the Linker to compile. > > Either I overlooked something or something I am clueless about is going on. > > So, what is the "best" way to use a DEF file to export functions in > Dev-C++??? Not only a code sample but also where to list the file. > > I am sure it is just me but any help will be appreciated. I am burning up > way too much time on this. > > Thanks, > ~ Thomas O'Hare ~ > President, RedTile, Inc. - DBA: RedTile Software Web, Wireless, Network, > Database & Systems Software > +1.407.295.9148 ; +49.8651.717950 ; http://www.RedTile.Com/ > Operations Manager; Virtual FoxPro User Group To...@VF... ; > http://www.VFUG.Org/ > > > HongQuan.Zhang wrote: >> Hi,All: >> I create a dll project and I want to export some function such as >> void Test(); >> I add a def file like def file in MSVC,and of course I add a linker >> opiton "-def test.def" >> in project options->parameter->linker >> In the file Test.def,there are only several code as follow: >> >> ; test.def : Declares the module parameters for the DLL. >> >> LIBRARY "test" >> DESCRIPTION 'test Windows Dynamic Link Library' >> >> EXPORTS >> ; Explicit exports can go here >> Test >> >> >> When I compile the project and get some error: >> [Linker error] undefined reference to `Test' >> >> >> >> >> >> ---------------------------------------------------------------------- >> -- >> >> ---------------------------------------------------------------------- >> --- Using Tomcat but need to do more? Need to support web services, >> security? >> Get stuff done quickly with pre-integrated technology to make your job >> easier Download IBM WebSphere Application Server v.1.0.1 based on >> Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=1216 >> 42 >> >> >> ---------------------------------------------------------------------- >> -- >> >> _______________________________________________ >> Dev-cpp-users mailing list >> Dev...@li... >> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > ------------------------------------------------------------------------ > > Subject: > Re: [Dev-C++] ??: ??: How to build a DLL with def file? > From: > "Per Westermark" <pw...@ia...> > Date: > Wed, 9 Aug 2006 19:41:00 +0800 > To: > "HongQuan.Zhang" <hon...@i-...> > > To: > "HongQuan.Zhang" <hon...@i-...> > CC: > <Dev...@li...> > > > I do dynamic loading of libraries in my applications too using something > like the following for Win32 applications. Normally I hide a bit more of > the code in macros, to make it work with Linux too. > > #if BUILDING_DLL > #define DLLIMPORT __declspec(dllexport) > #else > #define DLLIMPORT __declspec(dllimport) > #endif > > extern "C" { > DLLIMPORT DWORD __cdecl GetObjectFactoryCount(); > DLLIMPORT bool __cdecl GetObjectFactory(DWORD n,ObjectFactoryInfo& info); > } > > hLib = LoadLibrary(pszName); > GetObjectFactoryCount = > (suitable cast)GetProcAddress(hLib,"GetObjectFactoryCount"); > GetObjectFactory = > (suitable cast)GetProcAddress(hLib,"GetObjectFactory"); > > /Per W > > On Wed, 9 Aug 2006, HongQuan.Zhang wrote: > >> Per Westermarki"1/4s( >> Thank you for answer my question. >> I don't want to use __declspec(dllexport),because this director > will output a function name with additional characters which are added by > compiler. >> Example: >> void Test(int a); >> maybe output like this "_test@4" >> I just want to output with name "Test" , So I can use LoadLibrary > and GetProcAddress to get the function address easily! >> That is,I need to load the dll and invoke the function dynamicly! >> >> In MSVC ,I can only need to do is provide a def file and write the > function name down and compile! >> Anyway,thanks again! >> >> >> >> Hongquan >> >> >> >> >> -----é,?a"??a*Z(Y"a"??----- >> a*?‘a"??a"^(o)^(o): Per Westermark [mailto:pw...@ia...] >> a*?‘éEUR??―?é―?: 2006a*^(1)?8?oe^9?―? 17:48 >> ?”?a"??a"^(o)^(o): HongQuan.Zhang >> ?S("éEUR?: Dev...@li... >> a"??é?~: Re: [Dev-C++] c,?”a*¤?: How to build a DLL with def filei"1/4Y" >> >> Note that in C++, the external name of functions are mangled. Extra digits > and characters are added to the name to distinguish type information. This > is needed since C++ allows multiple functions with the same name but with > different signatures. For example: >> int Test() { return 0} >> int Test(int a) { return a; } >> int Test(int a,int b) { return a+b; } >> int Test(const char* s) { return strlen(s); } ... >> >> If you use a file to specify exported symbols, you have to specify the > fully mangled name. >> Or, you have to declare the function as type "C", to avoid the name > manging. The function will then just get an initial underscore in it's > external name - _Test. >> When developing on Windows systems, it is quite common to use the M$ >> extension: >> __declspec(dllexport) >> before name of exported symbols directly in the source code. >> >> The linker will then be able to extract the information about all exported > symbols automatically, without the need of the def file. >> You might have code: >> >> __declspec(dllexport) int my_variable; >> __declspec(dllexport) int Test() { return 0; } ... >> >> Normally the dll declaration is hidden in a #define, to make the code > compatible with compilers/environments that doesn't support DLL files. >> #define __declspec(dllexport) EXPORT >> >> EXPORT int my_variable; >> EXPORT int Test() { return 0; } >> >> >> In the same way, code that needs to access a function or variable defined > in a DLL may use __declspec(dllimport) instead. >> /Per W >> >> On Wed, 9 Aug 2006, HongQuan.Zhang wrote: >> >>> I am sorry that I haven't finish the post before I send it! >>> the original message is at below. >>> And I just want to know how to code the def file,or how to build a dll >>> with specify export function name! >>> Thanks a lot! >>> >>> Hongquan >>> >>> -----A~“A~S(A^1/4A~3/4A~”A^?A^1/4A~3/4----- >>> A^・A^?A^1/4A~3/4A~^A~<: HongQuan.Zhang [mailto:hon...@i-...] >>> A^・A^?A~<A~?A~S(A^±A^1/4A~¤: 2006A~"A~^(a)8A~”A~,9A~^A~. 17:16 >>> A~S(A~.A^1/4A~3/4A~^A~<: 'Dev...@li...' >>> A~A~・A~OEA~?: How to build a DLL with def fileA^?A^? >>> >>> HiA^?A^?All: >>> I create a dll project and I want to export some function such as >>> void Test(); >>> I add a def file like def file in MSVC,and of course I add a linker >>> opiton "-def test.def" >>> in project options->parameter->linker >>> In the file Test.def,there are only several code as follow: >>> >>> ; test.def : Declares the module parameters for the DLL. >>> >>> LIBRARY "test" >>> DESCRIPTION 'test Windows Dynamic Link Library' >>> >>> EXPORTS >>> ; Explicit exports can go here >>> Test >>> >>> >>> When I compile the project and get some error: >>> [Linker error] undefined reference to `Test' >>> >>> >>> >>> >> >> >> >> ------------------------------------------------------------------------- >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job > easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Dev-cpp-users mailing list >> Dev...@li... >> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > > ------------------------------------------------------------------------ > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |