#Dev environment

48 messages · Page 1 of 1 (latest)

warm drum
#

I am an experienced Go programmer, but I have never written much C++ (or C). To me it looks like there are a million ways to set up a dev environment for C++ but none of them look very appealing at the moment. This is a big change for me because Go is very opinionated and there's one right way to do things, which I kind of like. This is compounded because a lot of guides I see online are Windows-centric, but I don't use Windows, and I don't really like Visual Studio either.

So, I'm interested in learning the most "canonical" way of developing in C++, and after I am familiar I plan to branch out to find a way that I like.

What should I use if I want to start in C++ and learn the usual way of doings things (on a Mac/Linux mixed environment - no Windows)? How should I manage building the project, CMake? Whats a typical workflow for setting up a project and organising it?

south crownBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

brave edge
#

CMake is the way to go for building cross-platform, but I warn you, not the most beginner friendly.

warm drum
#

not really, more like the simplest thing possible. i just use VS Code at the moment

#

i dont want to learn an IDE on top of C++

#

i dont have the brain for that atm lol

brave edge
#

IDE's are meant to make your life easier, not harder

#

Anyway, if you were to switch between macOS and linux often, then I'd opt for CLion + Cmake

#

CLion being an IDE that has great cmake integration (will make your life easier as a lot of the heavy lifting of cmake is done for you)

warm drum
#

i heard it turns your PC into a space heater

brave edge
#

Let me guess, a VIM user said that? ¯_(ツ)_/¯

#

It's not worlds fastest IDE, but its used in professional environments, just like Visual Studio for instance

warm drum
#

i'm mainly just remoting in to the linux PC's. my big PC just runs silverblue

brave edge
#

CLion + Cmake prob your easiest route

warm drum
#

is there a standard way to create a project with cmake? With Go I just write go mod init myproject and then I can manage dependencies and add files etc

brave edge
#

Well, not like that, but it'd be more like:

cmake_minimum_required(VERSION 3.10)
project(MyProject VERSION 1.0)

add_executable(myexecutable main.cpp)

# If using external libraries, find and link them here
# find_package(SomeLibrary REQUIRED)
# target_link_libraries(myexecutable SomeLibrary::SomeLibrary)
#

in a CMakeLists, and off you go, you'd expand the cmakelist yourself

#

or use something like CLion as IDE and it's done for you (generating and updating)

warm drum
#

damn, so i have to manually add all these files to cmakelists.txt?

#

oh ok

brave edge
#

CLion does it for you, VS Code has plugins im pretty sure

#

but yes, without using external tools you'd be adding it manually

warm drum
#

ok, and how about compiler? CMake manages that too?

#

should i be using clang or gcc

brave edge
warm drum
#

idk which one to prefer though lol

brave edge
#

Clang has faster at compiling generally speaking

#

has better error/warning messages

#

in my experience

warm drum
#

thanks for your help btw, there's a lot of choices i have to make as a newbie. appreciate your time

brave edge
#

My pleasure

#

When creating a project with CLion, Visual Studio, or any respectable IDE with CMake support this will all be taken care of

#

and in the settings you'd be able to change compiler, language version, etc.

#

For the sake of simplicity I highly suggest just going with an IDE, and get started learning/writing, rather than getting stuck on setting up the environment for the next 3 days. CMake is a great tool, but does not come close to pleasant in its use.

warm drum
#

lol, i will try one. so far i have CMake with VSCode running. and i can use the command pallete to make CMake build

brave edge
#

If it works, then just continue with it

#

wouldnt worry about external depenencies

#

you wouldnt need it anytime soon if you've just started learning C++

warm drum
#

yeah, just want a simple loop for the moment, will see how i go

brave edge
#

As long as you're able to compile it and attach a debugger (requires some vs code plugin) then you're good to go I'd say

warm drum
#

!solved

south crownBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

neat hamlet
# warm drum

There also a tab on the left for CMake, where you can manage everything including debugging targets or reconfiguring

proper prawn
#

Well since this isn't closed yet, what is the purpose of CMake? It makes large projects easier to compile since in cpp you need to tell the compiler where the dependincies are? Or does it do more than that?