User forums > Using Code::Blocks

Use custom .DEF

(1/1)

Dr.Optix:
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 ---

--- End code ---

and I want to use my .DEF

--- Code: ---LIBRARY "TheDLL"
EXPORTS
     CreateTest
     DeleteTest
     ShowTestValue

--- End code ---

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

Jenna:
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.

Dr.Optix:
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

Jenna:
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.

Navigation

[0] Message Index

Go to full version