I’ve been trying to learn a system language because it would enable me to access a whole new world of possibility for games, tools, and potential projects. My main problem when learning the language are:

  • can I write modern C++ code using the newer standards and still compile with libraries from older standards?
  • how do I even organize a C++ project? Look at the linked project, the CMakeList.txt is so hard to understand, the syntax looks so hard to write.
  • how do I install dependencies? You’re going to laugh at me, but I always used languages with package managers and I looked again at the linked project, and they write a whole CMakeList.txt to import ImGui (GUI library I wanna try) but if you compare the structure of the files, it’s different from the ones on the repository of ImGui.

As you see there are a lot of problems and it pains me to not be able to solve them because Rust is so unfun to use and work with! Do you think I should try C++, carry one with it?

Thanks, hector.

  • lysdexic@programming.devM
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    8 months ago

    can I write modern C++ code using the newer standards and still compile with libraries from older standards?

    Short answer: yes.

    Longer version: It depends on what compiler suite you’re using. In the end the main requirements are that a) include headers are valid C++ in any of the standards you’re targeting (i.e., don’t expect to build a C++11 project which includes language features introduced in C++20) b) it generates symbols that can be resolved and linked on all binaries.

    This should be done as a last resort, though. The problems you might experience won’t be trivial to troubleshoot or common.

    how do I even organize a C++ project?

    One of the main advantages of C++ is that it does not enforce any project tree layout. It doesn’t even require a specific file type or file extension. You are free to follow what works best for you.

    If you want a guideline, that can also be provided. See for example this link:

    https://github.com/vector-of-bool/pitchfork

    how do I install dependencies?

    C++ does not enforce any dependency resolution system. To keep things simple but debatable, you can give Conan a try.

    https://conan.io/