简体   繁体   中英

how to install msys2 into base mingw directory

I was wondering if there is a way in MSYS2 to specify the base MinGW/MinGW64 directory?

In MSYS (ie, MSYS-1), after installing MSYS, it knows that the directory structure is, eg, /c/mingw/msys/... , and if you install a mingw package using mingw-get , the installed binary goes to /c/mingw/bin . I think this might be because there is /mingw mount in the default /etc/fsab .

Now, when I do a similar operation under MSYS2/MinGW64 with MSYS2 at /c/mingw/msys64 , the binary isn't installed the /c/mingw/bin anymore. For example, if I install clang as follows:

pacman -S mingw-w64-x86_64-clang

the binary is installed to:

/c/mingw/msys64/mingw64/bin/clang.exe

as if MSYS2 were creating another mingw64 installation within itself (with bin/lib/etc/share ...). This confuses MinGW64, as it reports that clang cannot be found. I know I can add another path, but it's rather weird to have one MinGW installation at the root, and another inside a subfolder of MSYS2. And I suspect this could cause inconsistency in the tool-chain in the future.

My question is, is there a way to let MSYS2 install MinGW packages to the MinGW directory tree as with MSYS ?

Thanks

To say that you have "another mingw64 installation within itself" is the wrong way to think about it. MSYS2 is the system that is running the show, that you chose to put it in a folder called "C:/mingw" doesn't make that folder a mingw-w64 system in any way, you've just got an MSYS2 system rooted at "C:/mingw/msys64"

I'm afraid that MSYS2 doesn't allow selection of root folders for any of its 3 repositories outside of selecting the global system root (ie the folder to which you install or unpack MSYS2). The main reason for this is because we use pacman as our package manager and this facility doesn't exist there since it is a tool to manage the entire system and as such, all pacman packages are compressed with absolute folders (which are unpacked relative to the global system root).

Since MSYS2 (via Cygwin; credit for the core of MSYS2 lies with Cygwin) provides "/etc/fstab", you might think to use that to enable you to put "/mingw{32,64}" elsewhere, and to an extent you can get away with that, but I strongly urge you not to do this as it will just result in problems. For example, Native Windows programs that expect to be able to use a relative path of "../" to get from "C:/msys64/mingw64" to "C:/msys64" will be sorely disappointed, and by that I mean will they will likely crash. For this reason I am not going to tell you how to achieve such a broken system.

You should try to think of your MSYS2 install as being a complete sub-system in its own right, where we've made some decisions (like the location of the "/", "/mingw32" and "/mingw64" folders) for you to improve compatibility and remove some variables that would make problems more frequent and difficult to diagnose and fix.

I would also recommend installing MSYS2 to the root of a drive (any drive) due to Windows 260 MAXPATH limit. I know that with UNC paths the limit is much further out, but most MSYS2 and Windows software do not use UNC paths and have hardcoded C string arrays of size MAXPATH+1 all over the place. Doing this may also help you to think of the MinGW-w64 repositories as being sub-repositories of the overall MSYS2 system, rather than the other way around.

For pacman reference, you should use these pages:

pacman.conf(5) Manual Page and pacman tips

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM