您可以在64位安装中运行32位Cygwin应用程序吗? [英] Can you run a 32 bit Cygwin application in a 64 bit installation?

查看:646
本文介绍了您可以在64位安装中运行32位Cygwin应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在64位安装中运行32位Cygwin应用程序?



动机:如



由于我没有您的 32位可执行文件,我不喜欢搜索下载,解压缩等...),我创建了一个小示例(要使其运行,您还需要 gcc 工具链-我拥有出于其他目的,但是无论如何,这都与问题无关)。



code.c

  #include< stdio.h> 


int main(){
printf( \ void * \是%d位长。\n,sizeof(void *)* 8 );
返回0;
}

输出


  [cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> uname -a 
CYGWIN_NT-10.0 cfati-5510-0 2.11.2(0.329 / 5/3)2018-11-08 14:34 x86_64 Cygwin
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> ls
code.c
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> x86_64-pc-cygwin-gcc.exe -o exe-gcc-064.exe code.c
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> i686-pc-cygwin-gcc.exe -o exe-gcc-032.exe code.c -m32
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> ; ls -al
总计433
drwxrwx --- + 1管理员无0 Jan 16 12:45。
drwxrwx --- + 1管理员无0 Jan 16 10:33 ..
-rwxrwx --- + 1管理员无118 Jan 16 10:39 code.c
-rwxrwxr-x + 1 cfati无151062 Jan 16 12:45 exe-gcc-032.exe
-rwxrwxr-x + 1 cfati无157755 Jan 16 12:45 exe-gcc-064.exe
[cfati @ cfati-5510 -0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>文件exe-gcc-064.exe
exe-gcc-064.exe:PE32 +可执行文件(控制台)x86-64,用于MS Windows
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> ld exe-gcc-064.exe
ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll(0x7ffcaf990000)
KERNEL32.DLL => /cygdrive/c/WINDOWS/System32/KERNEL32.DLL(0x7ffcaf300000)
KERNELBASE.dll => /cygdrive/c/WINDOWS/System32/KERNELBASE.dll(0x7ffcabe60000)
cygwin1.dll => /usr/bin/cygwin1.dll(0x180040000)
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> ./exe-gcc-064.exe
void *的长度为64位。
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>文件exe-gcc-032.exe
exe-gcc-032.exe:PE32可执行文件(控制台)Intel 80386,用于MS Windows
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> ld exe-gcc-032.exe
ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll(0x7ffcaf990000)
??? => ??? (0x77150000)
wow64.dll => /cygdrive/c/WINDOWS/System32/wow64.dll(0x7ffcaf800000)
wow64win.dll => /cygdrive/c/WINDOWS/System32/wow64win.dll(0x7ffcad570000)
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> ./exe-gcc-032.exe
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>回声$?
127


如您所见,我遇到了与 exe-gcc-032.exe 完全相同的问题。 ??? 依赖项是 32位 cygwin1.dll 。让我们探究这个问题:


  [cfati @ cfati-5510- 0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>查找/ usr -name cygwin1.dll 
/usr/i686-pc-cygwin/sys-root/usr/bin/cygwin1.dll
/usr/bin/cygwin1.dll
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> cygcheck -f /usr/bin/cygwin1.dll
cygwin-2.11.2-1
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>文件/usr/bin/cygwin1.dll
/usr/bin/cygwin1.dll:PE32+可执行文件(DLL)(控制台)x86-64,用于MS Windows
[cfati @ cfati-5510-0: / cygdrive / e / Work / Dev / StackOverflow / q054206577]>
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> cygcheck -f /usr/i686-pc-cygwin/sys-root/usr/bin/cygwin1.dll
cygwin32-2.10.0-1
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>文件/usr/i686-pc-cygwin/sys-root/usr/bin/cygwin1.dll
/usr/i686-pc-cygwin/sys-root/usr/bin/cygwin1.dll:PE32可执行文件(DLL )(控制台)Intel 80386(剥离到外部PDB),用于MS Windows
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> echo $ {PATH}
/ usr / local / bin:/ usr / bin:/ cygdrive / c /程序文件(x86)/通用文件/ Oracle / Java / javapath:/ cygdrive / c / WINDOWS / system32: /cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Install/x64/NVidia/GPU Computing Toolkit / CUDA / AllVers / bin:/ cygdrive / c / Install / x64 / NVidia / GPU Computing Toolkit / CUDA / AllVers / libnvvp:/ cygdrive / c / Install / x86 / Borland / Delphi / 7 / Bin:/ cygdrive / c / Install / x86 / Borland / Delphi / 7 / Projects / Bpl:/ cygdrive / c / ProgramData / Oracle / Java / javapath:/ cygdrive / c / Program Files(x86)/ Intel / iCLS Client:/ cygdrive / c / Program Files / Intel / iCLS客户端:/ cygdrive / c /程序文件(x86)/英特尔/英特尔(R)管理引擎组件/ DAL:/ cygdrive / c /程序文件/英特尔/英特尔(R)管理引擎组件/ DAL:/ cygdrive / c /程序文件(x86)/ Intel / Intel(R)管理引擎组件/ IPT:/ cygdrive / c / Program Files / Intel / Intel(R)管理引擎组件/ IPT:/ cygdrive / c / Program Files(x86)/ NVIDIA Corporation / PhysX / Common:/ cy gdrive / c / WINDOWS / System32 / OpenSSH:/ cygdrive / c / Install / x86 / IVI Foundation / VISA / AllVers / WinNT / Bin:/ cygdrive / c / Program Files / IVI Foundation / VISA / Win64 / Bin:/ cygdrive / c / Install / x86 / IVI Foundation / VISA / AllVers / WinNT / Bin:/ cygdrive / e / Work / Dev / Utils / cfati-5510-0 / windows:/ cygdrive / c / Install / x64 / NVidia / GPU Computing Toolkit /cuDNN/AllVers/bin:/cygdrive/c/Users/cfati/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/Install/Qt/Qt/5.9.1/msvc2015/bin


因此, 32位 .dll 存在(由上述软件包安装),但找不到它,因为它的目录不在 $ {PATH} 中(由于内容的长度,这不是立即可见的)。请注意,在这种情况下, Cygwin 不接受 $ {LD_LIBRARY_PATH}



显而易见的步骤是,通过在 $ {PATH} (在开头的 )中添加其dir,从而使系统知道此 .dll 。 :


  [cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]>导出PATH = / usr / i686-pc-cygwin / sys-root / usr / bin:$ {PATH} 
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577] > ./exe-gcc-032.exe
void *长32位。
[cfati @ cfati-5510-0:/ cygdrive / e / Work / Dev / StackOverflow / q054206577]> ./exe-gcc-064.exe
void *的长度为64位。


您去了。



最终笔记




  • 64位 ldd ,它是一个 .exe (不同于在脚本中的 Nix 上)不能妥善处理 32位工件的依赖性。不幸的是, cygwin32-binutils 软件包没有提供不会出现此问题的 32位副本,因此,目前为止,它已经足够好了

  • 运行 .exe 时可能会遇到一些问题,因为 cygwin1.dll 版本( > rxvt-native.exe ,并且系统上已经存在)。如果是这样,建议您启动 Cygwin 32 环境,获取 cygwin 软件包版本(将其称为 $ {CYGWIN_PKG_VER} em> ),然后在 Cygwin 64t 环境中,安装最接近 $ {CYGWIN_PKG_VER} cygwin32 版本。 li>


@ EDIT0



我添加了 system( echo $ {PATH}); (并且隐含地 #include< stdlib.h> )在我的测试程序中,并且在 32位变体上, system 返回了 127 (就像 exe-gcc-032.exe 的退出代码(如果没有正确的路径)。我怀疑这2个不是无关的,启动 32位应用程序时环境会发生一些变化,可能 rxvt-native 尝试启动 bash (或其他任何命令)通过 system



@ EDIT1



因此,可以从 Cygwin 64 运行 32位应用程序>(进行简短检查,没有透露任何官方消息表明它是不受支持的配置)。但是在这种情况下,由于该应用程序很复杂(这是一个终端,需要运行多个其他应用程序),因此会出现问题。进一步的可能方法(有人建议的其他方法):




  • 放手的时间(也许有充分的理由不这样做) t移植)。切换到现代替代产品( Mintty

  • 搜索 rxvt 的非官方预构建的 64位版本,或尝试自己构建它(有些人喜欢它)

  • 同时具有两种环境( Cygwin 32 Cygwin 64 )安装在您的 PC


    • 使用您喜欢的终端(来自Cygwin 32 )。这将是您的主要环境

    • 远程管理 Cygwin 64 ,例如通过:


      • ssh :我没有检查有关2个 sshd的限制在同一台计算机上并行运行,但是如果没有,您应该为其中之一更改监听端口的默认端口( 22 )。我建议对前者这样做,以便可以使用默认设置从外部使用后者



  • 继续朝这个方向进行研究,但据我所知,它已经开始成为城堡卡了(如果还没有的话)-这似乎更像是一种变通方法( gainarie


Is it possible to run a 32-bit Cygwin application in a 64-bit installation?

Motivation: As discussed in Where's the rxvt-native utility gone in cygwin 1.7.26 for 64bit windows?, rxvt-native, my favourite terminal emulator in Windows, is not currently available in 64 Cygwin. My hope is that just like I can run 32-bit Linux applications on 64-bit Linux distros, maybe I could run the 32-bit rxvt on 64-bit Cygwin.

I have tried copying the executable from my old PC's C:\cygwin\bin directory to my new PC's C:\cygwin64\usr\local\bin directory but it is not able to run it.

When I run the process, it just silently does nothing.

ldd tells me some dependencies are missing:

$ ldd /usr/local/bin/rxvt-native.exe
        ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x7ffcb79b0000)
        ??? => ??? (0x77a10000)
        wow64.dll => /cygdrive/c/Windows/System32/wow64.dll (0x62c20000)
        wow64win.dll => /cygdrive/c/Windows/System32/wow64win.dll (0x62c80000)

I have tried copying the cygwin1.dll file from my 32-bit system but I'm not sure how to make it available only to this process without hiding the 64-bit one from other processes.

My next option is to uninstall my 64-bit cygwin and start again with the 32-bit variant, but I'm still hoping there's a way... Thanks for any help you can provide.

解决方案

Like any Lnx distribution, the Cygwin 64 emulator allows running 32 bit executables (as long as they are compatible). You only need to either have:

  • The right packages installed
  • The right .dlls in the right place (as you mentioned) - but manually copying them (especially in system locations) is neither scalable, nor does it guarantee that the system will properly work afterwards

First, you'd need the cygwin32 package (at least) installed:

Since I don't have your 32 bit executable (I didn't fell like searching downloading, unpacking, and so on ...), I created a small example (to make it run, you'd need the gcc toolchains as well - which I have for other purposes, but anyway this is not related to the question) that reproduces the behavior.

code.c:

#include <stdio.h>


int main() {
    printf("\"void*\" is %d bits long.\n", sizeof(void*) * 8);
    return 0;
}

Output:

[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> uname -a
CYGWIN_NT-10.0 cfati-5510-0 2.11.2(0.329/5/3) 2018-11-08 14:34 x86_64 Cygwin
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> ls
code.c
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> x86_64-pc-cygwin-gcc.exe -o exe-gcc-064.exe code.c
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> i686-pc-cygwin-gcc.exe -o exe-gcc-032.exe code.c -m32
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> ls -al
total 433
drwxrwx---+ 1 Administrators None      0 Jan 16 12:45 .
drwxrwx---+ 1 Administrators None      0 Jan 16 10:33 ..
-rwxrwx---+ 1 Administrators None    118 Jan 16 10:39 code.c
-rwxrwxr-x+ 1 cfati          None 151062 Jan 16 12:45 exe-gcc-032.exe
-rwxrwxr-x+ 1 cfati          None 157755 Jan 16 12:45 exe-gcc-064.exe
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]>
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> file exe-gcc-064.exe
exe-gcc-064.exe: PE32+ executable (console) x86-64, for MS Windows
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> ldd exe-gcc-064.exe
        ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffcaf990000)
        KERNEL32.DLL => /cygdrive/c/WINDOWS/System32/KERNEL32.DLL (0x7ffcaf300000)
        KERNELBASE.dll => /cygdrive/c/WINDOWS/System32/KERNELBASE.dll (0x7ffcabe60000)
        cygwin1.dll => /usr/bin/cygwin1.dll (0x180040000)
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> ./exe-gcc-064.exe
"void*" is 64 bits long.
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]>
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> file exe-gcc-032.exe
exe-gcc-032.exe: PE32 executable (console) Intel 80386, for MS Windows
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> ldd exe-gcc-032.exe
        ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffcaf990000)
        ??? => ??? (0x77150000)
        wow64.dll => /cygdrive/c/WINDOWS/System32/wow64.dll (0x7ffcaf800000)
        wow64win.dll => /cygdrive/c/WINDOWS/System32/wow64win.dll (0x7ffcad570000)
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> ./exe-gcc-032.exe
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]>
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> echo $?
127

As you can see, I ran into the exact same problem for exe-gcc-032.exe. The ??? dependency is the 32 bit cygwin1.dll. Let's explore the problem:

[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> find /usr -name cygwin1.dll
/usr/i686-pc-cygwin/sys-root/usr/bin/cygwin1.dll
/usr/bin/cygwin1.dll
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> cygcheck -f /usr/bin/cygwin1.dll
cygwin-2.11.2-1
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> file /usr/bin/cygwin1.dll
/usr/bin/cygwin1.dll: PE32+ executable (DLL) (console) x86-64, for MS Windows
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]>
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> cygcheck -f /usr/i686-pc-cygwin/sys-root/usr/bin/cygwin1.dll
cygwin32-2.10.0-1
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> file /usr/i686-pc-cygwin/sys-root/usr/bin/cygwin1.dll
/usr/i686-pc-cygwin/sys-root/usr/bin/cygwin1.dll: PE32 executable (DLL) (console) Intel 80386 (stripped to external PDB), for MS Windows
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]>
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> echo ${PATH}
/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Install/x64/NVidia/GPU Computing Toolkit/CUDA/AllVers/bin:/cygdrive/c/Install/x64/NVidia/GPU Computing Toolkit/CUDA/AllVers/libnvvp:/cygdrive/c/Install/x86/Borland/Delphi/7/Bin:/cygdrive/c/Install/x86/Borland/Delphi/7/Projects/Bpl:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Program Files (x86)/Intel/iCLS Client:/cygdrive/c/Program Files/Intel/iCLS Client:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Install/x86/IVI Foundation/VISA/AllVers/WinNT/Bin:/cygdrive/c/Program Files/IVI Foundation/VISA/Win64/Bin:/cygdrive/c/Install/x86/IVI Foundation/VISA/AllVers/WinNT/Bin:/cygdrive/e/Work/Dev/Utils/cfati-5510-0/windows:/cygdrive/c/Install/x64/NVidia/GPU Computing Toolkit/cuDNN/AllVers/bin:/cygdrive/c/Users/cfati/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/Install/Qt/Qt/5.9.1/msvc2015/bin

So, the 32 bit .dll exists (installed by the above package), but it can't be found, as its dir is not in ${PATH} (due to the content length this isn't immediately visible). Note that Cygwin doesn't honour ${LD_LIBRARY_PATH} in this scenario.

The obvious step is to let the system know about this .dll, by adding its dir in ${PATH} (at the beginning):

[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> export PATH=/usr/i686-pc-cygwin/sys-root/usr/bin:${PATH}
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> ./exe-gcc-032.exe
"void*" is 32 bits long.
[cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackOverflow/q054206577]> ./exe-gcc-064.exe
"void*" is 64 bits long.

There you go.

Final notes:

  • (64 bit) ldd which is an .exe (unlike on Nix, where it's a script), doesn't gracefully handle dependencies for 32 bit artefacts. Unfortunately, cygwin32-binutils package doesn't provide a 32 bit counterpart that wouldn't have this problem, so at the current moment this is as good as it gets
  • You might run into some issues when running your .exe, because of possible differences between cygwin1.dll versions (the one that rxvt-native.exe expects, and the one present on the system). If so, I'd suggest that you start your Cygwin 32 environment, get the cygwin package version (let's call it ${CYGWIN_PKG_VER}), and on the Cygwin 64t environment, install the cygwin32 version that is closest to ${CYGWIN_PKG_VER}

@EDIT0:

I added system("echo ${PATH}"); (and implicitly #include <stdlib.h>) in my test program, and on the 32 bit variant, system returned 127 (just like exe-gcc-032.exe's exit code when not having the proper path). I suspect the 2 can't be unrelated, and something happens with the environment, when launching 32 bit applications, and probably rxvt-native tries to launch bash (or any other command) via system.

@EDIT1:

So, it is possible to run a 32 bit application from Cygwin 64 (a brief check, didn't reveal any official sources stating that it's an Unsupported Configuration). But in this particular case, since the app is complex (it's a terminal, required to run multiple other applications), there is a problem. Possible ways (some suggested by other people) to go further:

  • Time to let go (probably there is a good reason why it wasn't ported). Switch to a modern replacement (Mintty)
  • Search for an unofficial prebuilt 64 bit version of rxvt, or try building it yourself (there are some other people who like it)
  • Have both environments (Cygwin 32 and Cygwin 64) installed on your PC
    • Use your favorite terminal (from Cygwin 32). This will be your "main" environment
    • Administrate Cygwin 64 "remotely", e.g. via:
      • ssh: I didn't check for restrictions regarding the 2 sshds running in parallel on the same machine, but if there aren't any, you should change the listening port from default (22) for one of them. I'd suggest to do that for the former, so that the latter is available from "outside" using default settings
  • Continue research on this direction, but as I see things, it's starting (if it hasn't already) to become a castle card - this seems more like a workaround (gainarie)

这篇关于您可以在64位安装中运行32位Cygwin应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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