I'd recommend using clangd together with the vscode-clangd extension instead of VSCode's "official" C/C++ extension.
Properly set up with a compile_commands.json and its pretty much better than any C/C++ IDE I've ever used.
I use CMake for all my projects, and passing "-D CMAKE_EXPORT_COMPILE_COMMANDS=ON" generates the compile_commands.json for clangd. I create a symlink to it in the main project folder so clangd can find it.
Clangd embeds clang-format and clang-tidy, so given appropriate configuration files formatting in VSCode just works with no extra extensions but vscode-clangd.
For debugging, I use CodeLLDB. Haven't had any problems with it so far, everything seems to work fine. Debug console works etc.
Debugging for one. You have to use a C++ debugger alongside Rust, and the lldb debugger is immensely superior (especially where structs are concerned in locals/watch).
I strongly recommend you have a look at vcpkg for getting tooling such as make and gcc installed.
Is it that hard for addons to implement proper settings GUI dialogs in vscode? Editing json files by hand is step backwards, especially when this comes from the company which also produces (real) Visual Studio.
What settings are you referring to? VSCode's settings (both main and extensions) have a GUI view. The compile_commands.json is always generated and not meant to be edited at all.
Settings of particular extensions, e.g. Golang's. When something is explained (e.g how to add build targets) it always goes to editing some json files.
How exactly it is lightweight when it carries a copy of Chrome browser in the background? Jut at idle with no files opened it uses 600 Mb of memory.
PS: it is a nice software which I also use extensively, but Electron is an abomination, Flash of 21 century.
They're also leaps and bounds better as IDEs than VSCode. I'd gladly exchange some "clunky"ness for a better experience and more features driven by a proper GUI.
You have to take into account the helper and renderer processes. A freshly launched instance takes around 250 MB on my system. It consumes more as you open files that trigger lazy loading of additional extensions. Still less than other IDEs, though.
In contrast, the so-called "heavier" classic Visual Studio 2019 v16.5 (devenv.exe) with no files open, Task Manager stats shows it using less than ~200 MB.
I think some folks get the impression VSCode is "lightweight" because the GUI/UI is lightweight. VSCode is less "busy" looking... less menu options, no ribbon with icons, less multi-panels of properties, etc. VSCode's GUI looks more like a bare-bones "text editor" than an IDE.
The deceptive answer is probably "Yes" to whatever such incarnation of that question you ask. But as always when it comes to VSCode, it's buggy, half-configured and most of the config is weirdly hidden inside json-schema driven JSON config files that may or may not work. So much so that for me it effectively becomes a "No" answer.
That's been my experience with watching stubborn fellow co-workers struggling with it while doing python development. On paper, it has all the features and whistles of course, so therefore it's the "best IDE".
Code completion, type-annotation, debugging, virtualenv, built-in linting, docker support, etc. But then when you use them, it's a virtual catastrophe of configs, random "does it work, no, try the config again, does it work now? Yes No?" And so it continues, for an hour. Meanwhile, a python IDE like PyCharm just works without hassle.
A few weeks ago I was reaching for VScode + Qt because I normally do a bunch of small one-offs. My go-to is mostly command line (vim and shell scripts for building or Makefiles or eventually cmake if things get "heavy")--which means I'm very excited about avoiding qmake in favor of cmake. I find most IDEs unbearably slow and heavy, but I really like Visual Studio's debugger (with multiple languages).
I hear great things about QtCreator, but for me it's more about not wanting to invest in yet another large application for things I don't do every day.
Thanks for this, I'm sure many would give it a try and will like the idea of having the possiblity and easier selection when working with their favorite IDE or editor when working with Qt.
Having said that, I will never leave QtCreator for VS Code, not that is not good, but QtCreator feels much solid and integrated than any other IDE when working with Qt/C++ or many C/C++ code bases out there, in matter of fact, QtCreator is my go to when doing c/c++.
I've tried CLion but I don't think will use that either.
You're not the first person to mention QtCreator for c/c++ projects ( not even using QT ). Can you elaborate about what you like about QtCreator over other c/c++ IDEs?
I use Visual Studio 2017 to develop a Qt application on Windows. I use Qt Creator (QtC) for same app on macOS. I love Qt, am delighted to have converted from Win32.
Sorry but VS still feels as solid as a tank, Qt Creator is less responsive to my needs.
- 'asserts' in QtC bring the debug session to a grinding halt. I can't step over like I can in VS.
- Where can I define macros in QtC?
- In debug mode, QtC is unable to display certain types of variables, way too often.
- I have fiddled for days with the .PRO file, read all the StackOveflow posts, and I still can't suppress reams of pedantic warnings.
- QtC just gives the impression of a rudimentary attempt at VS, like things are about to fall apart at any moment. To a programmer accustomed to VS, there always seems to be something missing, and I don't mean just different keyboard shortcuts. QtC has a long way to go.
Still, it's better than a text editor and the command line.
Fun, I have exactly the opposite experience re. VS and Qt Creator - VS sometimes takes, like 15 minutes to start a debug session on a large project while QtC can get to work in the same time that it would take gdb to start. And that's without counting the clang-based code model, all the niceties under the locator (ctrl-k), etc etc
> Where can I define macros in QtC?
the IDE is imho not the place to do that. Just use CMake and target_compile_definitions(my_target PRIVATE MY_MACRO=123)
> - In debug mode, QtC is unable to display certain types of variables, way too often.
very strange, but then I mostly use it on Linux with gdb / lldb, maybe the cdb integration is less good.
> - I have fiddled for days with the .PRO file, read all the StackOveflow posts, and I still can't suppress reams of pedantic warnings
If CONFIG += warn_off in your .pro (switch to cmake !!!) does not work please file bugs !
Qt Creator has vertical tabs ("Opened documents" panel) which is way superior as soon as you have more than 3 files open. It's also pretty useless since you can just <ctrl-k> <first few letters> <enter> or <ctrl-tab> to switch
It has a better extension ecosystem by a wide, wide margin. Some of the benefits that can bring from my personal experience:
- Using the same editor setup for tons of different environments (Python, C/C++, Rust, JavaScript, TypeScript, Java, Go, and more are all very well supported)
- There are live collaboration extensions that let you pair program with other devs over the internet, with really good responsiveness
- The remote extension also lets you specify a dockerfile/image ref + plugin configuration in your repository, which can then be used for your editing. This effectively gives you transparent, Git-based, immutable development environments. This can be a big productivity boost.
I've also found it pretty easy for most people to pick up and use, and it's also fairly lightweight and reasonable IME.
I love Qt Creator, but the lack of tabs drives me nuts. The interface is so unfamiliar that I just can't use it. I use it to debug, to build interfaces, to compile, etc... but to code, I just use Sublime/VS Code/Atom/whatever.
That's funny because I prefer "Open Documents" dock in QtCreator to the tabs. It's hard for me to switch between files because I can just see 7-8 tabs without scrolling and in the dock I might have 20 files with longer names.
Is anyone here using gitlab with a runner to build QT applications upon commit? I've got a friend who needs this and he is only using QTCreator but it seems like building inside a docker container should be possible. I guess I'm asking: can all the things discussed here be done from command line instead of inside the editor and if so, how do you determine those commands?
If you set it up using cmake, it's like any other app: cmake, make, done. (cmake has support for handling the Qt specific bits for you)
If you're using Qt's qmake, which is likely if they just started with QtCreator, you call qmake and then make to build.
In both cases I'd refer you to Qt's documentation for details, but QtCreators project configuration UI and build log also shows you which commands it is running.
I have a project that has this same workflow, in my gitlab-ci file I just run qmake followed by make. I have a custom container which contains the QT library and build tools.
I've led adoption on that exact setup at work. You can definitely do it, but I have nothing but bad things to say about Qmake. It's poorly documented, inscrutable, and a huge PITA. Switch to any other build system if you can.
That said, automating the builds in GitLab CI was worth it 1000x over.
If you’re fighting qmake there is a very good chance you’re fighting the wrong problem. Is your build a complicated mess? (It shouldn’t be) Do you have a complicated multi platform mess (it shouldn’t be complicated)
I have qt kits to build for 4 different platforms and 3 different build toolchains. It was very easy to set up, and flipping between kits either in creator or in a terminal takes mere seconds.
That allows you to support _some_ dependency ordering from the top level, but not internally. It is very coarse, and also suffers from “recursive Makefile” issues. It’s also less ergonomic: a developer can’t go into a specific sub folder and build ONLY that sub folder and its dependencies. If you change a library, it also can't reliably tell you which other binaries are its dependents. You have to let Make walk the full project tree.
By “additional compilers,” I mean adding additional metacompilers, other languages, and so on. There is QMAKE_EXTRA_COMPILERS, but I can’t figure out how to get it to properly integrate with the dependency graph for the life of me.
Have you ever had to resort to “make distclean” to get a clean compile?
On your first point I respectfully disagree. The functionality does exactly what you claim it doesn’t do. You are mistaken on every point in your first paragraph.
bin/bin.pro # specify bin/bar/ as subfolder
bin/bar/bar.c
bin/bar/bah.h
bin/bar/bar.pro
lib/lib.pro # specify lib/foo/ as subfolder
lib/foo/foo.c
lib/foo/foo.h
lib/foo/foo.pro
project.pro # specify bin/ and lib/ as subfolders
And I have a fresh checkout, how do I compile "bin/bar" and all of its dependencies automatically? I want to run ONLY "bin/bar". I don't want to compile the entire repo. I don't want to have to investigate "bin/bar" and learn all of its transitive dependencies. I just want to run "bin/bar".
Honest to god, I have wanted this for over a year and it does not seem possible.
66 comments
[ 3.1 ms ] story [ 116 ms ] threadIf you don't mind sharing I am very interested in your setup.
I use CMake for all my projects, and passing "-D CMAKE_EXPORT_COMPILE_COMMANDS=ON" generates the compile_commands.json for clangd. I create a symlink to it in the main project folder so clangd can find it.
Clangd embeds clang-format and clang-tidy, so given appropriate configuration files formatting in VSCode just works with no extra extensions but vscode-clangd.
For debugging, I use CodeLLDB. Haven't had any problems with it so far, everything seems to work fine. Debug console works etc.
https://github.com/microsoft/vscode-cpptools/issues/3829#iss...
I also had the library issue mentioned here and copied the file the same way to fix that: https://github.com/microsoft/vscode-cpptools/issues/3829#iss...
I strongly recommend you have a look at vcpkg for getting tooling such as make and gcc installed.
Even so, I prefer editing the JSON files directly. I can easily see what's changed from the default, add comments, and make groups of settings.
Edit: My bad, apparently I didn't count all processes.
Launching it with no files open, the total private+shared memory adds up to ~300 MB. Screenshot of macOS Activity Monitor:
https://imgur.com/a/xDdzDRr
This memory usage is roughly the same on Windows 10 Task Manager:
https://imgur.com/a/xWkdoN1
In contrast, the so-called "heavier" classic Visual Studio 2019 v16.5 (devenv.exe) with no files open, Task Manager stats shows it using less than ~200 MB.
I think some folks get the impression VSCode is "lightweight" because the GUI/UI is lightweight. VSCode is less "busy" looking... less menu options, no ribbon with icons, less multi-panels of properties, etc. VSCode's GUI looks more like a bare-bones "text editor" than an IDE.
How they do it while using Electron? No idea.
That's been my experience with watching stubborn fellow co-workers struggling with it while doing python development. On paper, it has all the features and whistles of course, so therefore it's the "best IDE".
Code completion, type-annotation, debugging, virtualenv, built-in linting, docker support, etc. But then when you use them, it's a virtual catastrophe of configs, random "does it work, no, try the config again, does it work now? Yes No?" And so it continues, for an hour. Meanwhile, a python IDE like PyCharm just works without hassle.
You got me interested ^^
I hear great things about QtCreator, but for me it's more about not wanting to invest in yet another large application for things I don't do every day.
Having said that, I will never leave QtCreator for VS Code, not that is not good, but QtCreator feels much solid and integrated than any other IDE when working with Qt/C++ or many C/C++ code bases out there, in matter of fact, QtCreator is my go to when doing c/c++.
I've tried CLion but I don't think will use that either.
Need to mention is so damn light ?
Sorry but VS still feels as solid as a tank, Qt Creator is less responsive to my needs.
- 'asserts' in QtC bring the debug session to a grinding halt. I can't step over like I can in VS.
- Where can I define macros in QtC?
- In debug mode, QtC is unable to display certain types of variables, way too often.
- I have fiddled for days with the .PRO file, read all the StackOveflow posts, and I still can't suppress reams of pedantic warnings.
- QtC just gives the impression of a rudimentary attempt at VS, like things are about to fall apart at any moment. To a programmer accustomed to VS, there always seems to be something missing, and I don't mean just different keyboard shortcuts. QtC has a long way to go.
Still, it's better than a text editor and the command line.
> Where can I define macros in QtC?
the IDE is imho not the place to do that. Just use CMake and target_compile_definitions(my_target PRIVATE MY_MACRO=123)
> - In debug mode, QtC is unable to display certain types of variables, way too often.
very strange, but then I mostly use it on Linux with gdb / lldb, maybe the cdb integration is less good.
> - I have fiddled for days with the .PRO file, read all the StackOveflow posts, and I still can't suppress reams of pedantic warnings
If CONFIG += warn_off in your .pro (switch to cmake !!!) does not work please file bugs !
- Using the same editor setup for tons of different environments (Python, C/C++, Rust, JavaScript, TypeScript, Java, Go, and more are all very well supported)
- The VS Code remote editing extensions are fantastic: https://code.visualstudio.com/docs/remote/remote-overview
- There are live collaboration extensions that let you pair program with other devs over the internet, with really good responsiveness
- The remote extension also lets you specify a dockerfile/image ref + plugin configuration in your repository, which can then be used for your editing. This effectively gives you transparent, Git-based, immutable development environments. This can be a big productivity boost.
I've also found it pretty easy for most people to pick up and use, and it's also fairly lightweight and reasonable IME.
If you set it up using cmake, it's like any other app: cmake, make, done. (cmake has support for handling the Qt specific bits for you)
If you're using Qt's qmake, which is likely if they just started with QtCreator, you call qmake and then make to build.
In both cases I'd refer you to Qt's documentation for details, but QtCreators project configuration UI and build log also shows you which commands it is running.
That said, automating the builds in GitLab CI was worth it 1000x over.
I would be happy to take a look at your build.
- qmake doesn't support true dependencies between subprojects (ie, if I ask it to build a/b/c, it can't know that a/b/c depends on d/e/f)
- qmake's support for integrating additional compilers is inscrutable and again, has terrible issues with parallelism and dependencies
- the way it is backed by make is prone to incremental build issues
I have qt kits to build for 4 different platforms and 3 different build toolchains. It was very easy to set up, and flipping between kits either in creator or in a terminal takes mere seconds.
I have never experienced your 3rd point.
By “additional compilers,” I mean adding additional metacompilers, other languages, and so on. There is QMAKE_EXTRA_COMPILERS, but I can’t figure out how to get it to properly integrate with the dependency graph for the life of me.
Have you ever had to resort to “make distclean” to get a clean compile?
For your second point: https://ortogonal.github.io/qmake-extra-compiler/ I have never used this but it looks straightforward enough.
I have never had to use make distclean. I use make clean && qmake && make sometimes.
I'm not a fan of qmake but this works just fine with it.
Given I have this layout:
And I have a fresh checkout, how do I compile "bin/bar" and all of its dependencies automatically? I want to run ONLY "bin/bar". I don't want to compile the entire repo. I don't want to have to investigate "bin/bar" and learn all of its transitive dependencies. I just want to run "bin/bar".Honest to god, I have wanted this for over a year and it does not seem possible.