Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Dr.Optix on May 16, 2009, 11:44:23 am

Title: Use custom .DEF
Post by: Dr.Optix on May 16, 2009, 11:44:23 am
Since I moved to CodeBlocks from Visual C++ I tryed to use custom .DEF files when i create DLLs for my apps. I want to export my functions using custom .DEF because with plain text names exported is easyer to write let's say C# wrappers for my DLL than when the DLL use mangled names.

for example if i have this C/C++ file
Code
--- other code ---

class TTest
{
private:
    m_Val;
public:

    TTest(int x);
    virtual ~TTest();

    void ShowVal();
};


#ifdef __cplusplus
extern "C"
{
#endif

TTest * CreateTest(int x);
void DeleteTest(TTest * TestToDelete);
void ShowTestValue();

#ifdef __cplusplus
}
#endif

--- other code ---

and I want to use my .DEF
Code
LIBRARY "TheDLL"
EXPORTS
     CreateTest
     DeleteTest
     ShowTestValue

Hope you understand what I'm looking for

~Dr.Optix

PS: I know/feel that C::B don't want to be a Visual Studio clone and it more wants to be a competitor but in Visual Studio when you add a .DEF file tothe DLL project it automatically use it
Title: Re: Use custom .DEF
Post by: Jenna on May 16, 2009, 12:28:22 pm
You can create the sample dll-project with the wizard and see how it is done there.

I am not sure if this works for other compilers than gcc, if not I think the best way is to use your favourite search-engine and/or the documentation of your compiler/linker.
Title: Re: Use custom .DEF
Post by: Dr.Optix on May 16, 2009, 12:39:20 pm
actually i found found that mingw contains dlltool.exe

This utility can take a .DEF file as input, now I study how to use this tool.

I will research further and maybe this tool can be used as a pre or post build command. I'll come with updates

~Dr.Optix

Title: Re: Use custom .DEF
Post by: Jenna on May 16, 2009, 12:50:53 pm
If you create your own dll's you can create the .def-file at compile or better link-time.

Just have a look at the wizard-created sample (don't forget to inspect the project's properties), it's quite easy and C::B creates the correct commandline to do what you want.