Cygwin在Visual Studio中 [英] Cygwin in Visual Studio

查看:239
本文介绍了Cygwin在Visual Studio中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将一个旧的程序,我写的类从KDev在Ubuntu到Windows Visual Studio 2008使用Cygwin作为一个个人学习练习。我有include路径配置为包括 C:\cygwin\usr\include ,但它不正确读取.h文件。



也就是说,我想知道如何在Visual Studio环境中使用cygwin使用unix sockets.h 功能。有没有人得到这个工作或有一个更简单的方法去这样做?

解决方案

有几种方法去可以使其工作,这取决于你的确切目标。最简单的方法可能是创建一个Visual Studiomakefile项目,触发自定义构建命令以运行您构建的makefile。但是,这让你远离Visual Studio作为IDE的许多好处,所以我猜这不是真正的你以后。



如果你想要一个更完全集成的解决方案,你需要做两件事。首先,你需要改变你的所有include / library路径,以避免Microsoft的,并去Cygwin之后,而不是。您可以通过从菜单中选择工具 - >选项,然后从出现的窗口左侧的树中选择项目和解决方案 - > VC ++目录来实现。你可以选择更改可执行文件,头文件,库等的搜索目录。对于你想要做的事情,我建议删除一切并添加到cygwin目录中。 / p>

其次,你必须告诉Visual Studio使用gcc / g ++编译器。这有点棘手。 VS支持自定义文件类型的自定义构建规则...但似乎有C ++硬件在Microsoft编译器。我真的不知道一个伟大的方式,除了使用您自己的自定义文件扩展名。你可以尝试.c(C文件)和.cc(C ++文件)的标准unix扩展,但我怀疑Visual Studio将自动拾取。



如果您在解决方案资源管理器中右键单击项目并选择自定义构建规则,您将获得一个界面这将允许您为您选择的文件扩展名创建自定义构建规则。这个界面比较简单。



这可能不会给你你想要的,但它可能是你要使用Visual Studio。


I'm trying to port an old program I wrote for class from KDev in Ubuntu to Windows Visual Studio 2008 using Cygwin as a personal learning exercise. I have the include path configured to include C:\cygwin\usr\include but it doesn't read the .h files properly.

Namely I'm curious as to how one would go about using unix sockets.h functionality in a Visual Studio environment using Cygwin. Has anybody ever got this working or have an easier way to go about doing this?

解决方案

There are several ways to go about this that could be made to work, depending upon your exact goals. The simplest way is probably just to create a Visual Studio "makefile" project that fires off a custom build command to run a makefile you've built. But that keeps you away from a lot of the nice benefits of Visual Studio as an IDE, so I'm guessing that's not really what you're after.

If you want a more fully integrated solution, you're going to need to do two things. First of all, you're going to need to change out all of your include/library paths to avoid the Microsoft ones and go after the Cygwin ones instead. You can do this by selecting "Tools->Options" from the menu, then choosing "Projects and Solutions->VC++ Directories" from the tree on the left hand side of the window that comes up. You'll have options to change the search directories for executables, headers, libraries, etc. For what you're trying to do, I'd suggest removing everything and adding in just the cygwin directories.

Second, you'll have to tell Visual Studio to use the gcc/g++ compiler. This is a bit trickier. VS supports custom build rules for custom file types... but it seems to have C++ hardwired in for the Microsoft compiler. I don't really know a great way around that except to use your own custom file extension. You can try the standard unix extensions of .c (C files) and .cc (C++ files), but I suspect Visual Studio will automatically pick up on those. You may have to go with something totally foreign.

If you right click on your project in the Solution Explorer and select "Custom Build Rules" you'll be given an interface that will let you create your custom build rules for the file extension you've chosen. The interface is relatively straightforward from there.

This might not get you exactly what you wanted, but it's probably about as close as you're going to get with Visual Studio.

这篇关于Cygwin在Visual Studio中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆