0

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?

Cinder Biscuits
  • 4,880
  • 31
  • 51
Peter
  • 53
  • 1
  • 3
  • 2
    With CLion you should be able to open the top level CMakeLists.txt as the project file – nos Jan 04 '19 at 14:40
  • IMHO, this is off topic and might get closed: you are asking for some software recommendation, are you? – kebs Jan 04 '19 at 14:41
  • 1
    @kebs, I am not asking for any software recommendations, but the procedure to open the C++ project files in Linux IDE as I am new to Linux IDEs and how those files are generated in Linux. – Peter Jan 04 '19 at 14:46
  • yes that's true, but 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. Thanks for your help! – Peter Jan 04 '19 at 15:01
  • 2
    @Peter Linux has several different build systems and IDEs all with their own way of doing things. Makefiles are generally your best bet on Linux as their tooling is part of GNU. See my answer for more. – Cinder Biscuits Jan 04 '19 at 15:03
  • 2
    @Peter As mentioned Clion lets you open the CMakeLists.txt file directly. See the bottom of https://www.jetbrains.com/clion/features/start-your-project.html . You don't need to run cmake first to generate a project file. Now - other Linux IDEs might not support that though. – nos Jan 04 '19 at 15:37
  • What kind of software are you developing? – Basile Starynkevitch Jan 04 '19 at 15:50
  • Asking for tools recommendations is *explicitly* **off-topic** on StackOverflow – Basile Starynkevitch Jan 04 '19 at 16:09
  • Hello. I started developing a tool to view VS solutions. If there is interest, I will develop it further. https://github.com/bravikov/visual-studio-solution-explorer – Dmitry Bravikov Jan 04 '22 at 23:41

6 Answers6

2

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.

Cinder Biscuits
  • 4,880
  • 31
  • 51
2

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.

Nick Mertin
  • 1,149
  • 12
  • 27
2

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

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0
  • There is no such thing as the "Linux C++ IDE" cause there are many
  • CMakeLists.txt IS the cross-platform equivalent of "Solution files"
Slava
  • 1,528
  • 1
  • 15
  • 23
0

Cmake and CMakelits.txt is good start for manage cpp project.
You can use Clion for more easy configuration tool set.
https://www.jetbrains.com/clion/

I think the first answers here is linux geek that want all the people use linux will be like them. No, people love to use linux and get one program that can give you set of tools. Not to build your own set of tools from scratch. Yes you can do it on linux, yes, you actually can enjoy it if you are linux geek, but most of the people just want things gets done. Please let them to enter to linux and make this community more bigger and happier.

Tal
  • 1,145
  • 2
  • 14
  • 32
-1

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)

kebs
  • 6,387
  • 4
  • 41
  • 70
  • 4
    Visual Studio Code is an entirely separate IDE that's available on Windows, Mac and Linux; from what I've seen it doesn't natively support the MSBuild system. It does support many languages, but requires external tools for compilation, and in my experience works better as a code editor than a full IDE. If OP has access to CLion it's definitely a better option for C++ than VS Code. – Nick Mertin Jan 04 '19 at 19:43
  • 1
    and a third called Visual Studio for Mac which is purely a C# IDE. – Cinder Biscuits Jan 05 '19 at 00:24