How does the PATH environment affect my executable using msvcr90 on msvcr80?

#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 different versions of MSVCR80.dll in the same directory as the generated executable (via cmake ), but none of them matched.

Is there a general solution to this problem?

UPDATE

Some answers recommend installing VS-redist, but I'm not sure if this will affect my installed Visual Studio 9, can anyone confirm?

Executable manifest file

 <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> 

The manifest file seems to say that it should use MSVCR90 , why does it always report the absence of MSVCR80.dll ?

Foound

After spending several hours on this, I found that this was caused by this setting in PATH:

 D:\MATLAB\R2007b\bin\win32 

After removal, everything works fine. But why does this option affect my executable executable using msvcr90 on msvcr80 ???

+4
source share
4 answers

When asked about a topic, even a gtk application needs Microsoft libraries because it does not attempt to emulate the appearance and behavior of Windows widgets. Instead, gtk uses its own APIs to draw widgets. Even if you compile the MinGW compiler, your program still needs MSVCR.

Try a peek into the makefiles to get an idea of ​​why the cmake link is not working properly.

+1
source

1.

Perhaps CMake uses an external compiler. In your case, this seems like Microsoft Visual C++ 2005 . And the target executable is linked to C ++ runtime dinamycally , which means that the Microsoft Visual C ++ 2005 Redistributable Package SP1 (x86) packages must be installed on every computer on which the program is running.

 MSVCR = MicroSoft Visual C++ Runtime 

See also the MSDN article: / MD, / MT, / LD (Use Runtime Library)

2.

To indicate the use of CMake GCC: How to use a different compiler?

3.

Try using Dependency Walker to find out how accurately dependencies exist.

0
source

May I suggest 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 modify your CMake file to statically communicate with the MSVC environment.

(By the way, this has nothing to do with Gtk, each program will be associated with MSVC default runtime)

0
source

For this you need VS redist . Just placing the DLL in the folder will not work, because the loader looks at the manifest to match the dependencies, which should be located in a specific place in the WinSxS directory.

This is not a linker problem; you simply cannot run the EXE generated by you.

0
source

Source: https://habr.com/ru/post/1308013/


All Articles