Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: gregwarner on September 09, 2011, 07:40:14 pm

Title: Linking to DLL's
Post by: gregwarner on September 09, 2011, 07:40:14 pm
Feeling really dumb... How do I link my project to a Windows DLL? (C:\Windows\System32\wiaaut.dll specifically.) I'm at the Linker Settings and I'm trying to add a Link library, but the dialog box only filters file type extensions of .a, .so, .lib, .dylib, and .bundle. How do I choose a DLL?

I have zero experience using Code::Blocks and this is my first time migrating to this IDE.
Title: Re: Linking to DLL's
Post by: zabzonk on September 09, 2011, 08:24:02 pm
You can't link to a DLL directly - you need an import library (a  .LIB file) for it. If you haven't got one, you have to load the functions you want dynamically using LoadLibrary and GetProcAddress. This has nothing specifically to do with Code::Blocks, it's how the Windows linking process works.

Title: Re: Linking to DLL's
Post by: gregwarner on September 09, 2011, 08:46:18 pm
Ah. Thank you for clearing that up.

I don't suppose you know where I could find a good tutorial on how to do that, do you?
Title: Re: Linking to DLL's
Post by: stahta01 on September 09, 2011, 08:49:26 pm
FYI:

The answer to your question depends on your Compiler.

NOTE: MinGW GCC can link directly to an DLL.

Tim S.
Title: Re: Linking to DLL's
Post by: gregwarner on September 09, 2011, 08:56:52 pm
I'm using the GNU GCC Compiler.

EDIT: I just read that GCC doesn't directly support Microsoft DLL's, so I just downloaded and installed MinGW.

I'm still a little fuzzy on what I need to do next. I know I need to generate an import library if I don't already have one, but where do I check if there already exists an import library for wiaaut.dll?
Title: Re: Linking to DLL's
Post by: zabzonk on September 09, 2011, 11:20:30 pm
> NOTE: MinGW GCC can link directly to an DLL.

Saying something "can" do something without providing any idea how is particularly useless.
Title: Re: Linking to DLL's
Post by: stahta01 on September 09, 2011, 11:43:59 pm
> NOTE: MinGW GCC can link directly to an DLL.

Saying something "can" do something without providing any idea how is particularly useless.


FYI: There is this thing called Google.

Note: It is also mentioned in this site many times and there is an example linking to the codeblocks dll in the wiki.

Tim S.
Title: Re: Linking to DLL's
Post by: zabzonk on September 10, 2011, 12:09:30 am
I did Google for it and couldn't find anything. But as you obviously know so  many links on to how to do this, would it be asking too much for you to actually post one?
Title: Re: Linking to DLL's
Post by: stahta01 on September 10, 2011, 12:26:09 am
http://wiki.codeblocks.org/index.php?title=Linking_the_plugin_to_a_Nightly_Build

http://www.mingw.org/wiki/sampleDLL

Tim S.