Packaging a modified Qt class - c++

Heads up, this is going to be confusing:
I customized 9 files from Qt5.2: qquicktextdocument.cpp qquicktextdocument.h qquicktextedit.cpp qquicktextedit_p.h qquicktextedit_p_p.h qquicktextnode.cpp qquicktextnodeengine.cpp qquicktextnodeengine_p.h qquicktextnode_p.h
Each file is simply prefixed with a letter and still inside /qtdeclarative/src/quick/items/. I am 100% happy with the modifications I made being put under GPL etc. I somewhat want my end application (discussed below) to be Apache or MIT, but, I'm flexible.
My modifications work fine. When I modify a few additional files I am able to compile them along with the rest of Qt (at the same time, using the same make command). But these modifications are going into another Qt application that I am making which I want other people to be able to use, and requiring general consumers to have a custom compiled version of Qt would be obviously absurd.
I want to package/compile/do something, that will enable me to include the modifications in my final project as a shared library, or something.
As a web developer writing C++ and Qt, I am very confused about linking shared libraries, header files, etc.
To recap, I modified Qt 5.2 and made a custom compilation of it for an application I am building, and I want people to be able to run that application without having to have a custom compilation of Qt. I need a way to decouple my Qt modifications from Qt.
I realize this might be a big topic, I'm not expecting a step by step guide, just some general guidance. So far I have tried compiling my modified files as a library, then including that library in my actual project, but I am getting undefined references and missing files all over the place. (I don't know if I did anything right)
I am also currently looking at subclassing the classes I want but I'm unsure about this. It might require copy pasting some code, which could have licensing issues?
end goal: be able to have a wavy underline (in qml) for incorrectly spelt words.
Thank You.

My 5 cents.
If your changes can be useful (in general) to other people you can try to push them to upstream via codereview.
If you want your application to run only in windows everything become obvious: in windows it is normal to provide your application with shared libraries (to avoid DLL HELL). Btw, have you heard about static linking?
Qt has some plugin mechanism. You can compile your code into shared object (dynamic library) and install it with your application. For example, QML FolderListModel do this. You can look at code in $qt5_src/qtdeclarative/src/imports/folderlistmodel.

Related

Deployment of Qt app when sources change frequently

I'm currently working on a GUI app that is supposed to decrypt some data and print it on the screen, on Windows and Qt (C++) based. The code works fine and I now have to distribute it.
However, the format of the data to decipher can (and will) evolve, and is described on headers (.h) and sources (.c). Therefore, when this happens, I just have to change these files to the last version, the compilation goes fine and the program runs smoothly. It's a simple drag&drop of the new files in my source folder, really.
I am aware of how to deploy a .exe (with the correct dll and so forth), but I don't think it would work in this case. I briefly looked at how to create installers but i'm not sure that this is the right way to handle the situation (http://doc.qt.io/qtinstallerframework/ifw-creating-installers.html).
How could I distribute this code so that people that want to use it can just change the sources, run a script, and the .exe is generated, even with a computer that does not have Qt ? (but probably mingw32 and only on Windows)
Thanks in advance for your help !
From my understanding, you should include dll's and if the format of the data changes, you can just update and maintain your dll's.
Build your project in release mode and then use QTWinDeploy to finalize the build of the project with all the dependencys the projects require for users without QT.
This is how I maintain and distribute a project similar to yours.
Otherwise, I would recommend looking at self-updating programs.

Android ndk c++ do i have to change my whole code or can i use precompiled executables/make

As the topic says, I'm interested in using some existing c++ code. It is quite much so I don't want to change everything. That's why I'm asking if I have to change the whole code or if it is possible to include it somehow.
As I noticed Android Studio/Gradle wants a CMake file in order to include those external libraries, but my code only includes ordinary makefiles.
Is there any way to make use of the given structure without many changes?
I can't give too much information about the code because it will be too much but here is something about it:
C++ Code
Using Makefiles
(will add more if needed)
Methods I tried:
Ship code inside assets, copy it in the local directory and use then use "make" to compile it on the smartphone - result: permission denied
Use precompiled Unix executable - I couldn't find a right compiler yet (already tested Android standalone toolchain)
Use Android NDK - I didn't manage to include the existing code because the changes were too deep
In my opinion, the best way would be one of the first two options. But I haven't found a way to handle these problems, which are listed above.
What I would like to know is now:
Which option would be the best? Of course, if they're all possible that will depend on the problem, but some opinions would be nice.
How do I know what compiler I have to use?

How should/could/must I handle the dll that my C++ projects depend on?

I'm lost here and I have no clue how to proceed. This is not a question about how to make my program work, this is a question about how to stop wasting my time.
My programming environment is Visual Studio 2013 on windows, in C++.
I use 3 libraries extensively, namely: boost (using dynamic linking), OpenCV, and Qt.
During the development, I have configured VS to look at those 3 libraries by default for include and .lib. I have also added the 3 folders containing all the dlls to my PATH environment variable.
It works, but it is sometime painful, let me explain you when.
First hassle: Anytime I have a LNK error telling me I miss a function, it is usually on OpenCV since it has only one include file referencing all the functions. I have to look at OpenCV's source code to see what module this function belongs to and to know what I must link my program to.
Second Hassle: When comes the time to deploy my application, I have to ship it with all the relevant dlls. To know which one I need, I open dependency walker and try to forget nothing, I have then to test it on a different computer because 102% of the time I have missed a couple, and then I have to configure my Installer generator to include all those one by one.
Third Hassle: To ease a little bit the process of configuring a new development machine, I have recently switched to NuGet. It is great, I add boost with a couple of clicks to any project. But now my boost DLLs are everywhere, I have one folder per boost library, and since there are dozens of those I can't even add them all at once to my PATH now, so I have to move them manually to the appropriate folder, and that is really not what I want to do with my not-so-precious-but-who-are-you-to-judge time
I have looked around and couldn't find any good practice regarding this issue, maybe because they are too obvious, or too specific to a particular setup.
How do you do? How would you do if you were me?
We put all our external dependencies in version control along with the code. This ensures that all code can build "out of the box" on any of our development machines and also ensures that for any given version of the code, we know exactly which dependencies is has.
The best way to check for missing dependencies is how have a good automated test suite, if you've got comprehensive converge then if your tests pass you must have deployed the required libraries.
In terms of linking to the appropriate libraries, unfortunately, that just sounds like an issue with the structure of OpenCV (I'm not familiar with OpenCV). I tend to use dumpbin under Windows and nm under Linux to easily grep for symbols when I get link errors with an unfamiliar library.

What is the important dll files to execute any Qt5 application on any platform (Runtime files dll)?

I have created a simple application in Qt5 but, when run that application in for example windows 7, tells me the dll file something is missing, and another dll and another dll.
Now I want a package that contain all dll files that any Qt application needed.
Or, What's the Important dll files that needed to work any Qt application ?
Or, What's the Important dll files that needed to work any Qt application ?
In general, the Qt modules that you are using. If you use QtSql, you need to have the corresponding dll, but it goes the same way for any module. As for a simple core application, you would need to have the QtCore dll, respectively. I could continue the enumeration, but I believe you see the pattern how it goes.
Going even a bit further, you would need to specify your dependencies in the LIBS variable if you happen to use qmake. That is also a place where you would already need to be aware of your direct dependencies.
It would be usually the single library name, but in complex cases, you can always read the documentation of the project. The main point is the fact that you need to get aware of this without debugging. The latter would be more like an after-thought.
There are no "hidden dependencies". Since you are coding the project, you know the dependencies that you use. You will need to ship them.
There are some odd and rare cases when issues come that you would not be aware of, like missing dll for a different machine having a distinct VS/MSVC setup. In that case, it is better not to ship all the dlls for each possible end machine, but the end machine is supposed to install redistributable packages.
In rare cases when the above does not suffice, you can check the error message. If that is still unclear, you can use introspection tools for debugging the issue, like dependency walker.
Disclaimer: this answer goes as broad as the question is.

Using C++ code on iOS, create a static library or mix with Objective C?

I have some C++ code (exposing a C-only interface through a header) which I will use for an iOS project.
I can either create a static library and link to this from my app project, or add the source files directly to the app project - which option is best?
All answers appreciated!
Add the sources if you expect them to change often. Otherwise a library will be more suitable and will make your project cleaner (however, you will have to put only the header files in your project)
I've used OpenCV in one of my app projects which is mostly written in C++. I've found that adding the source files to the app project worked better for me because I made some minor changes to the code wherever appropriate. Comes down to the use case basically.
I always prefer to add the source if I have it, simply because it makes debugging easier. If you're making a call into a library routine and getting back an unexpected result (or crashing, or whatever), it's much easier to step into the library code with the debugger and figure out what's going on. If you just have a static library, it's a black box and you can't see what's going on inside. It also allows you to change the library code more easily if you encounter a bug or a missing feature (just be careful if the library is shared among other projects, to make sure you keep the library code up to date in its own repository).
Xcode is good about letting you keep your project organized, so use those features to your advantage. Keep the library code and headers separate from your main application and link it in as needed.
I suppose by code you don't mean a well formed library, so I expect this code could get any kind of modification pressure in the future. The best way is then wrapping it. here is one very nice example, but you might do it differently: http://robnapier.net/blog/wrapping-cppfinal-edition-759