跨平台编程 [英] Cross platform programming

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

问题描述

我需要写为大学的小程序。问题是,它必须是在C / C ++ linux下,我从来没有用过linux,我预计会有很多的IDE,编译问题,而这一切。

I need to write a small program for the university. The problem is, it has to be in C/C++ under linux, and I've never used linux, I anticipate having a lot of problems with the IDE, compilation, and all that.

是否可以在Windows下code,然后复制/粘贴的code和linux下编译它?什么是限制,我应该知道,如果它是在所有可能的?

Is it possible to code it under windows and then "copy/paste" the code and compile it under linux? What are limitations I should know about if it's at all possible?

这将是一个小程序,典型的客户机/服务器通信使用套接字。

It will be a small program, typical client/server communication using sockets.

推荐答案

我觉得你应该继续前进,在linux下做(GCC?)。这将教你'老同学'编程的一些东西。忘了使用IDE,使用vim(如果你得到媒体链接),或者用nedit(更像记事本)。

I think you should go ahead and do it under linux (gcc?). This will teach you some stuff about 'old school' programming. Forget about using an IDE, use vim (if you allready get it) or nedit (more like notepad).

在命令行编译。自己联系起来。写make文件来做到这一点。

Compile on the command line. Link it yourself. Write a make file to do this.

这是基础。你需要使用一个IDE之前去了解它。的这样做,而你还在上大学,因为这是一个痛苦,你会(也应该)要使用的IDE真正的工作!

This is the basics. You need to understand it before using an IDE. Do this while you are still at university, because it's a pain and you will (and should) want to use an IDE for real work!

另外,UNIX的一个基本的了解并不难实现(我发现我周围的Solaris中,Ubuntu和OS X的方式,从窗户背景的) - 一些简单的教程,应该让你和运行。编写小项目学校,没​​有太多你需要知道: CD LS MKDIR 制作 GCC (一定要使用 G ++ 的C ++项目 - 已经咬我在我的Mac之前...)。贴近你的home目录()。

Also, a basic understanding of unix is not hard to achieve (I have found my way around solaris, ubuntu and os x, coming from a windows background) - a few simple tutorials should get you up and running. For writing small school projects, there is not much you need to know: cd, ls, mkdir, make, gcc (be sure to use g++ for C++ projects - that has bitten me on my mac before...). Stay close to your home directory (~).

在目标系统上做你的项目将有助于你得到某些东西的权利:在做这些简单的插座和pthreads的例子,我发现的编译和链接它们是非plattform便携。在某些系统中,库链接需要做这样一来,别人的方式。

Doing your project on the target system will help you get certain stuff right: When doing these simple sockets and pthreads examples, I found compiling and linking them to be non-plattform portable. On certain systems, linking in the libraries needs to be done this way, on others that way.

BTW :如果你真的的想做这个窗口下,你最好的选择是有窗户下POSIX环境。如果我没有记错POSIX插座是Windows网络模型的不同。

BTW: If you really do want to do this under windows, your best bet is to have a POSIX environment under windows. POSIX sockets are different to the windows networking model if I remember correctly.

尝试要么MinGW的或Cygwin的。双方应该给你的Windows下的* nix的开发环境。您可以使用自己喜欢的文本编辑器(VIM的窗口?)和而非cmd.exe的bash的启动编译:)

Try either mingw or cygwin. Both should give you the *nix development environment under Windows. You can use your favorite text editor (a windows port of vim?) and cmd.exe instead of bash for starting the compiler :)

修改:对不起,如果音调对抗性(按评论)。我会尽量软化它一下。只是......我看到不少人努力学习C / C ++(或Java为此事)与IDE和已经开始相信,他们在出发的方式获得。当然,你将需要现实生活的方案更好的工具,但项目文件等的学校样本项目的开销增加了混乱。这也使得它更难你的作业通过电子邮件发送给你的老师 - 与一群.c和.h文件和Makefile文件的zip真的是那样简单,因为它得到...

EDIT: Sorry, if the tone is confrontational (according to comment). I will try to soften it a bit. It's just... I have seen quite a few people trying to learn C/C++ (or Java for that matter) with IDEs and have come to believe that they get in the way for starting off. Sure, you will need better tools for real life programs, but the overhead of project files etc. for school sample projects adds clutter. It also makes it harder to email your homework to your teacher - a zip with a bunch of .c and .h files and a makefile is really as simple as it gets...

这篇关于跨平台编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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