在Linux C ++ IDE中等效于解决方案文件 [英] What is the equivalent of Solution files in Linux C++ IDE

查看:75
本文介绍了在Linux C ++ IDE中等效于解决方案文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我一直在Windows中使用Visual Studio进行开发,因此我对Linux中的C ++开发非常陌生.

I am very new to C++ development in Linux as I have always used Visual Studio in Windows for development.

有一个C ++项目,该项目的设计方式是使用CMakeLists.txt文件构建.我在Windows上构建同样的代码很困难,但是幸运的是,我可以在Linux上构建它.

There is a C++ project, the project has been designed in a way that it's builds using CMakeLists.txt files. I had a tough time building the same in Windows but fortunately, I could build this in Linux.

Linux中的构建输出是一堆.so文件(我在网上阅读的内容等同于Windows中的.dll文件).

The build output in Linux is a bunch of .so files (that I read on the web is equivalent to .dll files in Windows).

我打算在Linux C ++ IDE中打开解决方案文件(我目前同样使用CLion),方法与在Windows中的Visual Studio中使用解决方案(.sln文件)一样.我不确定如何在Linux C ++ IDE中打开项目文件,以及如何在Linux中使用Cmake生成相同的文件.在这方面的任何帮助都将非常有帮助.

I intend to open the solution files in Linux C++ IDE (I am currently using CLion for the same), the same way it is done in Visual Studio in Windows using the solution (.sln file). I am not sure how the project file can be opened in Linux C++ IDE and how I can generate the same using Cmake in Linux. Any help in this regard would be very helpful.

什么是Linux中的VS解决方案文件的等效项,我想在基于Linux的C ++ IDE中打开项目文件(例如CLion),如何在Linux中使用Cmake生成相同的文件?

What is the equivalent of VS solution file in Linux, I want to open my project files in a Linux-based C++ IDE for example CLion, and how can I generate the same in Linux using Cmake?

推荐答案

首先,新鲜的思维方式采用Linux.您的问题暗含地要求获得与Microsoft产品完全相同的产品,这是合理的,也不是Linux和其他Unix(及其下的软件开发)如何工作的原因.在Linux(和其他Unix系统,包括MacOSX)上,您可以结合多种工具来完成工作,例如编译器(例如 Clang ),链接器和相关实用程序( binutils ),源代码编辑器(您有很多选择,我建议 emacs ,但您可以使用 vim gedit 等. ..这确实是个问题,例如 gdb 你真的想用它吗n,因为它非常强大),请使用版本控制(我强烈建议 git ),构建自动化工具(例如 make 忍者),也许是文档生成器,例如 doxygen ;也许您将使用C或C ++代码生成器(例如)进行临时元编程 href ="https://www.gnu.org/software/bison/" rel ="nofollow noreferrer">野牛, Protobuf 等...或通过您自己的脚本(在外壳中, Python ,例如 GPP Makefile 生成器(并且实际构建由make完成),并且在许多情况下,手动编写Makefile更为简单.

First, approach Linux with a fresh mindset. Your question is implicitly asking for an exact equivalent of Microsoft products, and that is not reasonable and is not how Linux and other Unixes (and software development under it) work. On Linux (and other Unix systems, including MacOSX), you'll combine several tools for your job, e.g. a compiler (such as GCC or Clang), a linker and related utilities (binutils), a source code editor (you have lots of choice, I recommend emacs, but you could use vim, geany, gedit, etc... it is really a matter of taste), a debugger like gdb (and you really want to use it on the command line, since it is very powerful), a version control (I strongly recommend git), a build automation tool (like make or ninja), perhaps a documentation generator such as doxygen; maybe you'll do some ad-hoc metaprogramming with C or C++ code generators such as bison, SWIG, Protobuf, etc... or thru your own script (in shell, AWK, Python, some generic preprocessor like GPP or m4, etc..). The cmake utility (which I don't like) is simply a Makefile generator (and the actual build is done by make), and in many cases writing that Makefile by hand is simpler.

尤其是,您将需要一些时间来学习如何以Linux方式做事.考虑到您可能需要几天或几周的阅读和学习时间.不要指望立即运作".花一些时间来学习命令行工具和

In particular, you will need some time to learn how to do things the Linux way. Consider that you could need a few days or weeks of reading and learning. Don't expect to be "operational" immediately. Invest some time in learning command line tools and the Unix shell.

如果您正在为Linux编程(特别是在C ++或C中),则还需要了解Linux编程(这需要一些时间).阅读诸如 ALP 之类的书或更新的书.请注意 syscalls(2).在某些情况下,您可能对C ++框架感兴趣,例如 Qt Boost 等...(但我相信即使您使用这些框架,您仍然需要了解Linux编程的基础.

If you are programming for Linux (notably in C++ or C), you'll also need to understand Linux programming (and that takes some time). Read some book like ALP or something newer. Be aware of the syscalls(2). In some cases, you could be interested by C++ frameworks such as Qt, POCO, Boost, etc... (but I believe you still need to understand the basics of Linux programming, even if you use these frameworks).

Unix哲学上阅读维基页面.它解释了恕我直言,组合工具的Unix视图对您的任务的优越性.

Read the wikipage on Unix philosophy. It explains IMHO the superiority of the Unix view of combining tools for your task.

您可以使用 Clion ,但是您应该知道还有其他方法可以相同的.首先,您可以使用其他IDE,例如 DEV + C ++

You could use Clion, but you should be aware that there are other ways of doing the same. First, you might use other IDEs, such as DEV+C++, Code::Blocks, etc. Then I don't recommend using any IDE blindly, but being capable of combining other tools instead (I like using emacs + make + gdb + git together), which means understand the programs that your IDE is starting for you.

使用 GCC (或使用)编译C或C ++代码时,请确保启用所有警告和调试信息. Clang )(因为默认情况下未启用警告和调试信息).因此,将-Wall -Wextra -g传递给gccg++(或clang++)编译命令.稍后(调试程序时),您可以传递一些优化标志(例如-O2).了解如何调用GCC .

Be sure to enable all warnings and debug info when compiling C or C++ code with GCC (or with Clang) (since warnings and debug info are not enabled by default). So pass -Wall -Wextra -g to your gcc or g++ (or clang++) compilation command. Later (when the program is debugged) you could pass some optimization flags (like -O2). Read how to invoke GCC.

尝试构建一些现有的免费软件程序(从其源代码,例如在 github ).您将学到很多东西(并且您将了解它们通常是按Unix方式设计的.)

Try to build some existing free software programs (from their source code, e.g. on github). You'll learn a big lot (and you'll understand that they are usually designed in the Unix way).

关于库,请阅读程序库的使用方法,以及后来的Drepper的 如何编写共享库 .请注意,插件机制在Linux上非常不同(请参见

Regarding libraries, read the Program Library HowTo and later Drepper's How to write shared libraries. Be aware that the plugin machinery is very different on Linux (see dlopen(3) and dlsym(3)) and on Windows (Levine's book on Linkers and Loaders explains that well).

我还建议您阅读> 操作系统:三篇简单文章 教科书(免费提供).

I also recommend reading the Operating Systems: Three Easy Pieces textbook (freely available).

Linux主要由免费软件组成,有时对研究Linux很有用.其中一些的源代码.

Linux is mostly made of free software, and it is sometimes very useful to study the source code of some of them.

Linux中的VS解决方案文件等效于什么?

What is the equivalent of VS solution file in Linux?

没有,我的回答解释了原因(以及为什么您甚至都不愿梦想找到一个).您将发明另一种在Linux上构建软件的方式.

There is none, and my answer explains why (and why you should not even dream of finding one). You'll invent another way of building your software on Linux.

PS.上面的大多数答案不仅适用于Linux,还适用于其他Unix系统,包括MacOSX(可能是Android).

PS. Most of the answer above fits for not only Linux but also other Unix systems, including MacOSX (and probably Android).

这篇关于在Linux C ++ IDE中等效于解决方案文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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