若干问题的Cygwin [的Linux在Windows(插座,线,其他的编程和外壳的问题) [英] Some Issues About Cygwin[Linux in Windows] (socket,thread,other programming and shell issues)

查看:181
本文介绍了若干问题的Cygwin [的Linux在Windows(插座,线,其他的编程和外壳的问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些cygwin的问题:结果


  1. 我可以使用Cygwin开发基于套接字code?结果

  2. Cygwin的是否有阅读()的write()与文件描述符工作职能?结果

  3. 我可以使用pthread库在Cygwin中?

  4. 是否code,在Cygwin的也编译
    编译的Linux没有任何变化或变化不大?结果

  5. 可以通过建立一个可执行文件
    Cygwin的运行在Linux上?结果

  6. 为什么Cygwin的不需要连接器
    选项​​ -lpthread 当我使用pthread库?

  7. 为什么在的#include< iostream的> 不要我需要使用命名空间std 使用;

  8. 我可以在Cygwin的QT工作?如果是这样,怎么样?

  9. 我可以启动我的Linux在其他

  10. 分区Cygwin和使用它吗?

  11. 我可以访问其他分区
     这是EXT3 Cygwin中?


解决方案

在1:
是。套接字库随Cygwin的 - 许多基于套接字的应用程序,如都包含在基本分配 Web服务器

在2:
是。我认为所有的第2条和3'在GNU C运行时库和系统调用是由cygwin的runtume实施。您可以在附带的Cygwin手册页检查。系统调用列表,并通过标准Cygwin的implementd LIB调用可以在这里找到

在3:是。 Pthread的包括在Cygwin的。上述在链接所指的名单中提到的pthreads为好。

在4:内置对GNU库任何应与Cygwin和Linux之间很少或没有变化工作(假设没有依赖性失踪Cygwin的)。根据CPU架构可能担心字对齐,的字节顺序以及其他特定架构的移植问题,但如果你在针对英特尔的Windows和Linux的code会有很少有移植问题,从CPU架构所产生的。

在5: Cygwin的默认情况下将建立对自己的共享库的程序,但是GCC可以交叉编译瞄准其他平台。你可以(在理论上)设置了GCC交叉编译编译器所支持的任何目标。有丰富的资源在网络上了解使用GCC交叉编译,并我不认为这个过程将在Cygwin的重大差异。

需要注意的是Cygwin的二进制文件将无法在Linux上运行 - 或者反之亦然。您仍需要单独建立两个。

在6:不知道 - 在猜测它是包含在标准运行,也许是因为有必要来包装的Win32线程API由于某种原因,

在7: <击>不知道 - 它可能是在所有平台上的G ++相同显然,一个编译器错误。 <一href=\"http://stackoverflow.com/questions/2087435/cygwin-socket-thread-other-programming-issues-some-question-to-cygwin/2120744#2120744\">Dan成型的回答占地面积对此进行了更详细。

在8:是。 IIRC QT是提供标准的建立,它会在一定的Cygwin编译。与的Linux / Unix,在Cygwin QT采用了X11的后端,所以你需要有一个X服务器,如的Xming运行

为了避免你可能想建立针对Win32 API的应用程序QT, X服务器上的依赖。这是可能的的MinGW ,这是一组头文件和库建立本地的Win32应用程式上GCC做到这一点。 MinGW的可以从Cygwin环境(在Cygwin交叉编译到非Cygwin的目标的GCC的一个例子)和安装<内使用/ A> cygwin.com 提供安装的选项。

MinGW的是相当成熟;它拥有所有的'秋后算账'的 - 库和头文件,你会期望找到在Unix / Linux GCC开发环境,是非常稳定的。它
往往是首选建筑开源软件的Win32端口,因为它是工具(一)免费,(二)支持软件和(c)使用的库使用GCC所以它不会受到MSVC之间辩证关系的变化海湾合作委员会。

不过,在语言和可用的库这些辩证法变化(例如MSVC不来的实施 getopt的)意味着移植MinGW和MSVC之间可以计划相当繁琐。我的经验 - 诚然不是非常广阔的,我只是做了这几次 - 是MINGW32移植和Linux之间的应用比MinGW和MSVC之间的移植变得更简单。与非便携的依赖性如Win32 API特定的使用将需要依赖组件被用于新的平台重新编写的,但你会少很多问题,在标准库的语言方言差异,头文件和明显的应用程序。

QT确实提供了一个平台抽象层的一个相当不错的工作。它提供的API进行数据库访问,线程,I / O等多项服务,以及图形用户界面。使用Qt的API在可能的情况应该有助于便携性和附带的MinGW的Unix / Linux操作系统味库意味着它可能给你提出申请,将与相对较少依赖于平台的code Win32和Linux之间端口一个良好的平台。

编辑:在Cygwin中的Qt开发包是:


  • QT4:Qt应用程序框架(来源)

  • QT4-DEVEL工具:Qt4的助理,设计师,和语言学家

  • QT4-DOC:Qt4的API文档

  • QT4-qtconfig:Qt4的桌面配置应用程序

  • QT4-qtdemo:Qt4的演示和实例

您会恐怕还需要GCC4-G ++和其他一些零零碎碎。 在Cygwin的网站有包的列表此上市。

I have some question about cygwin :

  1. Can I use Cygwin develop socket based code?
  2. Does Cygwin have read() and write() functions that work with file descriptors?
  3. Can I use Pthread library in Cygwin?
  4. Does code that compiles in Cygwin also compile in Linux without any change or with little change?
  5. Will an executable file that built by Cygwin run in Linux ?
  6. Why does Cygwin not need the linker option -lpthread when I use pthread library?
  7. why in #include <iostream> don't I need to use using namespace std; ?
  8. Can I work with QT in Cygwin? If so,How?
  9. Can I boot my Linux in other
  10. partition with Cygwin and use it?
  11. Can I access the other partition that is EXT3 in Cygwin?

解决方案

On 1: Yes. Socket libraries are shipped with Cygwin - many socket based apps such as web servers are included in the base distribution.

On 2: Yes. I think all of the 'section 2 and 3' system calls in the GNU C runtime and library are implemented by the cygwin runtume. You can check this in the man pages that come with Cygwin. A list of system calls and std lib calls implementd by Cygwin can be found here.

On 3: Yes. Pthread is included in Cygwin. The list referred to in the link above mentions pthreads as well.

On 4: Anything built against GNU libraries should work with little or no change between Cygwin and Linux (assuming there are no dependencies missing on Cygwin). Depending on CPU architecture you may have to worry about word alignment, endianness and other architecture-specific porting issues, but if you're targeting Windows and Linux on Intel your code would have few if any porting issues arising from CPU architecture.

On 5: Cygwin will build a program against its own shared libraries by default but GCC can cross-compile to target other platforms. You could (in theory) set GCC up to cross-compile to any target supported by the compiler. There are plenty of resources on the web about cross-compiling with GCC, and I don't think the process will be materially different on Cygwin.

Note that Cygwin binaries will not run on Linux - or Vice-versa. You will still need separate builds for both.

On 6: Not sure - at a guess it's included in the standard runtime, perhaps because it was necessary to wrap the Win32 threading API for some reason.

On 7: Don't know - it's probably the same on g++ on all platforms. Apparently a compiler bug. Dan Moulding's Answer covers this in more detail.

On 8: Yes. IIRC QT is available in the standard builds and it will certainly compile on Cygwin. As with Linux/Unix, QT on Cygwin uses an X11 backend so you will need to have an X server such as XMing running.

In order to avoid the dependency on an X server you may want to build QT apps against the Win32 API,. It is possible to do this with MinGW, which is a set of header files and libraries to build native Win32 apps with GCC. MinGW can be used from within a Cygwin environment (an example of GCC on Cygwin cross-compiling to a non-Cygwin target) and the installer from cygwin.com gives you the option of installing it.

MinGW is quite mature; it has all of the 'usual suspects' - libraries and header files you would expect to find on a Unix/Linux GCC development environment and is very stable. It is often the tool of choice for building Win32 ports of open-source software because it is (a) free, (b) supports the libraries used by the software and (c) uses GCC so it is not affected by dialectic variations between MSVC and GCC.

However, these dialectic variations in the language and available libraries (for example MSVC doesn't come with an implementation of getopt) mean that porting programs between MinGW and MSVC can be quite fiddly. My experience - admittedly not terribly extensive as I've only done this a few times - is that porting applications between MinGW32 and Linux is easier than porting between MinGW and MSVC. Obviously apps with non-portable dependencies such as Win32 specific API usage would require the dependent components to be re-written for the new platform but you'll have far fewer problems with differences in the standard libs, header files and language dialect.

QT does a fairly good job of providing a platform abstraction layer. It provides APIs for database access, threading, I/O and many other services as well as the GUI. Using the QT APIs where possible should help with portability and the Unix/Linux flavoured libraries that come with MinGW mean that it might give you a good platform for making applications that will port between Win32 and Linux with relatively little platform dependent code.

EDIT: The qt development packages in Cygwin are:

  • qt4: Qt application framework (source)
  • qt4-devel-tools: Qt4 Assistant, Designer, and Linguist
  • qt4-doc: Qt4 API documentation
  • qt4-qtconfig: Qt4 desktop configuration app
  • qt4-qtdemo: Qt4 demos and examples

You'll probably also need gcc4-g++ and some other bits and pieces. This listing on the cygwin web site has a list of the packages.

这篇关于若干问题的Cygwin [的Linux在Windows(插座,线,其他的编程和外壳的问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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