User forums > Using Code::Blocks
How to include an external lib and dll ???
kerstin:
Hello,
I'm trying to compile a program which was written with Visual Studio 2005 with C:B and MinGW.
The program needs an external lib -> I set under project -> Build Option -> linker settings -> name of lib without .lib and under search directory I set the path to the project.
I tried also to include it under settings-> compiler&debugger-> linker settings (here I added both dll. and lib) and also I set the path under search directory.
Still I'm getting this error:
07App.o obj\Debug\TarifeMenu.o obj\Debug\skript.res -lgdi32 -luser32 -lkernel32 -lIEICAN02 bin\IEICAN02.lib ..\IEICAN02.dll C:\Kerstin\Code_Block\ta_project_test\IEICAN02.dll C:\Kerstin\Code_Block\ta_project_test\IEICAN02.lib
mingw32-g++.exe: ..\IEICAN02.dll: No such file or directory
Has anyone an idea???
THANKS!!!
Kerstin
MortenMacFly:
--- Quote from: kerstin on September 08, 2008, 08:15:59 am ----lIEICAN02 bin\IEICAN02.lib ..\IEICAN02.dll C:\Kerstin\Code_Block\ta_project_test\IEICAN02.dll C:\Kerstin\Code_Block\ta_project_test\IEICAN02.lib
--- End quote ---
Did you notice that all the "libs" starting with ..\IEICAN02.dll ae missing the linker flag -l?
It seems you don't provider them through the library (project/target) options.
Either you really fill them under the project's "build options" -> tab "Linker settings" -> listbox "link libraries" line by line or (if you like) under "other linker options" but then it's best top put each library in an own line and (most important" don't forget to add the "-l" flag in front of each library.
As you see: The first solution is the best. ;-)
kerstin:
hi
Sorry but what do you mean with
--- Quote ---"-l" flag in front of each library
--- End quote ---
?
Did you mean something like this?
Other linker option:
-l IEICAN02.lib
or
link libraries:
bin\IEICAN02.lib
..\IEICAN02.dll
Edit. Removed MS word content.
MortenMacFly:
--- Quote from: kerstin on September 08, 2008, 09:20:25 am ----l IEICAN02.lib
bin\IEICAN02.lib
..\IEICAN02.dll
--- End quote ---
According to your image (Please: Never-ever use MS Word format again but true images such as JPG or PNG) you did several things wrong:
1.) Your library has an import library (if I got that picture right). So it makes no sense to link against both, the library and the DLL. Choose the library only and put the DLL to the application at runtime. I believe that's what you want to achieve.
2.) The linker option for GCC is: -l[library name]. That's a lower-case "L" WITHOUT space between the linker option and the library. Otherwise the linker takes this as two options: "-l" without am library -> so it get ignored and IEICAN02.lib as an object (not library!) file to link into the application. This won't work.
3.) You tell the linker to "somehow" include 3 files all of (more ort less) the same type. Decide for one way to go.
I strongly suggest you first read yourself into the command line version of the compiler / linker of your choice.
I'll give you a final hint:
1.) add *only* the import library under "link libraries" -> without path, without extension, without prefix.
2.) add the path to the import library under "search directories" -> linker
3.) put the DLL into your application directory.
BTW: This has been told a lot on this forum although it's not really related to C::B. I can only suggest to everybody: Learn how a compiler / linker works before you start using (any) IDE. Use the command line to get the basic skills, then use the IDE to automise the boring stuff. Otherwise you will sooner or later be lost again.
kerstin:
Thanks a lot , I think he found the dll now!
this is what I get now, just in case I'm wrong:
obj\Debug\skript.res -lgdi32 -luser32 -lkernel32 -lIEICAN02 C:\Kerstin\Code_Block\ta_project_test\IEICAN02.dll C:\Kerstin\Code_Block\ta_project_test\IEICAN02.lib
But can I ask you one more thing?
I get now this error:
obj\Debug\CAN.o: In function `ZN4CCAN16MyCAN_CountCardsEv':
C:/Kerstin/Code_Block/ta_project_test/CAN.CPP:20: undefined reference to `_imp___Z14CAN_CountCardsv@0'
this function (countCards) are defined in the lib I just included, (he finds the .h file). so why is it still an undefined reference?
Navigation
[0] Message Index
[#] Next page
Go to full version