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?
Solution files (.sln) and C++ project files (.vcxproj) are a Visual Studio custom format (more specifically, they are part of Microsoft's MSBuild build system). It might be possible to find (or write) an extension for another IDE that can read these files and emulate MSBuild, but if you have the CMake configuration file (CMakeLists.txt) you should be able to open that or its containing directory as a project in CLion (as was pointed out in the comments).
If you don't have that file, and the project doesn't require particularly complex build steps, then you can probably just create a new CLion project "from existing source"; it should be able to generate the CMake files for you.
Linux does not use VS solution files. They are specific to Windows and Visual Studio. You will need to use cmake -G
to generate the appropriate platform-specific build files. ie. One of these, depending on which IDE you chose to use:
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
KDevelop3 = Generates KDevelop 3 project files.
KDevelop3 - Unix Makefiles = Generates KDevelop 3 project files.
Kate - Ninja = Generates Kate project files.
Kate - Unix Makefiles = Generates Kate project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.
Since you are using CLion, I would suggest cmake -G "Unix Makefiles"
which are supported by several popular Linux C++ IDEs as well as GNU/Linux tooling found universally on Linux.
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.
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.
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).
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 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 systems, including MacOSX (and probably Android).
To complete the other answers, it appears that Microsoft provides a Linux version of Visual Studio, see https://code.visualstudio.com/download
Not quite sure of its capabilities (is it the same as the Windows version ?), but it should definitely be of some help.
Other hint: I use Codeblocks (only as an enhanced editor, not for building. For that I use solely makefiles), and it appears it can import Visual Studio project/solution (for whatever these terms mean...)
Finally, any good IDE should be able to create a project from a bunch of source files, once you tick some checkboxes to set the correct options.
(Disclaimer: I did quit using Windows for more than 10 years)