如何从Windows C切换到Linux C? [英] How to switch from windows C to linux C?

查看:196
本文介绍了如何从Windows C切换到Linux C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几十年来,我一直是DOS/Windows上的多语言程序员.我最终决定切换到Linux,但是在查找信息方面没有很多成功.从我已经用C语言编写的Windows cli程序开始并将它们转换为Linux相当容易,但是我没有.

对于gcc以及最终的gnome,所有不同的头文件,第三方库等都有很好的帮助来源吗?

任何帮助将不胜感激.

我尝试过的事情:

linuxcommand.org,
https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html,
linuxdevcenter,
等.

I''ve been a multi-language programmer on DOS/Windows for decades. I''ve finally decided to switch to Linux and I''m not having a lot of success finding information. I though it would be fairly easy to start with the Windows cli programs I''ve already written in C and convert them to Linux but it''s not.

Is there a good source of help for all the different header files, 3rd-party libs, etc. for gcc and, eventually, gnome?

Any help at all would be appreciated.

What I have tried:

linuxcommand.org,
https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html,
linuxdevcenter,
etc.

推荐答案

周围有很多Linux站点,您甚至可以在线找到手册页:
There are plenty of Linux sites around, and you can even find the man pages online: Section 3: library functions - Linux man pages[^].


我不认为只有一个消息源(甚至是几个消息源)涵盖了您的所有问题.专注于一个问题并在网上搜索,或者在这里再次提问该问题是否足够具体(这里不欢迎通过网络研究可以回答的问题).

但我会给您一些可能有用的基础知识.

C和C ++标准库几乎没有区别.

对于字符串,只需使用char*. Linux使用UTF-8字符串,这些字符串由char处理,而Windows使用宽字符串(wchar_t)和MS特定的TCHAR s.

尝试将现有Windows应用程序的GUI部分转换为Linux时,会出现大多数问题.由于存在多个GUI框架,因此您必须先决定使用哪个框架(
小部件工具包列表-维基百科,免费的百科全书 [ ^ ]).请注意,大多数都使用C ++(有关C框架,请参见上面的Wikipedia链接).

通常最好是从头开始重写GUI部分,而不是尝试转换现有代码.

对于其他任何内容(例如其他库),您必须搜索具有相应功能的库.对于与网络相关的操作,请使用普通套接字( Linux Howtos:主页 [ POSIX线程-维基百科,免费的百科全书 [
I don''t think that there is only one source (or even a few) that covers all your questions. Concentrate on one question and search the web or ask here again if the question is specific enough (questions that can be answered by web research are not really welcome here).

But I will give you some basics that might help.

There is (nearly) no difference regarding the C and C++ standard libraries.

With strings just use char*. Linux uses UTF-8 strings which are handled by chars while Windows uses wide strings (wchar_t) and the MS specific TCHARs.

Most problems arise when trying to convert the GUI part of an existing Windows application to Linux. Because there are multiple GUI frameworks, you have to decide first which to use (List of widget toolkits - Wikipedia, the free encyclopedia[^]). Note that most are using C++ (see above Wikipedia link for C frameworks).

It is usually better to rewrite the GUI parts from scratch rather then trying to convert existing code.

For anything else (like additional libraries) you have to search for libraries with corresponding functionality. For network related operations use plain sockets (Linux Howtos: Home[^]) or the functions provided by the used GUI framework instead of WinSock. Similar for threads where you can use pthreads (POSIX Threads - Wikipedia, the free encyclopedia[^]) or functions of the framework.

You should become familar with the development tools (mainly gcc, gdb, and the common make utilities). There are a lot of resources in the web covering basic tutorials and the tool''s documentation.


这篇关于如何从Windows C切换到Linux C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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