问题
#include <gtk/gtk.h>
int main( int argc, char *argv[] )
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_main ();
return 0;
}
I tried putting various versions of MSVCR80.dll
under the same directory as the generated executable(via cmake
),but none matched.
Is there a general solution for this kinda problem?
UPDATE
Some answers recommend install the VS redist,but I'm not sure whether or not it will affect my installed Visual Studio 9, can someone confirm?
Manifest file of the executable
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
It seems the manifest file says it should use the MSVCR90
, why it always reporting missing MSVCR80.dll
?
FOUND
After spending several hours on it,finally I found it's caused by this setting in PATH
:
D:\MATLAB\R2007b\bin\win32
After removing it all works fine.But why can that setting affect my running executable from using msvcr90 to msvcr80 ???
回答1:
Answering the topic question, even gtk application needs Microsoft libraries because it doesn't try to emulate look and behavior of Windows widgets. Instead, gtk uses native APIs to draw widgets. Even if you compile with MinGW compiler your program would still need MSVCR.
Try to look into makefiles to get an idea, why doesn't cmake link properly.
回答2:
May I suggest that you read this page? http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
In short, you need to change your CMake file to link statically to the MSVC runtime.
(By the way, this has nothing to do with Gtk; every program will be linked against the MSVC runtime by default)
回答3:
You need the VS redist for it to run. Just placing a DLL in the folder will not work, since the loader looks at the manifest for dependencies to satisfy, which must reside in a particular place in the WinSxS directory.
It's not a linker problem, you just can't run the EXE you generated.
回答4:
1.
Maybe, CMake uses external compiler. In your case - it seems to be Microsoft Visual C++ 2005
. And target executable is linked with C++ runtime dinamycally
what means that Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)
packages must be installed on every computer running the program.
MSVCR = MicroSoft Visual C++ Runtime
See also this MSDN
article: /MD, /MT, /LD (Use Run-Time Library)
2.
To indicate CMake use GCC: How do I use a different compiler?
3.
Try use Dependency Walker to figure out how exactly dependency are being exists
来源:https://stackoverflow.com/questions/2712913/how-does-path-environment-affect-my-running-executable-from-using-msvcr90-to-msv