Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: BigAngryDog on March 13, 2006, 10:04:35 am

Title: Using DEF Files with DLL Creation
Post by: BigAngryDog on March 13, 2006, 10:04:35 am
How does one link in a def file when creating a DLL?

Currently, my def file doesn't seem to have any effect. I particularly want to use it to remove function name decoration.

For example:

Code
LIBRARY test.dll

EXPORTS
    get_url = get_url@12
    get_urlW = get_urlW@12

Any help appreciated. :)
Title: Re: Using DEF Files with DLL Creation
Post by: Michael on March 13, 2006, 10:44:45 am
Hello,

It would be useful if you say which compiler you are using and which C::B version :). Anyway, this link (http://www.emmestech.com/colin_peters_tutorial/dll/make.html) could be useful.

Best wishes,
Michael
Title: Re: Using DEF Files with DLL Creation
Post by: BigAngryDog on March 13, 2006, 10:58:50 am
Version 1.0 RC2.

Thanks for the reply. However, it doesn't seem that the link has the info I need. It talks of a "dlltool" for creating import libraries. However, it isn't an import library I need. I specifically want to remove the name decoration with the __stdcall calling convention.

I understand that I can do it by adding aliases to a def file. So that:

get_url = get_url@12

But how do I "link in" the def file so that the aliases appear in the export table of the DLL?

I'm not an expert with MingGW from the command line. Is there any way I can add the option to C::B?
Title: Re: Using DEF Files with DLL Creation
Post by: mandrav on March 13, 2006, 11:26:04 am
Try adding the following in your target's other linker options:

--def test.def
EDIT: if the above doesn't work, try -Wl,--def=test.def

(replacing "test.def" with your def's filename)
Title: Re: Using DEF Files with DLL Creation
Post by: Michael on March 13, 2006, 11:34:58 am
Version 1.0 RC2.

You would might be give a try to a nightly build :).

Thanks for the reply. However, it doesn't seem that the link has the info I need. It talks of a "dlltool" for creating import libraries. However, it isn't an import library I need. I specifically want to remove the name decoration with the __stdcall calling convention.

I understand that I can do it by adding aliases to a def file. So that:

get_url = get_url@12

But how do I "link in" the def file so that the aliases appear in the export table of the DLL?

I'm not an expert with MingGW from the command line. Is there any way I can add the option to C::B?

I am not an expert too, but may be this link (http://www.emmestech.com/colin_peters_tutorial/tools/dlltool.html) could help.

Best wishes,
Michael
Title: Re: Using DEF Files with DLL Creation
Post by: BigAngryDog on March 14, 2006, 12:58:19 am
>You would might be give a try to a nightly build

I just have. Thanks!


>Try adding the following in your target's other linker options:

>--def test.def
>EDIT: if the above doesn't work, try -Wl,--def=test.def

Will do. Thanks!
Title: Re: Using DEF Files with DLL Creation
Post by: BigAngryDog on March 14, 2006, 03:29:41 am
>--def test.def
>EDIT: if the above doesn't work, try -Wl,--def=test.def

Didn't work, but helped me know what sort of thing to look for. Thanks.

So for anyone else looking to build a dll using the __stdcall (WINAPI) calling convention, without the name decoration MinGW (GCC) adds, then put this in CodeBlocks' "Other Linker Options":

Code
-Wl,--kill-at
Title: Re: Using DEF Files with DLL Creation
Post by: grandzebu on May 22, 2006, 03:51:49 pm
What a very goog information : -Wl,--kill-at is THE solution
Thank's a lot
GZ