News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Linking to DLL's

Started by gregwarner, September 09, 2011, 07:40:14 PM

Previous topic - Next topic

gregwarner

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.

zabzonk

#1
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.


gregwarner

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?

stahta01

FYI:

The answer to your question depends on your Compiler.

NOTE: MinGW GCC can link directly to an DLL.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

gregwarner

#4
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?

zabzonk

> NOTE: MinGW GCC can link directly to an DLL.

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

stahta01

Quote from: Neil Butterworth 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.


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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

zabzonk

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?

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]