Shared Code Library

  • I want a library of code that can be shared between multiple QtCreator projects. Any change to the code in that library by any of the project will be available to all projects. It would mimic the Smalltalk image. I have read the documentation for the Qt library, but it focuses on creating run-time libraries; it did not answer my question.

  • Qt Champions 2017

    There is nothing like smalltalk image in c++ if you mean this definition
    "Smalltalk objects live in something called an image. An image is a snapshot of memory containing all the objects at a given point in time."
    While you can just save all instances of a class to a file, its not possible to just load it again. Smalltalk used a vm for this. C++ has no such concept.

    If not a runtime library, then what sort of library do you mean ?

  • Lifetime Qt Champion


    From your description, it rather looks like a project management issue e.g. using git, have your library as a submodule of the projects that uses it and then keep it up to date through code reviews and proper project management.

  • @mrjj I know from working with C++ in the distant past--everything was compiled. The application I am developing is complex and how to do things are not really defined; it is an exploratory type of application for which Smalltalk was well suited; C++ is more, in my estimation, suited to well defined application were everything is known, a priori knowledge.

    I want to have a class that is mostly defined, but lacks features. I create one or more exploratory projects that uses that code, but also makes changes to it as the texting and development continues. This continues until the best approach shakes out. The reason I say that the application is complex is that there are many unknown approaches to be determined, but I what the shared code to be available to all projects in the development.

    I am using a divide and conquer approach; focus on one aspect and when a reasonable answer is found move on to the next, but also be prepared to backtrack. In Smalltalk a project would jut be a class that was included in the image with the code in classes, also in the image. The code I want is in files and it seems that I should

    The alternative I am using now is to create a project to explore an aspect classes in that project are manually copied into the next project to explore another aspect, so on and so forth. The code I want is in files and it seems that I should be able to point Qt to them.

    What am I missing?

  • @SGaist I am the only developer--using the Chief Programmer concept, project management and code reviews are in my head. I have not used git, but if it will solve my problem, I am more than willing to learn it. Is there some documentation that explains the interface between git and Qt?

  • Qt Champions 2017

    If you use a code revision system, you can add tags to be able to backtrack to
    a state of the project in time, or have multiple version of the same project
    sharing files and sharing updates.
    If you want to be able to say experiment on a code base, save the result and then next day, load another version of the project and try something else
    then a code control will be your friend.

    Many people uses GIT.

  • @mrjj Which works the best with Qt?

  • Qt Champions 2017

    All of them. Qt need nothing special.

    I used subversion directly in Creator.
    I assume there is a GIT interface also.

    I would recommend a bit of research on the code revision subject to make sure its what you are after.
    Its sounds like it but so far from smalltalk to c++ that you could have other desires.

  • @mrjj Thanks. I will look into Subversion, but I have not seen how it can be use to share one group of classes that are not compiled across multiple projects.

    This will probably show my ignorance of the structure of the C++ file system, but you can have .h and .cpp files that you include. It would seem to me that in Qt I should be able to have multiple Qt projects point to the same .h an .cpp files using the add existing files. I will try that.

  • Lifetime Qt Champion

    That has nothing to do with Qt. It's standard C++ project management.

    If you want to have a library that all your projects can use and that you can modify at will, then make it an autonomous project, build and install that library on your system and use it like any other C++ library.

  • Qt Champions 2017

    I would recommend GIT as its the new app, all is using and there are
    tons and tons of info about using it.

    • share one group of classes that are not compiled across multiple projects.

    You would share the files. ( and hence the classes)
    Have them under code revision.

    Then in Project A
    you update something in the shared part.
    You commit that change to the server.

    Then in Project B
    You just say Update and now project B also have any changes that were
    made in A.
    With no copying files around etc.

    Is that what you mean?

  • @mrjj That sounds like it is exactly what I want; I am only interested in sharing code, not compiled code, because it if far from being finalized. I want to thank all for adding comments. To SGaist, what is an autonomous project?

  • Qt Champions 2017

    @ofmrew said in Shared Code Library:

    autonomous project?

    Like a standalone project.
    If you made a shared library, all project would/could share it.
    If you installed it on your system, it would be like any other shared library.
    If you made a new version, all would use the new version.
    But this is compiled code.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.