User forums > Help
Using DLLs with CodeBlocks
rascalito:
Hello!
I'm a new user of CodeBlocks.
I have installed it an I'm using mingw64. Basically a hello world-ish program works,
debugger included.
Now I need to use a 3rd party DLL with some source code provided by the 3rd party.
Let's assume the dll is called my_dll and implements a function that I'll call "my_function"
(let's be creative!!). I have included my_dll.h.
The problem is that it doesn't compile or link. I get that kind of message:
undefined reference to __imp_my_function
Can anybody explain me how to use a DLL in CodeBlocks?
Thanks for any hint.
R.
Miguel Gimenez:
The DLL contains C or C++ code?.
In the former case, you can link with the .a file (if you have it) or directly with the DLL (goto Project options -> Linker settings and put my_dll.a on the left listbox or my_dll.dll on the right.
In the latter case you are doomed (except if the DLL was created with the same MINGW64 and options).
If you have more problems post a full rebuild log.
rascalito:
Hello!
Thanks for your reply!
No, I have only a .dll file.
By the way, some more info:
I'm using CodeBlocks 20.03, configured with MinGW64
-> By the way, when I set the compiler, there was no xxx64, but only xxx32 options, for example
c compiler: x86_64-w64-mingw32-gcc.exe // Why is it mingw32 and not 64???
--- Quote ---goto Project options -> Linker settings and put my_dll.a on the left listbox or my_dll.dll on the right.
--- End quote ---
Ok, let's be accurate, I'm an absolute beginner with CodeBlocks...
In this cersion, I don't have a Project options menu. I have a Project top menu, and under this project
menu, I have "Build options" and "properties".
I have opened Project -> Build options which sounds more correlated to what you suggested. Is this right?
In the config window -> Lineker settings tab, I have indeed 2 columns. I can put something on the left by
browsing to that file, but on the right column, I have to key in what I want to add (my_dll.dll). Does it
correspond to what's needed?
After keying in, I retried to compile everything (Rebuild workspace), and apparently things progressed
since all the undefined reference to __imp_my_function disappeared.
But now it says: error: ld returned 5 exit status.
Nothing more. I don't know what the 5 exit status mean. Is there a path problem? I tried the full path,
it doesn't help.
Any hint?
Thanks!
R
Miguel Gimenez:
Quoting myself...
--- Quote ---If you have more problems post a full rebuild log
--- End quote ---
https://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
rascalito:
Hello!
Sorry, I didn't notice that advice. I have checked the page, but it sarts with:
"Try building the project from command line. "
That's certainly a good idea, but it would be good to know how I rebuild form the command line.
Do I open a DOS window, go to the project location and run a make of some kind?
NB: I tried to google "codeblocks how to compile from the command line".
Thanks,
R
Navigation
[0] Message Index
[#] Next page
Go to full version