Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: OldSeaWolf on September 01, 2010, 08:35:22 pm
-
Dear members of the forum.
I have met a problem while I decided create a program that uses dynamically linked libraries.
I had created and compiled two test projects of my dlls without any problems and errors. In the process of compilation and linking 3 files were created for each project in the directory bin\debug:
<name>.dll, lib<name>.dll.a, lib<name>.dll.def .
Then I have created a project with a program that must use these dlls (future exe-module), copied lib<name>.dll.a file to the project directory and pointed it in the linker options of the project. I have added these files to the project tree as well. However after I started building (Ctrl-F9), some strange errors of the linker appeared.
Here is a quote:
mingw32-g++.exe: obj\Debug\libinout.dll.o: No such file or directory
mingw32-g++.exe: obj\Debug\libarithm.dll.o: No such file or directory
When I delete these files from the project tree leaving them in linker options another error springs out:
ld.exe: cannot find -larithm.dll
Please explain me what causes these mistakes and what I'm doing wrong. I tried to find this information in the users manual, however I didn't find any (perhaps I was not careful enough in my search). Could you give me a step by step instruction of creating such a project? I have made such projects based on the same source text in Visual Studio and dev-cpp (which contains an older version of MinGW) successfully, but I can't resolve the same problem in this IDE. Could you help me?
-
Turn on Full Compiler Logging and post the re-build log info.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
Might read and see if this answers your questions
http://wiki.codeblocks.org/index.php?title=Linking_the_plugin_to_a_Nightly_Build#Step_Four_-_Link_Everything_Together
Tim S.
-
Tim, here is the full log after Ctrl-F11. If it is necessary, I can send you all the project, it is a simple console application.
-------------- Clean: Debug in main ---------------
Cleaned "main - Debug"
-------------- Build: Debug in main ---------------
mingw32-g++.exe -Wall -fexceptions -g -c "C:\samp\gcd_lcm(2)\dynamic_link (CodeBlocks)\main\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\main.exe obj\Debug\libinout.dll.o obj\Debug\main.o obj\Debug\libarithm.dll.o -larithm.dll -linout.dll
mingw32-g++.exe: obj\Debug\libinout.dll.o: No such file or directory
mingw32-g++.exe: obj\Debug\libarithm.dll.o: No such file or directory
Process terminated with status 1 (0 minutes, 3 seconds)
0 errors, 0 warnings
-
Something is not right; but, I am not sure what is the cause.
What did you type into the Linker Library search path?
What did you type into the extra/other linker options?
What is the files in the project?
I have added these files to the project tree as well.
Try removing the DLLs from project tree.
Tim S.
-
I didn't point any paths to the IDE. I have copied the dll<...>.dll.a files to the main directory of the project (where I put all my sources). And I included these *.a files into the project.
First I added them to the project file-tree, then I pointed them in the linker options:
Project -> Build Options -> Linker Settings -> Link Libraries (Add Button).
Files in the project
Sources:
main.cpp
Headers:
arithm.h
inout.h
Others
libarithm.dll.a
libinout.dll.a
-
Others
libarithm.dll.a
libinout.dll.a
Please remove the others files.
Tim S.
-
I removed these two files from Others and here is the log after rebuilding:
-------------- Clean: Debug in main ---------------
Cleaned "main - Debug"
-------------- Build: Debug in main ---------------
mingw32-g++.exe -Wall -fexceptions -g -c "C:\samp\gcd_lcm(2)\dynamic_link (CodeBlocks)\main\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\main.exe obj\Debug\main.o -larithm.dll -linout.dll
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: cannot find -larithm.dll
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 4 seconds)
1 errors, 0 warnings
-
Add the path to the Linker Search folder to find the library/DLL.
Project Build Options
Tab "search directory"
Sub-Tab "Linker"
Tim S.
-
1. What path have I to add: path that contains *.a files (lib<...>.dll.a) or path with real dlls (<...>.dll)?
2. How should I add these paths (I have two dlls)?
Project -> Build Options... -> Search Directories -> Linker -> Add Button ?
Or perhaps I must do this in some other way?
-
Project -> Build Options... -> Search Directories -> Linker -> Add Button ?
Correct, add the path to the library/dll file used in the link list.
Tim S.
-
I have added the paths to both dll files which were created in the process of compilation of these dll projects and the chief project was built successfully.
In fact I had three independent projects: main, arithm, inout, each of them was situated in its own folder with the same name. To make the project "main" to be compiled I had to add to its linker settings the following directories: arithm\bin\Debug, inout\bin\Debug . Both directories contained the compiled dll files: arithm.dll and inout.dll.
Is this correct and is this the thing you actually meant? Or not?
-
I think it is correct.
The main thing is the items added to the linker library list should have their path added search dir linker area if they can not be found.
Tim S.
-
Thank you very much, Tim.