Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

cmake - What is the equivalent of Solution files in Linux C++ IDE

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...