Linux C++ IDE 中的解决方案文件相当于什么 [英] What is the equivalent of Solution files in Linux C++ IDE

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

问题描述

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

有一个 C++ 项目,该项目的设计方式是使用 CMakeLists.txt 文件构建.我在 Windows 中构建它时遇到了困难,但幸运的是,我可以在 Linux 中构建它.

Linux 中的构建输出是一堆 .so 文件(我在网上读到的文件相当于 Windows 中的 .dll 文件).

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

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

解决方案

首先,新鲜的心态接触 Linux.

您的问题暗含要求与 Microsoft 产品完全等效,这合理,也不是 Linux 和其他 Unix(及其下的软件开发)的工作方式.在 Linux(和其他 Unix 系统,包括 MacOSX)上,您将组合多种工具来完成您的工作,例如编译器(例如 GCCClang),一个链接器和相关实用程序(binutils)、源代码编辑器(你有很多选择,我推荐 emacs,但您可以使用 vimgeanygedit 等... 这真的是一个品味问题),像 gdb 这样的调试器(和你真的很想用它哦n 命令行,因为它非常强大),一个版本控制(我强烈推荐git,但也要考虑 mercurial),一个构建自动化工具(如makeninja),可能是文档生成器,例如doxygen;也许您会使用 C 或 C++ 代码生成器(例如 野牛, SWIG,ProtobufRefPerSys 等...或通过您自己的脚本(在 shell 中,AWKPython、一些通用的预处理器,如 GPPm4 等.);您还可以编写自己的 GCC 插件.cmake 实用程序(我不喜欢)只是一个 Makefile 生成器(实际构建由 make 完成),在许多情况下,手动编写 Makefile 更简单.

特别是,您将需要一些时间学习如何以 Linux 方式做事.阅读Advanced Linux Programming 然后系统调用(2).考虑到您可能需要几周的阅读和学习时间.不要期望可操作"立即地.花一些时间学习命令行工具和Unix shell.

如果您正在为 Linux 编程(特别是使用 C++ 或 C),您还需要了解 Linux 编程(这需要一些时间).阅读诸如 ALP 之类的书籍或更新的书籍.请注意系统调用(2).在某些情况下,您可能会对 C++ 框架感兴趣,例如 QtPOCO提升FLTK 等...(但我相信你仍然需要了解 Linux 编程的基础知识,即使你使用这些框架).>

阅读关于Unix哲学的维基页面.恕我直言,它解释了 Unix 视图结合工具来完成您的任务的优越性.

您可以使用 Clion,但您应该知道还有其他方法可以做到相同的.首先,您可能会使用其他 IDE,例如 DEV+C++Code::Blocks 等.那么我不建议盲目使用任何IDE,而是能够结合其他工具来代替(我喜欢使用emacs + make + gdb + git 在一起),这意味着了解您的 IDE 为您启动的程序.

在使用 GCC(或使用Clang)(因为默认情况下不启用警告和调试信息).因此,将 -Wall -Wextra -g 传递给您的 gccg++(或 clang++)编译命令.稍后(当程序被调试时)你可以传递一些优化标志(比如 -O2).阅读如何调用 GCC.

尝试构建一些现有的免费软件程序(从它们的源代码,例如在github).你会学到很多东西(你会明白它们通常是按照 Unix 方式设计的).

关于库,请阅读 Program Library HowToC++ dlopen mini HOWTOGCCBinutilsGNU makeGNU autoconf,来自 GNU bash.以及后来的 Drepper 的如何编写共享库.请注意,plugin 机制在 Linux 上非常不同(请参阅 dlopen(3)dlsym(3)) 和 Windows(莱文关于 链接器和加载器很好地解释了这一点.

我还推荐阅读操作系统:简单的三部曲 教科书(免费提供).

Linux 主要由自由软件组成,有时研究其中一些的源代码.

<块引用>

Linux中VS解决方案文件的等价物是什么?

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

附注.上面的大部分答案不仅适用于 Linux,还适用于其他 Unix 或 POSIX 系统,包括 MacOSX(可能还有 Android).

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

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.

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

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.

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?

解决方案

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, but consider also mercurial), 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, RefPerSys, etc... or thru your own script (in shell, AWK, Python, some generic preprocessor like GPP or m4, etc..); you could also code your own GCC plugin. 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.

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

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, FLTK, etc... (but I believe you still need to understand the basics of Linux programming, even if you use these frameworks).

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

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.

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.

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).

Regarding libraries, read the Program Library HowTo, the C++ dlopen mini HOWTO,the documentation of GCC, of Binutils, of GNU make, of GNU autoconf, of GNU bash. 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 is mostly made of free software, and it is sometimes very useful to study the source code of some of them.

What is the equivalent of VS solution file in 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. Most of the answer above fits for not only Linux but also other Unix or POSIX systems, including MacOSX (and probably Android).

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

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