MinGW需要部署哪些文件? [英] What files of MinGW need to be deployed?

查看:141
本文介绍了MinGW需要部署哪些文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用gcc-6.3.0和gcc-gnat-6.3.0在Windows的MinGW64(MSYS2)中编译了Linux软件.我想组装一个包含所有必要文件的安装程序包或zip文件.目标机器需要MinGW的哪些部分?

I compiled a Linux software in MinGW64 (MSYS2) on Windows with gcc-6.3.0 and gcc-gnat-6.3.0. I would like to assemble an installer package or zip file, that contains all necessary files. What parts of MinGW are required at a destination machine?

我不想交付完整的MSYS2/MinGW64,因为它具有3 GiB!可执行文件只有10个MiB.

I don't want to ship a complete MSYS2/MinGW64, because it has 3 GiB! The executable has only 10 MiB.

我也不会要求用户安装MSYS2和MinGW64,因为在Windows计算机上安装它是一场噩梦.程序包管理器(pacman)对用户不友好,无法用于普通用户.

I also won't demand a user to install MSYS2 and MinGW64, because it's a nightmare to install it on a Windows machine. The package manager (pacman) is not user friendly / usable for normal users.

通常,MinGW64不在我的PATH中.我有一个脚本可以根据选定的MinGW 32版和64版进行添加.用于编译程序的GCC来自mingw32或mingw64目录.

Normally, MinGW64 is not in my PATH. I have a script to add it depending on the selected MinGW version 32 vs. 64. The GCC used to compile the program is from the mingw32 or mingw64 directory.

我将二进制文件复制到一个单独的目录:C:\Tools\GHDL\0.34dev-mingw64-llvm\bin

I copied the binary to a separate directory: C:\Tools\GHDL\0.34dev-mingw64-llvm\bin

我用ldd.exe检查可执行文件:

C:\msys64\usr\bin\ldd.exe C:\Tools\GHDL\0.34dev-mingw64-llvm\bin\ghdl.exe
    ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x77020000)
    kernel32.dll => /c/Windows/system32/kernel32.dll (0x76f00000)
    KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll (0x7fefcf20000)
    ADVAPI32.dll => /c/Windows/system32/ADVAPI32.dll (0x7fefd6a0000)
    msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefd130000)
    sechost.dll => /c/Windows/SYSTEM32/sechost.dll (0x7feff310000)
    RPCRT4.dll => /c/Windows/system32/RPCRT4.dll (0x7fefe450000)
    SHELL32.dll => /c/Windows/system32/SHELL32.dll (0x7fefe580000)
    SHLWAPI.dll => /c/Windows/system32/SHLWAPI.dll (0x7fefe120000)
    GDI32.dll => /c/Windows/system32/GDI32.dll (0x7fefda60000)
    USER32.dll => /c/Windows/system32/USER32.dll (0x76e00000)
    LPK.dll => /c/Windows/system32/LPK.dll (0x7fefd110000)
    USP10.dll => /c/Windows/system32/USP10.dll (0x7fefd5d0000)

C:\msys64\usr\bin\ldd.exe C:\Tools\GHDL\0.34dev-mingw64-llvm\bin\ghdl1-llvm.exe
    ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x77020000)
    kernel32.dll => /c/Windows/system32/kernel32.dll (0x76f00000)
    KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll (0x7fefcf20000)
    ??? => ??? (0x6fe40000)
    libstdc++-6.dll => /c/Program Files/gettext-iconv/libstdc++-6.dll (0x6fc40000)
    libgcc_s_sjlj-1.dll => /c/Program Files/gettext-iconv/libgcc_s_sjlj-1.dll (0x6cec0000)
    msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefd130000)
    libwinpthread-1.dll => /c/Program Files/gettext-iconv/libwinpthread-1.dll (0x64940000)
    USER32.dll => /c/Windows/system32/USER32.dll (0x76e00000)
    GDI32.dll => /c/Windows/system32/GDI32.dll (0x7fefda60000)
    LPK.dll => /c/Windows/system32/LPK.dll (0x7fefd110000)
    USP10.dll => /c/Windows/system32/USP10.dll (0x7fefd5d0000)

我认为第一个可执行文件ghdl.exe是可以的,因为它仅引用Windows DLL.第二个可执行文件ghdl1-llvm.exe具有四个特殊条目:

I assume, the first executable ghdl.exe is OK, because it references only Windows DLLs. The second executable ghdl1-llvm.exe has four special entries:

  • libstdc++-6.dll => /c/Program Files/gettext-iconv/libstdc++-6.dll
  • libgcc_s_sjlj-1.dll => /c/Program Files/gettext-iconv/libgcc_s_sjlj-1.dll
  • libwinpthread-1.dll => /c/Program Files/gettext-iconv/libwinpthread-1.dll
  • ??? => ???
  • libstdc++-6.dll => /c/Program Files/gettext-iconv/libstdc++-6.dll
  • libgcc_s_sjlj-1.dll => /c/Program Files/gettext-iconv/libgcc_s_sjlj-1.dll
  • libwinpthread-1.dll => /c/Program Files/gettext-iconv/libwinpthread-1.dll
  • ??? => ???

问题:

  • 第一个意思是用户需要C ++软件包吗?此VC ++ 6.0可重新分发吗?
    否则,Linux上会有一个gettext包...
  • 我编译了,其中是用Ada编写的,带有后端的问题.我希望在Linux上再有两个依赖项:

  • Does the first mean, a user needs a C++ package? Is this VC++ 6.0 redistributable?
    Otherwise, there is a gettext package on Linux ...
  • I compiled ghdl, which is written in Ada, with llvm backend. I would expect two more dependencies like on Linux:

  • llvm 3.8
  • libgnat 6.3.0

OTOH,GHDL也有一个libgrt.a文件.如何从该文件读取依赖项?

OTOH, GHDL also has a libgrt.a file. How can I read the dependencies from that file?

哦,我认为编辑1中存在绑定错误.
如果我从MinGW64控制台中运行ldd,我会看到gettext绑定到其他文件...

Oh, I think there are binding errors in the edit 1.
If I run ldd from within MinGW64 console, I see gettext bound to other files ...

例如libstdc++-6.dll => /mingw64/bin/libstdc++-6.dll (0x6fc40000)

推荐答案

首先,请确保您确实在构建本机(MinGW)Windows应用程序.您使用的编译器应位于/mingw64/bin//mingw32/bin中.运行which gcc以确保您使用的编译器正确.许多MSYS2问题归结为人们不知道要使用哪个编译器,所以我总是提到它.

First of all, make sure you are actually building a native (MinGW) Windows application. The compiler you are using should be located in /mingw64/bin/ or /mingw32/bin. Run which gcc to make sure you are using the right compiler. Lots of MSYS2 problems boil down to people not knowing which compiler to use, so I always mention it.

所需的DLL完全由程序使用的库以及编译方式决定.因此,我不能仅告诉您所需的DLL.相反,我会帮助您自己解决问题.

The DLLs you need are determined by exactly what libraries your program uses and how it was compiled. So I can't just tell you what DLLs you will need. Instead, I will help you figure it out on your own.

找出这一点的实验方法是只提取编译后的可执行文件,将其移动到MSYS2之外的其他文件夹中,然后尝试通过双击来运行它.它可能会抱怨某些DLL丢失.将该DLL从MSYS2中的相应bin目录(/mingw64/bin/mingw32/bin)复制到带有可执行文件的目录中.重复此过程,直到您的程序成功运行.请注意,我假设MSYS2或其他具有类似DLL的程序不在您的PATH上.您可能需要暂时减少PATH中的文件夹数量,以确保正确执行此操作.例如,您可以尝试在运行set PATH=后从命令提示符运行该程序.

The experimental method to figure this out is to just take the executable file you compiled, move it to a different folder outside of MSYS2, and try to run it by double-clicking on it. It will probably complain about some DLL missing. Copy that DLL from the appropriate bin directory inside MSYS2 (/mingw64/bin or /mingw32/bin) into the directory with your executable. Repeat this until your program runs successfully. Note that I am assuming that MSYS2 or other programs with similar DLLs are not on your PATH. You might want to reduce the number of folders in your PATH temporarily to be sure you are doing this correctly. For example, you could try running the program from a Command Prompt after running set PATH=.

我经常使用的另一种方法是在 Dependency Walker 中打开可执行文件,然后直接查看它包含哪些DLL.取决于.

Another method that I often use is to open my executable in Dependency Walker and see what DLLs it directly depends on.

请注意,在极少数情况下,您可能有一个在运行时而不是在程序启动时加载的DLL.我上面提到的方法无法检测到这种情况,因此没有通用的机制.

Please note that on rare occasions, you might have a DLL that gets loaded at run time instead of when the program starts. The methods I mentioned above cannot detect that, and there is no general mechanism to do so.

文件libstdc++-6.dll是GCC的libstdc ++.它实现了C ++标准库,提供了std::string之类的东西. "VC ++ 6.0可再发行"将是某些Microsoft产品,它与众不同.

The file libstdc++-6.dll is GCC's libstdc++. It implements the C++ standard library, providing things like std::string. The "VC++ 6.0 redistributable" would be some Microsoft product, which is very different.

您的第二个问题不是问题.也许某些库是静态链接而不是动态链接.

Your second question is not a question. Maybe some of the libraries were statically linked instead of dynamically linked.

我不知道有什么好的方法来读取静态库文件(如libgrt.a)的依赖项.静态库只是一堆尚未链接的对象,因此静态库仅包含需要的未定义符号列表,但它不知道最终将由哪个共享库或静态库提供这些符号.我建议将静态库编译为可执行文件.

I don't know of any good way to read the dependencies of a static library file like libgrt.a. Static libraries are just a bundle of objects that have not been linked yet so a static library just has lists of undefined symbols that it needs, but it does not know which shared or static library will end up providing those symbols. I suggest compiling the static library it into an executable.

这篇关于MinGW需要部署哪些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆