Q_IMPORT_PLUGIN compiling error with qgif and qjpeg plugin - c++

I have some problem when a try to build my code upon the 4.7.4 dynamic version. I have linkage error because of the 2 following lines :
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qjpeg)
To resolve the problem i just commented the above lines. Now everything compile correctly, which is strange. Does that mean that the code is not using the plugin (look a stupid question, but the project has several hundred thousand lines, i don,t know every part of it)
Question : What is the purpose of qgif and qjped plugin. Should i expect code using explicitly functions form these plugins?
I just want to be sure that i will not broke something by committing these lines...

You'll only need those if you're linking the plugins statically. Since you're using the dynamic version, you don't need them, and can safely leave them out. You simply need to place the plugin DLL or SO files adjacent executable. If you open up the installation where you installed the Qt libraries to (in my case, G:\Libraries\Qt\4.7.1), you'll see a directory called 'plugins' which you can copy and paste into your project, adjacent to your executable.
As for the purpose of those plugins, they add support to QImage and the other Qt image related components for addition file formats so you can read and write, with varying levels of support. The level of support can be found here, under Reading and Writing Image Files.

Related

C++ SFML with MinGW version 8.2.0 and Atom text editor

I am trying to learn to make 2d games using c++ with the SFML library. I am using windows, but I would prefer to use the Atom text editor instead of Visual Studio. I did a lot of research on how to do this, but I still do not know how to use the SFML library with Atom. So, how would I go about implementing the SFML library in my c++ project written in Atom. Thank you!
This answer supposes that you've downloaded the 32-bit MinGW version of SFML, and you'd like to compile programs written in Atom from the command line1. Inside of the SFML folder you just downloaded, there are three folders which are important for us right now: bin, lib, and include.
The bin folder contains DLLs. In this answer I'm only going to talk about dynamic linking to SFML, since that's what I have experience with. To run any dynamically linked executable built using SFML, you'll need to copy all of the relevant DLLs into the same folder as the executable. (Which are the relevant ones? The easy solution is to just copy all of them.2)
The lib folder contains libraries (files with the .a extension). If you go to the folder where you installed MinGW (the default is C:\MinGW), and then follow the path \lib\gcc\mingw32\8.2.0, you should be in a folder with a few subfolders, some .o files, and a bunch of .a files. Copy into here all of the files from the SFML lib folder. Now MinGW knows about the SFML libraries.
Lastly, the include folder contains a folder named SFML, which contains all of the SFML header files. Copy the SFML folder. Now remember the folder that we dumped all of the .a files into in the last step? That folder should have a subfolder named include, which contains a folder named C++, which contains all of the standard C++ headers (iostream, algorithm, etc.). Into that C++ folder paste the SFML folder that we picked up just a second ago. (Not the contents of the folder, but rather the folder itself.) Now MinGW knows about the SFML headers, so we can safely type e.g. #include <SFML/Graphics.hpp>
To compile, for example, the file main.cpp at the end of this tutorial and dynamically link it with Atom, you would run the command g++ main.cpp -lsfml-graphics -lsfml-window -lsfml-system inside of cmd.exe.
Disclaimer: Copying the libraries and include folder is not the method recommended by SFML. Instead, they suggest using command line arguments to tell g++ where to look. But IMO (1) their method is more of a pain for first-time users, and (2) first-time users are unlikely to be using multiple compilers or multiple versions of SFML. (If you are using multiple compilers or multiple versions of SFML, you'll want to do it their way. In that case let me know and I can try to help.)
1) It's possible you're actually looking to compile directly in Atom at the click of a button (F5 by default?). If you already know how to compile non-SFML applications directly in Atom, then I think the above should be enough for you to compile SFML applications too, as long as you set your default compiler flags appropriately in Atom. (By which I mean: For the example above your flags should include -lsfml-graphics, -lsfml-window, and -lsfml-system, in that order).
2) To figure out what DLLs you need, you can add them all and start removing them until your application doesn't work. Alternatively, keep these three things in mind:
You always need openal32.dll
You need the DLLs that you linked to when compiling
You need the versions with "-d" (e.g. sfml-graphics-d-2.dll) if you're compiling in debug mode, and you need the versions without it otherwise
So in the case of the example above, you only need openal32.dll, sfml-graphics-2.dll, sfml-window-2.dll, and sfml-system-2.dll.
You need Atom Packages
So, iam currently developing a new package for SFML compile on Atom.
I just need to write the Docs and make it a Atom package, but take a look on the repo: https://github.com/brhaka/sfml-compiler
You can contribute to it, or just star :)
Iam working hard on it to release as soon as possible, so i suggest you to just wait a little bit. There's another package for that, but there's no documentation.
Your name is really cool!
I hope this can help you!
Brhaka

My project can't find its libraries when run manually from the terminal

I'm creating a library for the first time. So far it's working from the IDE (Qt Creator), but not from the terminal when I run its testing program manually.
There are two parts to my project, the library, and the sandbox for testing it. I've created a project in Qt Creator that includes two subprojects (one to build the lib, and one to build the tester) and both compile without errors. When I run the sandbox from the IDE the library is dynamically linked to the sandbox, the function greeting() is loaded in from it, then called, and prints "Welcome to the library!" to std::cout. However, if I open the build folder in the terminal and run the sandbox directly using ./sandbox I get:
./sandbox: error while loading shared libraries: libengine.so.1: cannot open shared object file: No such file or directory
I took this to mean that I needed to properly install my custom library, libengine.so.1. When I looked up how to do that I found that I just needed to copy the library files in to either, /usr/lib or /usr/local/lib, but neither of those worked and I'm still getting the above error. In the past, that simple solution did work for me when compiling a 3rd party library (SDL, I think) and I don't know what I'm missing that would mean it wouldn't work now. So far I haven't yet found any more detailed information and I don't know what I'm doing wrong or have missed.
How do I make my sandbox program see its companion library when I run it directly from the command line?
NOTE: I'm specifically asking about Linux/Ubuntu. If I later run into problems under Windows I'll be back. :-)
Short Answer
I ran in to multiple problems all at once.
First problem: Broken symbolic links (they're like shortcuts in Windows).
Second: My lib needed to be copied in to a different system directory than is generally recommended.
Third: Qt Creator and QMake made passing custom linker options difficult.
The Details
When Qt Creator compiles my library it automatically creates three symbolic links to it with different layouts of the version numbers.
> ll
lib-engine.so -> lib-engine.so.0.1.0
lib-engine.so.0 -> lib-engine.so.0.1.0
lib-engine.so.0.1 -> lib-engine.so.0.1.0
lib-engine.so.0.1.0 (original library file)
For some reason (I don't know why) each time I moved the links in to a system directory like usr/local/lib the links would break. I didn't notice this at first, or even think to check, because that's never happened to me before. Moving a link has always worked in the past. To get around this I just manually created the links within the directories they would reside in.
Broken links aside, putting the library in to usr/local/lib still didn't work, but usr/lib and /usr/lib/x86_64-linux-gnu (recommended in the blog linked below) did work!
Those fixes actually came after a different fix I looked in to after reading this blog and this article it linked to.
There it said to add -Wl,-rpath,'$ORIGIN/lib' to the gcc build options to embed a library search path in to the application itself. This set of options would allow me to put my library files where ever I wanted (specifically, in a directory called /lib in the application's working directory).
Unfortunately, that had two problems of its own. First, Qt Creator doesn't (from what I can tell) allow you to specify custom build options for individual subprojects through the GUI, so I had to figure out how to add linker options using the project file, assuming that was possible, which it was.
Second, QMake messed up the gcc options, embedding in to my application Library rpath: [RIGIN/lib] instead of Library rpath: [lib] like it's supposed to.
In the end, changing the proposed linker options of...
-Wl,-rpath,'$ORIGIN/lib'
... to the following QMake project file line...
QMAKE_LFLAGS += -Wl,-rpath,'lib'
... work out nicely. Using both fixes I can now either install my library on my system or put it in to a /lib folder and the program will run.

How to add 3rd party library in Unreal Engine 4

I am new to Unreal Engine. But here is what I planned to do. I want to an experiment project by combining socket.io with Unreal Engine 4. I know somebody may shot at me, for it already had a plugin. But I don't like graph programming at all (I prefer "real" coding)
But as I followed instruction from Installing socket.io C++ and here. It just won't work. The error told me something about File Not Found on multiple headers file from this github repo. So I tried to add a lot of things (Hopefully it won't affect the outcome). And now a tons of errors had popped up. Now they are mostly about Macro errors. And I have absolutely no idea how to fix.
The problem is I don't understand why after I include .lib files to PublicAdditionalLibraries I still needed the original file (Shouldn't it work like any other visual studio projects?)
Also how to tackle loads of errors I am facing
Thanking in advanced
Did you add your include paths with the lib headers to PublicIncludePaths array ( in the StartupModule() method ? it's gonna be needed to use methods from your lib.
Here is an exemple how to use the PublicIncludePaths
string includePath = Path.Combine(ThirdPartyPath, "opencv", "include");
PublicIncludePaths.Add(includePath);
ThirdPartyPath is a member of my module class i retrieve with my getter
Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/"));
I took a look at the github repo of Socket-IO-cpp lib and the only libs compiled for windows are in 32bits, take care you're not tried to compile in 64bits, or every .lib files of your libraries are in 32bits to be linked all together, in case you're using others libs.
If you got some runtime error, take a look at my answer which explain how to indicate .dll when .libs arn't enough.
Hope it helps

Run time error on executing the exe manually

I have a Qt application, which runs fine when I execute it from Qt Creator. However, on running it by manually clicking the generated exe, I get the following error :
I would understand if it would ask for missing DDLs (which I could then place in the same folder). But how should I proceed to handle this (in general) ?
P.S. It is not giving any line number in my source code which I could try testing this assert for. I tried using the release mode as well, but the same error.
We don't know what the problem with your code is; you'll need to use a debugger to find that out. I think that the pre-built Qt libraries that you download come with debug symbols, but if they don't, you can always build Qt yourself to get them using the -force-debug-info configure option.
You can also use DebugView to see debug output of deployed applications.
However, in general, you should use the windeployqt tool that is included with Qt.
The Qt for Windows - Deployment page has more information about deploying Qt applications to Windows machines, but windeployqt should do everything you need.
My qml files were not getting deployed properly and thus this error (this assert is probably on the variable storing the main qml file name, i.e. it should not be an empty string, which in case of missing main.qml, it was). Placing the qml files at correct paths solved the issue.
Also, as #mitch has pointed out in his answer, use windeployqt to find out the dependencies. Although, I have also realized that it doesn't cover all the dependencies (MSVC runtimes for example and other compiler related files sometimes). In that case run the dependency walker and place the missing files manually along with the exe.

Packaging a modified Qt class

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.