Thread: Crossplatform development with modern C, advice required.

  1. #1
    Registered User
    Join Date
    Apr 2015
    Posts
    5

    Crossplatform development with modern C, advice required.

    Hello,

    I am plan to start new big project (the game-development sdk & first game based on it). After more than 10 year of C++, I want to go the pure-C-way for number of reasons. And there are some problems which are currently show-stopper for me. I want to ask you, dear colleagues, for some advices in hope to resolve the issues.

    The problems arise because of mix of requirements for project:
    1. C11 features
    2. Cross-platform but with Windows as main development platform
    3. Visual Studio (VS) like experience are almost must-have for development process
    4. x64


    Because VS doesn't support the C11, it is impossible to use VS directly. There are of course many other C/C++ IDEs, and I have already try most popular of them (Eclipse, Netbeans, Code Blocks, Code Lite, Pelles C IDE). After VS they are just ugly. I am definitely not a MS fan, but code completion, build system & projects management, debugging - almost all aspects are just bad in compare to VS.

    In other words, currently I just unable to setup any reasonable development environment to start project with. At least the following are required:
    1. Reasonable code completion features (for raw-productivity)
    2. Flexible & non-over-bloated build system & projects management:
      • Workspace or solution concept (the set of modules projects to open as single entity)
      • Projects dependencies with automatic linking (so linker options for DLL/static libs dependencies are setup automatically)
      • non-make based (while not absolutely required, but I would prefer to avoid it as much as possible)

    3. Powerful & flawless debugging features (the gdb on Windows for me at this point seems to fail completelly - it sloooooow, hard to setup, strange issues here and here, etc.)


    I would appreciate any yours comments, thoughts, advices about the any aspects and problems mentioned above. I feel that my description of problem a bit messy, so please ask any questions if you interesting in.

    Thanks in advance!

  2. #2
    Registered User
    Join Date
    Mar 2015
    Location
    BE
    Posts
    66
    VS doesn't support C11. You mean the compiler VS uses doesn't support C11. But can't you configure the compiler yourself?
    I am a beginner in computers but I am just asking to understand and to be able to follow your thread.

    Good luck with your project!

  3. #3
    Registered User
    Join Date
    Apr 2015
    Posts
    5
    Quote Originally Posted by Carnotter View Post
    VS doesn't support C11. You mean the compiler VS uses doesn't support C11. But can't you configure the compiler yourself?
    I am a beginner in computers but I am just asking to understand and to be able to follow your thread.

    Good luck with your project!
    You are right, I mean that VS's compiler doesn't support the C11 features. The idea to use external compiler with VS IDE is really attractive and actually it was my one of very first approach to the problem. Unfortunately, I was unable to make this way working. While it is somehow possible to utilize external compiler for compiling job, there are many inconveniences arise. E.g. compilation related properties of projects are designed for VS compiler and become useless for external one (so you have to setup all compiler switches in a form of "additional parameters" string). The debugging is also become the problem. This way VS turns mostly in a good code editor, not more. Almost any other IDE currently provide the comparable [for me personally] level of feature for effective code-writing workflow (i mean mostly code-completion features), so in VS + external compiler solution, VS lost almost all significant features.

    Currently I am playing with Pelles C. At this moment it looks a bit promising. The projects & workspace management are very simplistic and not suit my needs, but I want to check the other aspects in more details.

    I was also very interesting in clang for many reasons, but after a bit of playing with it I was disappointed. They promise better tools via llvm features, they promise better compiler via llvm, they promise, promise, promise ... the tools are buggy [IMHO, maybe I just was unable to setup it properly] and not so very convenient, the compiler itself is GCC-clone with respect to features but GCC generate better code (at least with respect to performance, that is most interesting for my project), clang documentation is incomplete (e.g. I was unable to find explicit statements about C11/C99 support level). So I find no reasons to stay with clang. GCC on Windows is also pain, but still better than clang [IMHO].

  4. #4
    Registered User
    Join Date
    Apr 2015
    Posts
    5
    BTW, if there are Linux developers, I would be interesting to hear about your development tools setup.

    Below some additional info about my project specifics:
    1. Project consists of many modules, include relatively big set of 3rd-party libs. Each module is a single project in workspace/solution. There are library modules alongside with application modules (tests, tools)
    2. It is crucial to have ability to easily explore the code of any module during development at any time, debug them on source-code level, change them (include 3rd party libs). So this is why it is so important to have workspace/solution concept when all modules are build/rebuild (of course incrementally) and managed at once.


    Taking this into account, how one could setup development environment on Linux for such kind of project ?

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    gcc (the MinGW package on windows) with SlickEdit is my preferred setup both on Windows and Linux.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    You could try JetBrains CLion. It's not free, but it looks really good. I tried a beta version a while back, and found it to be pretty useful, as IDEs go.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  7. #7
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by Elkvis View Post
    You could try JetBrains CLion. It's not free, but it looks really good. I tried a beta version a while back, and found it to be pretty useful, as IDEs go.
    For C++, it has a very long way to go before ever getting comparable to QtCreator or Kdevelop.
    (For C, it would be good, I guess.)

  8. #8
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    You want to use a magical combination of two things: CMake and QtCreator.

    You will create a directory structure like this:

    Code:
    TopLevelProject/
        CMakeLists.txt
        Library1/
            CMakeLists.txt
            <sources and headers>
        Library2/
            CMakeLists.txt
            <sources and headers>
        Program1/
            CMakeLists.txt
            <sources and headers>
        Program2/
            CMakeLists.txt
            <sources and headers>
    In other words, each subproject is in its own directory and has its own CMakeLists.txt file. These are all contained in a top-level directory which also has a CMakeLists.txt. The top level CMakeLists.txt just uses add_subdirectory() to import all the subprojects into a single CMake working set. Then the individual CMakeLists.txt for the libraries and programs will indicate the relationships between the components.

    Once you have this structure in place, you can open the top-level CMakeLists.txt in QtCreator and invoke CMake. You will find yourself in a programming environment which rivals the usability of Visual Studio.

    If you need more specific details I will be happy to go over them with you here in the forum.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  9. #9
    Registered User
    Join Date
    Apr 2015
    Posts
    5
    Hi,

    Thank to all, dear colleagues!

    Quote Originally Posted by Mario F. View Post
    gcc (the MinGW package on windows) with SlickEdit is my preferred setup both on Windows and Linux.
    Start to playing with SlickEdit, at first glance looks promising, but have some issues with compilers setup. Will look further.

    Quote Originally Posted by Elkvis View Post
    You could try JetBrains CLion. It's not free, but it looks really good. I tried a beta version a while back, and found it to be pretty useful, as IDEs go.
    Thanks! Will take a look after SlickEdit.

    Quote Originally Posted by brewbuck View Post
    You want to use a magical combination of two things: CMake and QtCreator.
    While previously I was trying to avoid CMake completely, I think I have to give it one new chance Need to say that I saw no any single project with CMake build option where CMake generated build files was Ok for me personally. Well, one could say that I am perfectionist, it really juts a personal opinion.

  10. #10
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Alexey Kryshen View Post
    While previously I was trying to avoid CMake completely, I think I have to give it one new chance Need to say that I saw no any single project with CMake build option where CMake generated build files was Ok for me personally. Well, one could say that I am perfectionist, it really juts a personal opinion.
    As a developer who consumes a lot of C and C++ libraries, if a library doesn't already have a CMakeLists.txt file, the chances I will use that component drop to close to 0%.

    Makefiles are like the .o files of build systems. If you are writing them yourself then you are doing something wrong.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  11. #11
    Registered User
    Join Date
    Apr 2015
    Posts
    5
    Quote Originally Posted by brewbuck View Post
    As a developer who consumes a lot of C and C++ libraries, if a library doesn't already have a CMakeLists.txt file, the chances I will use that component drop to close to 0%.

    Makefiles are like the .o files of build systems. If you are writing them yourself then you are doing something wrong.
    For me personally the best build helper any project could provide - is just good textual description of compilation options implemented via the #ifdef. Having these I could perfectly setup build for any system, IDE and tools set in a minutes. Isn't that the only really universal approach (which also work just perfectly for any future compilers and IDEs which are not available today) ? What can CMake (or other similar tool) make better than me myself ? Does it make something really magic ?

    Please also note that this thread is not about how to build something, but how to organize the write-run-debug process in a most convenient way. Does CMake somehow related to these [development] iterations ? IMHO, no.

    Speaking about the CMake ... I don't want to say this tool is wrong or bad, but, from my experience:
    1. I saw projects which require Python or Perl to be installed in order to success the CMake build (not really problem of CMake, but ...). I really hate this.
    2. Does CMake provide some kind of "standardization" for build process ? No, unfortunately. Project could provide no build options for DLL, or static config, or way to select the CRT flavor (e.g. for VS). Just download a set of common libs like zlib, libpng, jpeg, freetype and try to add to your solution via the CMake.
    3. CMake itself is a relatively complex software and require some experience and knowledge to be used effectively in order to provide really flexible and adjustable builds (related to p.2). Unfortunately there are projects with just badly written CMake scripts.

    Taking this into account, CMake doesn't guarantee you could build the project or integrate it flawlessly into your project without additional hassles. If so, just provide me with set of all build options project were developer with (which are mostly all about the #ifdef-s), and I will setup the build with my compiler and tools in a minutes literally.

    To be honest, I never really learn the CMake deeply, maybe I just completely wrong in my opinion about it. And also my projects are really specific.

  12. #12
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    I've been using Eclipse a lot lately. I dig it.

  13. #13
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Alexey Kryshen View Post
    For me personally the best build helper any project could provide - is just good textual description of compilation options implemented via the #ifdef. Having these I could perfectly setup build for any system, IDE and tools set in a minutes. Isn't that the only really universal approach (which also work just perfectly for any future compilers and IDEs which are not available today) ? What can CMake (or other similar tool) make better than me myself ? Does it make something really magic ?
    CMake is a universal approach. If I've been provided a piece of software with a CMakeLists.txt file, I can usually incorporate that software into my build with one line of code in my own CMake script. Because that's how CMake is designed to work. So CMake *is* the universal approach you are talking about.

    Compilation options are most commonly injected into the source by macros and #ifdef, yes. And those things can be exposed out through CMake in the form of CMake variables.

    Please also note that this thread is not about how to build something, but how to organize the write-run-debug process in a most convenient way. Does CMake somehow related to these [development] iterations ? IMHO, no.
    CMake is absolutely wonderful, but that's not why I suggested you use it. I suggested it for a practical reason, and that's that QtCreator bases most of its project functionality on CMakeLists.txt files. So if you want to use QtCreator (which you do, because it provides refactoring, code completion, build configuration management, debugging, integrated Valgrind, and everything else), then you need to use CMake.

    I don't know why the Qt people chose CMake as the backbone of everything, but if I was forced to guess, I'd guess it's because it's superior to everything else.

    [*]Does CMake provide some kind of "standardization" for build process ? No, unfortunately. Project could provide no build options for DLL, or static config, or way to select the CRT flavor (e.g. for VS). Just download a set of common libs like zlib, libpng, jpeg, freetype and try to add to your solution via the CMake.
    Here, you have hit upon a legitimate gripe against CMake, and it's something I wish was better as well. But your suggestion of basically shipping no build system whatsoever, does not solve this problem.

    [*]CMake itself is a relatively complex software and require some experience and knowledge to be used effectively in order to provide really flexible and adjustable builds (related to p.2). Unfortunately there are projects with just badly written CMake scripts.
    Indeed, indeed. Check out my (very, very incomplete) attempt at a tool to help with CMake configuration: https://github.com/smxlong/nnw-proj

    I know, we're getting into crazy land by making a tool which generates a file which controls a program which generates a makefile which builds a piece of software... But hey, architecture comes in layers.

    To be honest, I never really learn the CMake deeply, maybe I just completely wrong in my opinion about it. And also my projects are really specific.
    You are literally saying what I said for a long time, before CMake finally clicked in my head. I've developed C and C++ professionally for 16 years now, and I can't believe I spent the vast majority of that time without CMake. At least give it another look.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. game development & programming skill required
    By newprog82 in forum Game Programming
    Replies: 2
    Last Post: 11-02-2010, 11:29 AM
  2. Modern DEBUG?
    By Uwar in forum Tech Board
    Replies: 10
    Last Post: 06-02-2009, 02:41 AM
  3. a qestion about modern editors
    By Masterx in forum C++ Programming
    Replies: 5
    Last Post: 02-01-2009, 01:04 AM
  4. Crossplatform Sound Library -- other than SDL and Allegro
    By frenchfry164 in forum Game Programming
    Replies: 4
    Last Post: 10-14-2003, 04:27 PM
  5. Modern Algebra
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-10-2003, 09:10 PM

Tags for this Thread