简体   繁体   English

使用Mingw构建环境C ++?

[英]Build Environment C++ using Mingw?

I haven't programmed for a while and am trying to set up my build environment on a new laptop. 我已经有一段时间没有编程了,正在尝试在新笔记本电脑上设置构建环境。 I've just forgotten how and think that I did allot of things wrong last time! 我忘了怎么做,以为我上次分配错误的东西!

What I'm trying to do is have that common Include Directory and common Lib directory so when I build projects or other dependencies, etc... my compiler is able to find all the include and lib files it needs. 我想做的是拥有通用的包含目录和通用的Lib目录,以便在构建项目或其他依赖项等时……我的编译器能够找到所需的所有包含和lib文件。 I'm not formally trained so some obvious things to you guys are learning points for me. 我没有接受正式培训,因此对你们来说一些显而易见的事情对我来说是学习的要点。

I'm going to use a Mingw compiler and MSYS. 我将使用Mingw编译器和MSYS。 Off memory I put the Include directory and the lib directory in the Mingw directory but I could be wrong there. 内存不足时,我将Include目录和lib目录放在Mingw目录中,但在那儿我可能是错的。

I'm just trying to set up an effective and simple build environment on Windows 7. 我只是想在Windows 7上建立有效且简单的构建环境。

Where should all my directories go? 我所有的目录都应该放在哪里? Thanks 谢谢

If you aren't already, MSYS2 is generally preferred over MSYS. 如果您还不是MSYS2,则通常比MSYS更受青睐。 I'm going to answer this assuming MSYS2. 我将假设MSYS2回答这个问题。 I use the 64 bit version, so that is what I'll show, but it should be simple enough to change. 我使用的是64位版本,这就是我要演示的内容,但是更改应该足够简单。

I will also assume you put the msys64 directory in the base directory, if not replace C:/msys64/ with C:/wherever/you/put/it/msys64/ . 我还将假设您将msys64目录放在基本目录中,如果不将C:/msys64/替换为C:/wherever/you/put/it/msys64/

When using the msys shell, /c/msys64/usr/ is the same as C:/msys64/usr/ which is the same as /usr/ since it tries to blend Linux file organization with windows, and it can sometimes be slightly unintuitive. 使用msys shell时, /c/msys64/usr/C:/msys64/usr/相同,与/usr/相同,因为它试图将Linux文件组织与Windows混合在一起,有时可能有些不直观。 When you install msys libraries, usually the include files are in C:/msys64/usr/include/ and the libraries are in C:/msys64/usr/lib/ . 安装msys库时,通常包含文件位于C:/msys64/usr/include/ ,而库位于C:/msys64/usr/lib/ The exception to this is when you have a 64-bit version and a 32-bit version of a program, in which case the headers are in C:/msys64/mingw64/include/ and the libs in C:/msys64/mingw64/lib/ for 64-bit ( mingw32 for 32 bit). 例外是当您具有程序的64位版本和32位版本时,在这种情况下,头文件位于C:/msys64/mingw64/include/ ,而libs位于C:/msys64/mingw64/lib/用于64位( mingw32用于32位)。

In order to build using these, you will need to add the appropriate include paths and library paths. 为了使用它们进行构建,您将需要添加适当的包含路径和库路径。 So, to make all 64-bit programs available, you would add the following flags 因此,要使所有64位程序可用,您将添加以下标志

-IC:/msys64/usr/include -IC:/msys64/mingw64/include -LC:/msys64/usr/lib -LC:/msys64/mingw64/lib

When you compile your own programs from source, you put them wherever you'd like. 当您从源代码编译自己的程序时,可以将它们放在任意位置。 It is best not to put them in the same directory as the package manager to avoid collisions. 最好不要将它们与软件包管理器放在同一目录中,以免发生冲突。 Running make install sometimes won't run as seamlessly on msys as it would on linux. 有时,运行make install在msys上无法像在Linux上那样无缝地运行。 In these cases, creating a folder such as C:/msys64/custom/include/ is a safer alternative. 在这些情况下,创建一个诸如C:/msys64/custom/include/的文件夹是一种更安全的选择。 See https://unix.stackexchange.com/questions/30/where-should-i-put-software-i-compile-myself for some more insight on this. 有关此问题的更多信息,请参见https://unix.stackexchange.com/questions/30/where-should-i-put-software-i-compile-myself

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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