Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: kirash4 on May 09, 2014, 12:13:37 am

Title: Missing DLL on Win - need to understand why
Post by: kirash4 on May 09, 2014, 12:13:37 am
I'm still playing and testing things with C::B hoping I can eventually write a GUI application using wxWidgets. I have a stand-alone installation of MinGW that I use to compile wxWidget projects. I can create a new wxWidgets project and as soon as that project opens I can hit Build and Run and a few seconds later I will get the minimal wxWidgets application to open. Great.

I've also created a completely different project, this time a console one, and used the ImageMagick library to build different command line utilities. That too compiles (and works) with the stand-alone MinGW compiler. No problems.

Now comes the failed trick: ultimately I want to create a GUI application that uses ImageMagick. I already know I can make a GUI application with just wxWidgets (I ran through all of their online tutorials already), and I can make a stand-alone console (or command line) application using ImageMagick's library. But combining the two is proving to be problematic. So here's what I did:

Start with a new wxWidgets project:
File -> New Project -> Select wxWidgets Project
Picked wxWidgets 3.0.x (since that's what I have installed)
For Project title I used a random name, 'wxTest' and Author/E-mail/Website are also filled accordingly
Preferred GUI Builder is set to wxSmith
Application Type is set to Frame Based
wxWidgets' location is set to $(#wx) (this global variable is configured to the same location where wxWidgets-3.0.0 is installed)
Compiler is set to the stand-alone MinGW install on this machine
Both Debug and Release configurations are enabled with default values
Under wxWidgets Library Settings I have wxWidgets as a monolithic library and unicode enabled (DLL is not checked.)
Under Miscellaneous settings I have Create and use precompiled header (PCH) enabled. The Create Empty Project as well as Configure Advance Options are not checked.

-- At this point the project is open and I can hit Build and Run and it compiles and launches the (empty) application.

Now I will add the same settings for ImageMagick (hereafter referred to as IM) that I did for the console programs to compile:
(Note, I have the IM libraries installed in T:\ImageMagick-6.8.5)
Project -> Properties -> Build targets
By default 'Debug' is selected so we'll play with that for now.
Click the Build options... button
The Selected compiler is still set to the stand-along MinGW compiler
Under Compiler settings -> #defines, I added the required define for IM:
Quote
MAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
Under Linker settings, it already lists several libwx* libraries. I added the required IM libraries specific for MinGW32:
Quote
T:\ImageMagick-6.8.5\lib\libMagick++-6.Q16.dll.a
T:\ImageMagick-6.8.5\lib\libMagickCore-6.Q16.dll.a
T:\ImageMagick-6.8.5\lib\libMagickWand-6.Q16.dll.a
Under Search directories -> Compiler it already lists one wxWidgets line. I added the required IM include location: T:\ImageMagick-6.8.5\include\ImageMagick-6
Under Search directories -> Linker it already lists the wxWidgets line. I added the required IM library location: T:\ImageMagick-6.8.5\lib

-- At this point I have configured this project the same exact way as I did the other, console programs that also use IM.

I performed a Build -> Clean then a Build and Run. It will successfully compile, no errors, no warnings. However when it tries to run the executable, I get errors. First error is that the executable is missing libMagick++-6.Q16-1.dll in its path. No problem, I can put it there. Then it complains about missing 'pthreadGC2.dll' and it's at this point that I'm lost.

Where is that dll being called from, and why? Why is it when I create a stand-alone wxWidgets project, I never get that error? In fact, I went through all of their tutorials online and the only libraries it ever wanted me to have present were 'libstdc++-6.dll' and 'libwinpthread-1.dll'. Both of those come from MinGW so it's a simple matter of copying them over into the executable folder and it works. And for the console applications that use IM, all I had to do there was copy the required 'libMagick++-6.Q16-1.dll' into the folder and done. But where's this 'pthreadGC2.dll' coming from? And why does it only pop up when I try to build a wxWidgets GUI application with the IM library? I haven't even included the IM header file yet, just setup the various paths and settings for it to work.

Looking at both the MinGW stand-alone install, as well as my system as a whole, I can't find that pthreadGC2.dll file anywhere. Nor can I figure out what specifically is wanting to use it or how to fix it (other than to download it from somewhere on the net, something I'm not willing to do simply because I don't see why I would need it when separately, both scenarios work without.)

Any ideas and/or suggestions anyone?
Title: Re: Missing DLL on Win - need to understand why
Post by: stahta01 on May 09, 2014, 03:14:03 am
You need to learn to use DLL tools to find which thing wants that DLL; then you will likely have to research the answer on how/why on another site.

I use "dependency walker" depends.exe from http://www.dependencywalker.com/ (http://www.dependencywalker.com/)

You will likely need to post a full build log to get help on this issue.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)

It might be a compiler setting caused issue or a library documentation issue.
In other words, your directions might be too old.

Tim S.
Title: Re: Missing DLL on Win - need to understand why
Post by: kirash4 on May 09, 2014, 03:41:25 am
Stand-alone console application (command line utility) using ImageMagick:
Code
-------------- Clean: GetPX - MinGW (stand-alone) in POVpoi (compiler: MinGW)---------------

Cleaned "POVpoi - GetPX - MinGW (stand-alone)"

-------------- Build: GetPX - MinGW (stand-alone) in POVpoi (compiler: MinGW)---------------

g++.exe -Wall -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -IT:\ImageMagick-6.8.5\include\ImageMagick-6 -c G:\Dropbox\CodeBlocks\POVpoi\getpx-v10.cpp -o obj\Release\getpx-v10.o
g++.exe -LT:\ImageMagick-6.8.5\lib -o bin\Release\MinGW\getpx.exe obj\Release\getpx-v10.o   T:\ImageMagick-6.8.5\lib\libMagick++-6.Q16.dll.a T:\ImageMagick-6.8.5\lib\libMagickCore-6.Q16.dll.a T:\ImageMagick-6.8.5\lib\libMagickWand-6.Q16.dll.a
Output file is bin\Release\MinGW\getpx.exe with size 98.18 KB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))
Build log saved as:
file://G:/Dropbox/CodeBlocks/POVpoi/POVpoi_build_log.html

Empty wxWidgets project, nothing added:
Code
-------------- Clean: Debug in wxOnly (compiler: MinGW)---------------

Cleaned "wxOnly - Debug"

-------------- Build: Debug in wxOnly (compiler: MinGW)---------------

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -IT:\wxWidgets-3.0.0\include -IT:\wxWidgets-3.0.0\lib\gcc_lib\mswud -c G:\Dropbox\CodeBlocks\wxOnly\wx_pch.h -o wx_pch.h.gch\Debug_wx_pch_h_gch
windres.exe -IT:\wxWidgets-3.0.0\include -IT:\wxWidgets-3.0.0\lib\gcc_lib\mswud -J rc -O coff -i G:\Dropbox\CODEBL~1\wxOnly\resource.rc -o obj\Debug\resource.res
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -IT:\wxWidgets-3.0.0\include -IT:\wxWidgets-3.0.0\lib\gcc_lib\mswud -c G:\Dropbox\CodeBlocks\wxOnly\wxOnlyApp.cpp -o obj\Debug\wxOnlyApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -IT:\wxWidgets-3.0.0\include -IT:\wxWidgets-3.0.0\lib\gcc_lib\mswud -c G:\Dropbox\CodeBlocks\wxOnly\wxOnlyMain.cpp -o obj\Debug\wxOnlyMain.o
g++.exe -LT:\wxWidgets-3.0.0\lib\gcc_lib -o bin\Debug\wxOnly.exe  obj\Debug\wxOnlyApp.o obj\Debug\wxOnlyMain.o obj\Debug\resource.res -mthreads  -lwxmsw30ud -lwxpngd -lwxjpegd -lwxtiffd -lwxzlibd -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
Output file is bin\Debug\wxOnly.exe with size 66.19 MB
Process terminated with status 0 (0 minute(s), 37 second(s))
0 error(s), 0 warning(s) (0 minute(s), 37 second(s))
Build log saved as:
file://G:/Dropbox/CodeBlocks/wxOnly/wxOnly_build_log.html

Empty wxWidgets project with the necessary paths to IM added. The same IM configuration as the console applications:
Code
-------------- Clean: Debug in wxTest (compiler: MinGW)---------------

Cleaned "wxTest - Debug"

-------------- Build: Debug in wxTest (compiler: MinGW)---------------

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -IT:\wxWidgets-3.0.0\include -IT:\wxWidgets-3.0.0\lib\gcc_lib\mswud -IT:\ImageMagick-6.8.5\include\ImageMagick-6 -c G:\Dropbox\CodeBlocks\wxTest\wx_pch.h -o wx_pch.h.gch\Debug_wx_pch_h_gch
windres.exe -IT:\wxWidgets-3.0.0\include -IT:\wxWidgets-3.0.0\lib\gcc_lib\mswud -J rc -O coff -i G:\Dropbox\CODEBL~1\wxTest\resource.rc -o obj\Debug\resource.res
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -IT:\wxWidgets-3.0.0\include -IT:\wxWidgets-3.0.0\lib\gcc_lib\mswud -IT:\ImageMagick-6.8.5\include\ImageMagick-6 -c G:\Dropbox\CodeBlocks\wxTest\wxTestApp.cpp -o obj\Debug\wxTestApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -IT:\wxWidgets-3.0.0\include -IT:\wxWidgets-3.0.0\lib\gcc_lib\mswud -IT:\ImageMagick-6.8.5\include\ImageMagick-6 -c G:\Dropbox\CodeBlocks\wxTest\wxTestMain.cpp -o obj\Debug\wxTestMain.o
g++.exe -LT:\wxWidgets-3.0.0\lib\gcc_lib -LT:\ImageMagick-6.8.5\lib -o bin\Debug\wxTest.exe  obj\Debug\wxTestApp.o obj\Debug\wxTestMain.o obj\Debug\resource.res -mthreads  -lwxmsw30ud -lwxpngd -lwxjpegd -lwxtiffd -lwxzlibd T:\ImageMagick-6.8.5\lib\libMagick++-6.Q16.dll.a T:\ImageMagick-6.8.5\lib\libMagickCore-6.Q16.dll.a T:\ImageMagick-6.8.5\lib\libMagickWand-6.Q16.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
Output file is bin\Debug\wxTest.exe with size 66.19 MB
Process terminated with status 0 (0 minute(s), 19 second(s))
0 error(s), 0 warning(s) (0 minute(s), 19 second(s))
Build log saved as:
file://G:/Dropbox/CodeBlocks/wxTest/wxTest_build_log.html

As I mentioned before, they ALL compile, however only the stand-along utility or the wxWidgets (only) executables work (after copying the necessary libraries in the same folder.) The last one where I am trying to incorporate IM with wxWidgets, that fails with needing that pthreadGC2.dll library.
Title: Re: Missing DLL on Win - need to understand why
Post by: stahta01 on May 09, 2014, 04:15:44 am
You need to learn to use DLL tools to find which thing wants that DLL; then you will likely have to research the answer on how/why on another site.

I use "dependency walker" depends.exe from http://www.dependencywalker.com/ (http://www.dependencywalker.com/)

Tim S.
Title: Re: Missing DLL on Win - need to understand why
Post by: kirash4 on May 09, 2014, 06:01:56 am
Ok, so it points at the libMagickCore-6.Q16-1.dll library. Great. I will have to take that up with the IM folks. However, what I don't understand is why does this error ONLY pop up when I try to use both wxWidgets and IM together. Compiling something that only uses IM works just fine. So what gives?