Compiler options for DLL

General questions regarding the usage of CodeLite
Fred
CodeLite Enthusiast
Posts: 43
Joined: Mon Jul 02, 2012 12:53 pm
Genuine User: Yes
IDE Question: C++
Contact:

Compiler options for DLL

Post by Fred »

Hello,
I want to create a dll and its def file using as Compiler Options in the project stettings:

Code: Select all

-shared;-s;-Wl,--subsystem,windows,--output-def,testDll.def
The dll is created, but not the def file.

After this, I need a second run to remove the exports decorations with

Code: Select all

-shared;-s;-Wl,--subsystem,windows,--kill-at
The decorations are not removed.

Please give me advise how to pass these options correctly.

Another question is, how to perform the second run with the different option after the first without changing the options manually every time.

Changing the options does not force CodeLite to do a new linking, because the sources are unchanged.
How can I force a new run without changing the source?

Thank you,
Fred
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Compiler options for DLL

Post by Jarod42 »

First,
there is a linker options where you can add your options instead of using -Wl option.

Secondly, it seems strange to link in two passes. (def file won't be coherent with dll).
maybe use something like --add-stdcall-alias ?

Third, you can use PostBuildEvent if necessary.
Fred
CodeLite Enthusiast
Posts: 43
Joined: Mon Jul 02, 2012 12:53 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Compiler options for DLL

Post by Fred »

Thank you for your reply!

I want to create a dll with undecorated stdcall functions for compatibility with other programming languages.
CodeLite and MinGW are new for me.
First,
there is a linker options where you can add your options instead of using -Wl option.
Yes, this is my first problem. If this is the compiler command:

Code: Select all

g++ -o xxxx.dll xxx.o -shared -s -Wl,--subsystem,windows,--output-def,xxxx.def
what must I use as CodeLite linker option?
I tried several possibilities and always got an error message, that the option is unrecognized or "no such file or directory".
Secondly, it seems strange to link in two passes. (def file won't be coherent with dll).
maybe use something like --add-stdcall-alias ?
I tried --add-stdcall-alias, and got error message "unrecognized option". How to use it with CodeLite linker options?
This processing really is strange, but I do not know another way to create a dll and an import lib with undecorated stdcall functions with MinGW using CodeLite.
If you know, please tell me.
The second step (create an undecorated function dll) I found, was:

Code: Select all

g++ -o xxxx.dll xxx.o -shared -s -Wl,--subsystem,windows,--kill-at
Third, you can use PostBuildEvent if necessary.
Actually there is a third step to create the import library, so I'll have to do this anyway.
I found on the web:

Code: Select all

dlltool --kill-at -d xxxx.def -D xxxx.dll -l libxxxx.a
But for the moment I would be happy, if I could set the correct linker options.

Regards,
Fred
Fred
CodeLite Enthusiast
Posts: 43
Joined: Mon Jul 02, 2012 12:53 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Compiler options for DLL

Post by Fred »

Hello,

I managed to create a dll with the --add-stdcall-alias linker option now, and used it with BCC5, MSVC2008, and MinGW.
This CodeLite linker option worked for me:

Code: Select all

-s;-Wl,--subsystem,windows,--add-stdcall-alias
It's not passed to the linker, if it is in the CodeLite compiler options.

Thanks, Jarod. This is much easier to use than a dll without any function decorations.
Only for MSVC I needed a def file, MinGW even links it without a lib file.

If someone is interested in the details for using the dll with BCC or MSVC, I can post it here.

Regards,
Fred
Post Reply