User forums > Using Code::Blocks
How to make .dll build with .def file in cb?
manceb:
I'm the new one in cb from vs2010.The cb svn I have been using is 10050.Everything is fine except I can't use .def file to define a .dll file.
I have read all of the topics carefully about this problem,such as (http://forums.codeblocks.org/index.php/topic,14812.msg99253.html#msg99253
http://forums.codeblocks.org/index.php/topic,10559.msg72397.html#msg72397
http://forums.codeblocks.org/index.php/topic,14285.msg96045.html#msg96045
http://forums.codeblocks.org/index.php/topic,8236.msg61186.html#msg61186
http://forums.codeblocks.org/index.php/topic,8967.msg64716.html#msg64716
http://forums.codeblocks.org/index.php/topic,10882.msg74368.html#msg74368
http://forums.codeblocks.org/index.php/topic,2616.msg20703.html#msg20703
).But they did not solve my problem.so thanks to someone to tell me How to configure C::B to use DEF file when creating DLL?
test code :
main.cpp:
--- Code: ---int __stdcall Add(int numa, int numb)
{
return (numa + numb);
}
int __stdcall Sub(int numa, int numb)
{
return (numa - numb);
}
--- End code ---
main.def
--- Code: ---
LIBRARY test
EXPORTS
Add @ 1
Sub @ 2
--- End code ---
the project options
the other linker options and errors.
I'd appreciate any reply
BlueHazzard:
I'm not familiar with def files, but it is in general better to post the content of the "Build Log" window instead of the "Build messages" window. in Build log are showed more information. And it is also better to post the content in code tags (# symbol in the forum editor), instead of pictures.
And as far as i know, you don't need any .def file with the gcc compiler. You need the .def file only with msvc compiler, but you are using the gcc to compiler your program...
greetings
manceb:
thank you for you replay,the bulid log as follow.
because the dll wich used in some program must use __stdall and .def
as you see ,so can anyone help me to use cb to create the dll with .def file?
thank you.
BlueHazzard:
As you can clearly see in the output the option "--def" is not supported by gcc...
are you ever planing to go back to msvc?
if not, why are you using def files and not simply use "__declspec(dllexport)" in your source? (http://stackoverflow.com/a/21902439)
i don't know any option for gcc to use def files, and this is also no gcc support forum. It is a c::b support forum, so if you find a option to use def files with gcc and want to know how to use it with c::b then we can help you better...
PS.: i searched a bit and according some sites you need to use a thirparty tool to use def files with gcc: http://www.boyunjian.com/do/article/snapshot.do?uid=1013034473452214461
so you need a post build step to make your dlls. You can make a post build step in Project->Build Options ->Pre/Post build steps->Post build step.
The Variables you can use in this post build steps are described here: http://wiki.codeblocks.org/index.php?title=Variable_expansion
so you need a postbuild line like this (no waranty, i can't test it, because no windows, and also not a expert with this kind of sorcery )
--- Code: ---dllwrap -o $(TARGET_OUTPUT_BASENAME).dll --driver-name c++ --def DEF_FILE $(TARGET_OBJECT_DIR)\$(TARGET_OUTPUT_BASENAME).o $(TARGET_OUTPUT_FILE) -Wl,--enable-stdcall-fixup
--- End code ---
stahta01:
Edit: Looks like my post is NOT needed by OP; I should have read the whole thread before posting.
Creating the def was NOT the problem; using it was. I never used one because most of the time it is never needed.
IIRC, def is in the Project -> Property menu.
Tab: "Build Targets"
Under "selected build target options"
Type: Needs set to an option that support .def file. DLL does.
Checkmark: Create def export file.
Adjust "Def. file filename"
Tim S.
Navigation
[0] Message Index
[#] Next page
Go to full version