make---linux和windows格式
我遇到了一个大问题..我已经在 Linux 操作系统中使用 linux make 文件编译了我的 c 文件。
我想通过命令提示符使用相同的 make 文件在 Windows 中编译相同的文件。 为此,我也有 nmake 实用程序和 Cygwin 实用程序。
我已经使用简单的程序和简单的 make 文件成功地完成了这一点。
但是当我使用复杂的 C 文件和复杂的 make 文件时,无法编译。
我已将 linux make 文件中的“/”更改为 Windows 中的“\”? 还有什么改变吗?
我想知道“Windows 中是否有特殊的 make 文件格式?”
还有它们之间的区别..
我真的需要那个......
I am in a big problem ..i have compiled my c files using linux make file in Linux OS.
I want to compile the same files in Windows using the same make file by command prompt. For that i have nmake utility and Cygwin utility too.
I have done that successfully with simple programs with simple make file ..
But it is not possible to compile when i was using the complex C files with complex make file.
I have changed the '/' in linux make file to '\' in windows? Anyother changes?
I want to know 'Is there any special make file formats in windows?'
also the difference between them..
I am really in need of that...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
不幸的是,nmake 只是松散地受到 make 的启发,并且他们没有把很多重要的事情做对。 到目前为止,最简单的事情就是首先在两个平台上拥有相同的制作风格。
在 Linux 上,Gnu make 是默认且最佳的选择。
在 Windows 上,有多个 Gnu make 源,其中有一些怪癖可供选择。 就我个人而言,我主要使用来自 GnuWin32 项目的 Gnu make 的本机 win32 版本。 您可能想查看该项目的其余包,因为其他一些包也很有用。
替代来源是 Cygwin 和 MinGW32/MSYS。
Cygwin 是在 Windows 内核之上提供 *nix 兼容环境的可靠尝试。 它由一个 DLL 组成,该 DLL 导出大量通过 Windows API 实现的 *nix(尤其是 POSIX)系统调用。 该 DLL 对于磁盘挂载也有自己的想法,并且更喜欢 *nix 样式的路径名。 DLL 本身已获得 GPL 许可(尽管商业用途许可证需要付费),并且在 Cygwin 环境中构建的程序默认需要它,因此这可能是一个需要考虑的因素。 另一个因素是Cygwin对普通Windows用户不友好,因此基于它的开发项目通常对非unix用户来说很难处理。 然而,对于跨平台开发人员来说,Cygwin 非常有用,因为它可以为您提供 Makefile 所需的所有常见的可疑实用程序,并且它包括针对 MinGW32 的本机 Windows 目标 GCC 以及针对 Cygwin 环境的 GCC。
MinGW32 是一个移植项目,在移植 GCC 编译器以作为本机 Windows 可执行文件运行方面做得非常好。 如果与它们提供的头文件一起使用,则可以通过现代 Windows 安装附带的 C 运行时 DLL 使用几乎所有 Windows API。
MSYS 是 Cygwin 的轻量级分支,包含一组最小的实用程序(从 *nix shell 开始),通常假定典型的 *nix Makefile 存在这些实用程序。 与 Cygwin 不同,MSYS 的配置使得默认目标是本机 Windows API。
我在这里试图暗示的,也许应该直白地说,你的兼容性问题不会随着你使用的方言而结束。
Makefile 语言本身高度依赖于可用的命令 shell,大多数严肃的项目 Makefile 最终都会使用许多 *nix 核心实用程序,例如 cp 和 rm。
我强烈建议从 make 的 GnuWin32 版本开始,并安装 MinGW32 和 MSYS。 这样,编写一个在 MSYS 和 linux 下都可以工作的 Makefile 就相对容易了,并且只需要少量的特定于平台的逻辑。
Unfortunately, nmake was only loosly inspired by make, and they didn't get many important things right. By far the easiest thing to do is to start by having the same flavor of make on both platforms.
On linux, Gnu make is the default and best option.
On Windows, there are several sources for Gnu make, with some quirks to choose among. Personally, I mostly use the native win32 build of Gnu make from the GnuWin32 project. You might want to poke around at the rest of the project's packages because some of the others will be useful to have as well.
Alternative sources are Cygwin and MinGW32/MSYS.
Cygwin is a credible attempt at providing a *nix compatibility environment on top of the Windows kernel. It consists of a DLL that exports a huge percentage of *nix (especially POSIX) system calls implemented via the Windows API. That DLL also has its own idea about disk mounts and prefers *nix-style path names. The DLL itself is licensed GPL (although a commercial-use license is available for a fee), and programs built in the Cygwin environment require it by default, so that can be a factor to consider. Another factor is that Cygwin is not friendly to normal Windows users, so development projects based on it usually end up difficult for non-unix users to deal with. For a cross-platform developer, however, Cygwin can be really useful as it gets you all of the usual suspect utility programs required by your Makefile, and it includes the MinGW32 native Windows targeted GCC as well as a GCC targeting the Cygwin environment.
MinGW32 is a porting project that did a really good job of porting the GCC compilers to run as native Windows executables. If used along with the header files they supply, it is possible to use nearly all of the Windows API via a C runtime DLL that ships with modern Windows installations.
MSYS is a lightweight fork of Cygwin that contains a minimal set of utilities (starting with a *nix shell) that are usually assumed to exist by a typical *nix Makefile. Unlike Cygwin, MSYS is configured such that the default target is the native Windows API.
What I'm trying to hint at here, and probably should just state flat out, is that your compatibility issues don't end with the dialect of make you use.
The Makefile language itself is highly dependent on the command shell available, and most serious project Makefiles end up using many of the *nix the core utilities such as cp and rm.
I would strongly recommend starting with the GnuWin32 build of make, and also installing MinGW32 and MSYS. It is then relatively easy to write a Makefile that works under both MSYS and linux, and needs only a small amount of platform-specific logic.
您应该考虑使用 CMake 进行跨平台 make,但真正的问题是您不必将“/”更改为“\”。 如果您在 cygwin 或 msys(推荐)下运行,这应该会为您处理。
You should consider CMake for cross-platform make but your real problem is you shouldn't have to change the '/' to '\'. If you run under cygwin or msys (recommended) this should be handled for you.
NMake 是一个 Windows 工具,只会解析 Windows 风格的路径,即带有驱动器号和反斜杠的路径。 因此,您应该使用与 cygwin 一起安装的 GNU Make。
NMake is a windows tool and will parse only windows-style paths, i.e. paths with drive letters and backslashes. Therefore you should use GNU Make installed with cygwin.
nmake 应该读取你的 makefile,差异通常是在 make 版本之间而不是操作系统之间。
最大的问题是您的目标平台实际上是什么,您是试图让此代码在 Windows 中本机运行还是希望在 Cygwin 下运行?
nmake should read your makefiles okay, the differences are generally between versions of make rather than OSs.
The big question is what your target platform actually is, are you trying to make this code operate in Windows natively or are you looking to run it under Cygwin?
在两个平台上使用 gnumake。 我愿意。 我已经很多年没有碰过 Visual C 了。
Use gnumake on both platforms. I do. I haven't touched Visual C in years.
nmake有它自己的格式而不是windows本身,所以makefile格式与make工具有关而不是与操作系统有关。 对于简单的事情,g(nu)make 和 nmake 的格式类似,正如人们之前建议的那样,考虑仅使用 gmake。
nmake got it's own format rather than windows itself, so makefile format is related to make tool rather than os. For simple things format is similar for g(nu)make and nmake, as people suggested before consider using gmake only.