所以我在网上读过书,但还是很困惑。我了解到在Linux on Windows世界中有不同的工具: Msys、Msys2、Cygwin、明威和明威-64。
以下是我认为我知道的,如果我错了,请纠正我:
(?)为了在Windows上支持GCC,可以通过所有程序默认链接的DLL提供POSIX兼容层。
版本。
这都是真的吗?如果是的话,下面是我要验证的内容:
从本质上讲,我认为我的开发所需要的全部是明,以便使用GCC来构建本机Windows应用程序。我不需要POSIX层,我也不希望我的程序依赖于任何DLL,除了Windows系统上存在的DLL。据我所知,这就是明伟所提供的。
但是,不知何故,我成功地安装了MSYS (或MSYS2?我不再确定了)在我的系统。我早期遵循的教程建议这样做。
由于MSYS(2)似乎在C:\msys64\mingw64
下包含了Mingw,所以我只是直接从Windows中使用Mingw二进制文件,而不需要通过MSYS(2) shell程序。例如,我只是将C:\msys64\mingw64\bin
添加到PATH
中,然后直接从Windows运行gcc
来编译我的项目。
更新:我现在已经使用dependencies检查了,在MSYS2 shell中运行C:\msys64\mingw64\bin\gcc
仍然可以创建一个没有特殊依赖项的.exe
(这很好)。那么,这个msys-2.0.dll
是MSYS2文档提到的什么呢?使用MSYS2编译C与仅仅使用Mingw有什么不同?
发布于 2020-04-05 02:01:36
我强烈建议使用MSYS2而不是MSYS和mingw.org。假装后两者根本不存在。在积极的发展中,更新的项目在各个方面都更好。
MSYS2 2的包管理器可以为下列目标系统提供工具链:
(i686)
前两种情况可以从您喜欢的任何shell中调用。如果不使用MSYS2提供的启动脚本,则可能需要设置路径。它们产生本机Windows可执行文件。使用默认的开关到GCC,就会有一些依赖项,比如libgcc_s*.dll
。使用-static
进行静态构建将生成除了Windows之外没有依赖项的可执行文件。
在后两种情况下,二进制文件将依赖于MSYS2 DLL和其他内容,但这提供了对一系列POSIX功能的支持。
[~ MSYS]$ ls /usr/include
_ansi.h cursesp.h glob.h net strings.h
_newlib_version.h cursesw.h gnumake.h netdb.h symcat.h
_syslist.h cursslk.h grp.h netinet sys
a.out.h cygwin icmp.h newlib.h sysexits.h
acl devctl.h ieeefp.h nl_types.h syslog.h
aio.h diagnostics.h ifaddrs.h panel.h tar.h
alloca.h dirent.h inttypes.h paths.h term.h
alpm.h dis-asm.h io.h plugin-api.h term_entry.h
alpm_list.h dlfcn.h langinfo.h poll.h termcap.h
ansidecl.h elf.h lastlog.h process.h termio.h
ar.h endian.h libfdt.h pthread.h termios.h
argz.h envlock.h libfdt_env.h pty.h tgmath.h
arpa envz.h libgen.h pwd.h threads.h
asm err.h limits.h reent.h tic.h
assert.h errno.h locale.h regdef.h time.h
attr error.h machine regex.h tzfile.h
bfd.h eti.h magic.h resolv.h ucontext.h
bfd_stdint.h etip.h malloc.h sched.h unctrl.h
bfdlink.h fastmath.h mapi.h search.h unistd.h
bits fcntl.h math.h semaphore.h utime.h
byteswap.h fdt.h memory.h setjmp.h utmp.h
complex.h features.h menu.h signal.h utmpx.h
cpio.h fenv.h mntent.h spawn.h w32api
ctf.h FlexLexer.h monetary.h ssp wait.h
ctf-api.h fnmatch.h mqueue.h stdatomic.h wchar.h
ctype.h form.h nc_tparm.h stdint.h wctype.h
curses.h fts.h ncurses stdio.h winpty
cursesapp.h ftw.h ncurses.h stdio_ext.h wordexp.h
cursesf.h gawkapi.h ncurses_dll.h stdlib.h xlocale.h
cursesm.h getopt.h ncursesw string.h
[~ MSYS]$
[~ MSYS]$
[~ MSYS]$ ls /usr/include/sys
_default_fcntl.h acl.h fcntl.h mman.h quota.h signal.h stdio.h termio.h ttychars.h utsname.h
_intsup.h cdefs.h features.h mount.h random.h signalfd.h strace.h termios.h types.h vfs.h
_pthreadtypes.h config.h file.h msg.h reent.h smallprint.h string.h time.h ucontext.h wait.h
_sigset.h custom_file.h iconvnls.h mtio.h resource.h socket.h sysinfo.h timeb.h uio.h xattr.h
_stdint.h cygwin.h ioctl.h param.h sched.h soundcard.h syslimits.h timerfd.h un.h
_timespec.h dir.h ipc.h poll.h select.h stat.h syslog.h times.h unistd.h
_timeval.h dirent.h kd.h procfs.h sem.h statfs.h sysmacros.h timespec.h utime.h
_types.h errno.h lock.h queue.h shm.h statvfs.h sysproto.h tree.h utmp.h
Cygwin是一个竞争产品,它还提供POSIX功能,并依赖于Cygwin。MSYS2目标是Cygwin的分叉。
https://stackoverflow.com/questions/61027176
复制相似问题