首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >安装MSYS(2)后,我如何简单地使用纯明GCC?

安装MSYS(2)后,我如何简单地使用纯明GCC?
EN

Stack Overflow用户
提问于 2020-04-04 11:09:27
回答 2查看 2.7K关注 0票数 1

所以我在网上读过书,但还是很困惑。我了解到在Linux on Windows世界中有不同的工具: Msys、Msys2、Cygwin、明威和明威-64。

以下是我认为我知道的,如果我错了,请纠正我:

  1. 明威的目标仅仅是成为GCC程序到Windows的一个端口。它创建了本机Windows二进制文件,仅此而已。
  2. 明珠- 64只是一个更新的、更受支持的版本,它也支持Windows 64位。
  3. Cygwin,同时还包括

(?)为了在Windows上支持GCC,可以通过所有程序默认链接的DLL提供POSIX兼容层。

  1. MSYS是Cygwin的一个分支,但它放弃了POSIX兼容性的一些努力。相反,它的主要目标是允许创建本机Windows程序。但是--它们仍然将依赖于一个MSYS DLL的存在。
  2. MSYS2只是一个更新的、更活跃的MSYS.

版本。

这都是真的吗?如果是的话,下面是我要验证的内容:

从本质上讲,我认为我的开发所需要的全部是明,以便使用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来编译我的项目。

  1. ,这是一种有效的方式使用明?还是我会遇到problems?
  2. Does这种方法创建纯-related本机二进制文件,而不应该依赖于任何MSYS(2)-related DLL?
  3. 是否真的只有当我通过msys2.exe程序启动明珠程序(例如GCC)时,才能使用MSYS(2)-related功能和依赖关系?因此,如果我想避免使用任何MSYS(2)或Cygwin相关的东西,而只使用纯明GCC,那么像前面所描述的那样,直接在明珠目录下启动GCC是否是一种好方法?

更新:我现在已经使用dependencies检查了,在MSYS2 shell中运行C:\msys64\mingw64\bin\gcc仍然可以创建一个没有特殊依赖项的.exe (这很好)。那么,这个msys-2.0.dll是MSYS2文档提到的什么呢?使用MSYS2编译C与仅仅使用Mingw有什么不同?

EN

Stack Overflow用户

发布于 2020-04-05 02:01:36

我强烈建议使用MSYS2而不是MSYS和mingw.org。假装后两者根本不存在。在积极的发展中,更新的项目在各个方面都更好。

MSYS2 2的包管理器可以为下列目标系统提供工具链:

(i686)

  • Standalone
  • Win32 Win64 (x86_64)
  • MSYS2 i686
  • MSYS2 x86_64

前两种情况可以从您喜欢的任何shell中调用。如果不使用MSYS2提供的启动脚本,则可能需要设置路径。它们产生本机Windows可执行文件。使用默认的开关到GCC,就会有一些依赖项,比如libgcc_s*.dll。使用-static进行静态构建将生成除了Windows之外没有依赖项的可执行文件。

在后两种情况下,二进制文件将依赖于MSYS2 DLL和其他内容,但这提供了对一系列POSIX功能的支持。

代码语言:javascript
运行
复制
[~ 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的分叉。

票数 1
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61027176

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档