User forums > Using Code::Blocks

Include dll into C++ project

(1/3) > >>

gtafan:
How can I include a dll into my C++ prject in Code::Blocks? I have the .h, .dll and the other file, but what i have to do in
Code::Blocks, so can use al the stuff from the .h file?

stahta01:
Do you know what a compiler is?

If yes, lookup the directions for your compiler.

You can sometimes link to an DLL; but, the rules very by compiler and DLL.

Tim S.

gtafan:

--- Quote from: stahta01 on November 28, 2018, 08:08:34 am ---Do you know what a compiler is?

If yes, lookup the directions for your compiler.

You can sometimes link to an DLL; but, the rules very by compiler and DLL.

Tim S.

--- End quote ---
Not shure about your first question, what you exactly mean, but compiler is the thing turning my sorce code into executable machine code, how exactly it´s done I don´t care. I am really not going to do that stuf manualy. The reason I am using an IDE like Code::Blocks is because I don´t want to do the most programming related stuff manually.
Posibly I just misunderstood your question and you wanted to know if the dll was compiled with the same compiler, as the one I use. If this was your question, I have no idea which compiler was used for that dll.

oBFusCATed:
His remark is related to the fact that some compilers (linkers to be exact) aren't able to link when a dll is given on the command line. They need special import libraries.
So his suggestion is useful, because if you have no idea about the capabilities of your compiler you're going to suffer a lot and you'll have to always ask for help at random forums and possibly be ignored.

If you're using a mingw based compiler and the dll is compatible with your compiler, just add the dll to the list of linked libraries, adjust the search paths and you should be able to link it.
If it doesn't work. Post full rebuild log, but first read compiler/linkers manual how it is supposed to work in your case.

Probably reading this first might help: http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_What_do_I_need_to_know_when_using_3rd_party_libs.3F

Also keep in mind that IDEs save time if you know what you're doing. If you expect to click buttons at random and get the result you're after - you'll be disappointed and you'll suffer a lot.

BlueHazzard:
Additionally keep in mind if you use a c++ dynamic library you will have a bad time if you do not use the same compiler as the dll (compiler vendor and compiler version (or to be more speciffic the ABI has to be the same)). With c dll you will have more luck.
MSVC compiled dlls are not compatible with mingw gcc without some conversation. You find the instruction in google.
If you use a gcc compiled dll you probably will have a .lib file or a .a file and you simply add them to the Project->Build options->Select the project on the left->Linker->libraries...

Navigation

[0] Message Index

[#] Next page

Go to full version