How to statically link Qt image formats plugins for WebKit? - c++

I need a QWebView to display images, instead of the question marks it currently displays.
I have found that i need to link some image plugins to my application to do so. I have researched this problem for a while now, and I haven't found a satisfying solution.
I followed these steps:
1) I have added in my project folder and the folder in which the application is compiled a folder named: imageformats/ in which i have put these folowing plugins: libqgif.so and libqjpeg.so
2) I have added to my project configuration file (.pro) this:
QTPLUGIN += qjpeg \
qgif
3) And I have added to the .cpp containg the main function of my project this:
#include <QtPlugin>
Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qgif)
And i get the following errors:
main.cpp:(.text.startup+0xce): undefined reference to `qt_plugin_instance_qjpeg()'
main.cpp:(.text.startup+0xda): undefined reference to `qt_plugin_instance_qgif()'
I also tried changing the directory to plugins/imageformats/, but it made no difference whatsoever.

For me (on Ubuntu 12.04), I didn't have libjpeg and dev headers installed.
$ sudo apt-get install libjpeg62-dev
(which will also install libjpeg62 if you don't have it).
After this, my QTWebView showed jpeg images without any extra modifications.

Related

contrib module missing in opencv 3.0?

I am using OpenCV 3.0 beta.
I tried to create a face recogniser using createLBPHFaceRecognizer(); class as,
**Ptr <FaceRecognizer> model = createLBPHFaceRecognizer();**
the error I have is
**error: 'createLBPHFaceRecognizer' was not declared in this scope**
I have researched and found that the class exists in contrib module of opencv2
(opencv2/contrib/contrib.hpp) in previous versions of OpenCV
But this module is not available in opencv 3.0 beta.
So where are the recogniser classes defined in opencv 3.0?
If they are not defined,how can we add this module in addition to the existing modules?
you will have to download and build the opencv_contrib repo.
after running cmake, make, make install,
#include <opencv2/face.hpp>
// note the additional namespace:
cv::Ptr <cv::face::FaceRecognizer> model = cv::face::createLBPHFaceRecognizer();
// proceed as usual
from https://github.com/opencv/opencv_contrib:
Start cmake-gui
Select the opencv source code folder and the folder where binaries
will be built (the 2 upper forms of the interface)
Press the configure button. you will see all the opencv build
parameters in the central interface
Browse the parameters and look for the form called
OPENCV_EXTRA_MODULES_PATH (use the search form to focus rapidly on
it)
Complete this OPENCV_EXTRA_MODULES_PATH by the proper pathname to
the /modules value using its browse button.
Press the configure button followed by the generate button (the
first time, you will be asked which makefile style to use)
Build the opencv core with the method you chose (make and make
install if you chose Unix makfile at step 6)
To run, linker flags to contrib modules will need to be added to use them in your code/IDE. For example to use the aruco module, "-lopencv_aruco" flag will be added.
On my Debian installation
$ dpkg -l libopencv-contrib-dev
ii libopencv-contrib-dev:amd64 3.2.0+dfsg-6 amd64 development files for libopencv-contrib3.2
enables me to use contributed modules with just an additional include. For example:
#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
auto model = cv::face::createLBPHFaceRecognizer();

Installing Qt Components for Windows

I am able to compile the source of qt-components just fine using the following steps:
Downloaded the tar.gz from http://qt.gitorious.org/qt-components/desktop/trees/master
Unpacked the components
Added path variable value to the environment variables for mingw and qmake
Ran the following command: qmake && make install
I can see that the above command exits successfully and copies the qml files and a few other folders to C:\Qt_2.8.0\Qt4.8.4\imports\QtDesktop
I then open up qtcreator and inside of my qml file, I type import QtDesktop 0.1, but it returns an error of module "QtDesktop" is not installed. If I hover over the QtDesktop import statement, it reads Library at C:\Qt_2.8.0\Qt4.8.4\imports\QtDesktop - Dumped plugins succesfully.
...so what I am doing wrong here?
Please note that I am constricted in using Qt4

Trouble getting a Qt Reference Document program to work(Minehunt)... its just blank when run... no errors though?

http://docs.huihoo.com/qt/4.7/demos-declarative-minehunt.html
When I build and run... I just get a blank white rectangle... game is MineHunt.
The source code is in the URL. I created files and copied and pasted into Qt Creator 4.7.
Running in Linux.
No need to downvote. Deploying qml apps does not seem to be easy for beginners. jdl, I don't know if I can help you. Currently I am only on Linux. But what I did:
I copied the whole folder minehunt in my destination folder (/tmp/mine). When I ran qmake I got:
WARNING: Include file
/tmp/mine/helper/qmlapplicationviewer/qmlapplicationviewer.pri not
found
So I also copied the examples/declarative/helper folder into /tmp/mine.
Looked like this:
/tmp
/mine
/minehunt
/helper
Then I changed into minhunt, did 'qmake' and 'make'. A few seconds later I had a working minehunt binary in /tmp/mine/minehunt/.
I'll try tomorrow the Windows build.
Edit: Ok, tried now under Windows 7. Qt4.
QtCreator opened.
Project ...qt\demos\declarative\minehunt\minehunt.pro
loaded. Normally in release mode compiled. No problem. A file minehunt.exe was created in ....qt\demos\declarative\minehunt\release. Started: White screen. Exactly as you described it. In ...qt\demos\declarative\minehunt I found a folder 'qml'. I moved this folder and the minehunt.exe into another folder (myMineFolder). Simulating a simple deployment this way. Clicked on minehunt.exe -> worked like a charm.
So my folder layout:
myMineFolder
qml
minehunt.exe
But of course, I have set my PATH variable correctly to my Qt installation.

Qt-creator and ncurses: initscr() not found

I am on Xubuntu x64 and I want to use ncurses in my software. This software is being build with Qt Creator 4.8. I have no problems including the ncurses.h file, but when I want to use functions of ncurses (initscr() and endwin()) I get the following errors:
Undefined reference to 'endwin'
Undefined reference to 'initscr'
What steps should I take to fix this problem?
I have installed the following ncurses related packages:
libncurses5:amd64
libncurses5:i386
libncurses5-dbg
libncurses5-dev
libncursesw5:amd64
libncursesw5:i386
libncursesw5-dbg
libncursesw5-dev
ncurses-base
ncurses-bin
ncurses-examples
I found out (finally)
The right way to do it: rightclick your project->add library -> system library
Here you need the path to the *.so file (so not *.so.5 or something), which was in my case
/usr/lib/x86_64-linux-gnu/libncurses.so
Then add it and tadaaa: done.
and I also found this guide may be it works, to me none has worked yet
http://www.lucidarme.me/?p=3961
"In the .pro file of the project, add the following line to specify to the compiler it has to use the ncurses library:
LIBS += -lncurses
To avoid the following error message : “Error opening terminal: unknown.”, add a variable in the run environment of Qt. Project -> Run -> Run environment -> add. Add a variable named TERM and set it of xterm."
UPD: my problem solved by checking the "Run in terminal" option in Projects->Run.

How to use SQLite in C++ program using Code::Blocks?

I'm a complete beginner with Code::Blocks and SQLite, and have some basic knowledge with C++. I'm currently using Ubuntu 11.04.
I have downloaded SQLite Amalgamation here. When I extracted the zip file, there are four files inside: shell.c, sqlite3.c, sqlite3.h, and sqlite3ext.h. If I simply add those files to a (for example) a console project, it gives out an error: the .c's of the downloaded sqlite each have their own main function. Removing those from the project, the errors are gone and I can call #include "sqlite3.h". I am trying to follow this, and tried the first two lines of code from here and it gives out an error: undefined reference to sqlite3_open.
I think adding those .h's directly to a console project isn't the right way to use it, though I'm not sure.
How exactly should I use those? What should I do to use those for my C++ program?
Any help is greatly appreciated. :)
EDIT: I also tried to create a .a file of those sqlite files by following this. When I try it, it gives out an error: cannot find -lsqlite.
I got it! Though there was something that I did that caused problems.. I forget to remove the .a file that I added at Project > Build Options > Linker Settings earlier, which caused problems..
Here are the steps I made to add SQLite: (for those that might have the same problems)
Copy the files extracted from the SQLite Amalgamation to the directory of the project.
Add the sqlite files (Project > Add Files) EXCEPT the shell.c (it is the one that causes the multiple function error)
Compile it (Yes, a simple Ctrl+f9).
here are errors: undefined reference to pthread_mutexattr..... These are fixed by going to Project > Build Options > Highlight 'the Project Name' above Debug and Release at the top left corner > Linker settings, and adding "-lpthread" (without quotes) to Other linker options:.
Some more errors are found: undefined reference to dlopen, dlerror..... Add '"-ldl"' just below the '"-lpthread"' added earlier.
DONE :)
I didn't find a complete answer for Windows as a beginner, and at the beginning it is very painful to understand everything. So here's what worked for me.
Download the SQlite Amalgamation file.
Open Code::Blocks -> New Project -> Choose static library
Unzip the file you have downloaded and copy the folder/contents to your new project directory. Add all the files to the project and build the project.
You will find a ProjectName.a file in the bin/Debug or bin/Release directory. Copy that file to your actual SQlite project directory.
Go to Code::Blocks Project->Build options. Select 'Linker Settings' tab and add the path to the .a file. Don't close it yet!!!
In 'Search Directories' tab, select the 'Compiler' tab, add the path to the Amalgamation header files, or copy the header files to your directory (you can add the header files to your project) and in the 'Linker' tab add the path to the .a file
Now Compile!!! Hopefully this will run
That is all, I wish it'll save some searching time for another noob
You will need to compile the sqlite code first, and then just #include "sqlite3.h" into your project where you need it.
UPD:
Try this:
Download this package from sqlite site and extract it somewhere, say, into a folder called "sqlite". Open terminal, and go into this folder. Inside of it, run
./configure
sudo make
sudo make install
and see what happens. It should build itself automatically. Consult the README file that is inside the archive too.