Expected type-specifier before 'QSslSocket' in QT Application - c++

I am still fairly new to Qt, but I'd like to write a program that allows a user to send a small message via email.
When I go to build my project I get errors like
expected type-specifier before 'QSslSocket' and 'QSslSocket' was not declared in this scope. I get these both when I try to compile my code and when I try to compile the demos from the git, so I don't think it is in my code.
Looking into this issue I have seen that most solutions involve making sure that openssl is installed on the machine and that Qt was built with the openssl flag set in the configuration. I have ensured that I have openssl and libssl-dev installed and I just rebuilt my version of Qt using the openssl flag. Still no luck.
In my project I have QT += core network added in my .pro file. I have #include <QtNetwork/QsslSocket> in my *.h file that requires it.
As for my system, I am working on Ubuntu 14.04 LTS. I have Qt 4.8.6 installed (again with -openssl included in the config file). Openssl and libssl-dev are both at 1.0.1f-1ubuntu2.11.
If you have any ideas they would be greatly appreciated!

Ultimately, it did come down to my configuration. I completely removed all versions of Qt4 off my computersudo make uninstall (since I installed from a tarball instead of from the repository), I cleaned my configuration file using make confclean, I rebuilt the configuration using ./configure -openssl, then make and finally sudo make install. I think the issue before was that I had not cleaned my config file first. I had a version installed for embedded Linux and it is possible that I was applying the -openssl flag to that build since I had installed that later. For the record both #include <QtNetwork/QSslSocket> and #include <QSslSocket> work, at least in my version of Qt (4.8.6).

Related

How Qt's example built during cross compiling qt compared to run qmake after compiling?

FIRST, it's not the issue that Qt CANNOT found target .so, qt can found it, but it failed to load it and produce not logs... on both terminal and gdb. It seems that qmake/make is using wrong library but I have only one qt installed in my cross compile environment that generated by make install.
I'm struggling for cross compiling qt5.10 for raspberry pi on Windows. I'm using msys2, gnutoolchains's raspberry chains.
The problem here is the examples built by the compiling process runs almost no problem, I only needs to add a qt.conf to fix the prefix override by msys2 and it can run and display something on my pi.
But when it comes to qt creator, or qmake out of cross compiling, it starts to show me:
This application failed to start because it could not find or load the Qt platform plugin "xcb"
Here are two problems, first, the platform plugin should not be xcb since I'm running without x, cross compiled version will use eglfs by default.
And, second, even I specific platform plugin to eglfs, it still tells me it cannot load eglfs.
I'm putting two version of programs in the same place.
qt5pi/examples/opengl/2dpainting $ ls
2dpainting glwidget.cpp helper.h widget.cpp window.h
2dpainting.pro glwidget.h main.cpp widget.h
2dpaint_my helper.cpp qt.conf window.cpp
2dpaint_my is compiled by qmake && make and 2dpainting is by qt's cross compiling process uses the same source.
I'm suspecting qt is adding something during it's cross compiling, but I'm not sure how it happened. Qt'wiki about raspberry pi contains nothing about this issue.
update
It looks even wired to me. I copied a running example from its folder to another and it also crash, things look like this..
pi#raspberrypi:/usr/local/qt5pi/examples/qt_test $ cp ../opengl/2dpainting/2dpainting .
pi#raspberrypi:/usr/local/qt5pi/examples/qt_test $ ./2dpainting
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen,vnc, webgl, xcb.
Reinstalling the application may fix this problem.
Aborted
pi#raspberrypi:/usr/local/qt5pi/examples/qt_test $ ../opengl/2dpainting/2dpainting
qt.qpa.egldeviceintegration: EGL device integration plugin keys: ("eglfs_brcm","eglfs_emu")
qt.qpa.egldeviceintegration: EGL device integration plugin keys (sorted): ("eglfs_brcm", "eglfs_emu")
qt.qpa.egldeviceintegration: Trying to load device EGL integration "eglfs_brcm"
qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_brcm"
qt.qpa.input: Initializing tslib plugin "TsLib" ""
qt.qpa.input: tslib device is "/dev/input/event0"
I'm not sure, but it seems that the this step on qt'wiki introduced some qt5.7 files into lib folder.
sudo apt-get update
sudo apt-get build-dep qt4-x11
sudo apt-get build-dep libqt5gui5
sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
The problem is, qt's examples, when it on their own folders, can magically find (maybe qmake install did something?) and use the correct *.so, and so it works without problem.
But, when compiling with qmake, the program won't find the correct libraries so, newer libq*.so with older libQtXXXXX.so lead to this probleam. And that's how it uses a different qt version with compile.
And, that indicates the optional 00- in step 13 from the wiki:
[on RPi] Update the device to let the linker find the Qt libs:
echo /usr/local/qt5pi/lib | sudo tee /etc/ld.so.conf.d/qt5pi.conf
sudo ldconfig
If you're facing issues with running the example, try to use 00-qt5pi.conf instead of qt5pi.conf, to introduce proper order.
should be taken even the examples run without problem.

install wx-widgets is driving me insane on Yosemite

I'm on Mac OS X Yosemite 10.10.2. As far as I know, wx-widgets were preinstalled on older versions on OS X (probably that's why google search doesn't help), but that's not the case anymore. I need to get started on a C++ project using wx-widgets, using any IDE (Eclipse, Codelite, or whatever is best). However, I simply cannot get wx-widgets to work. After a workaround I was able to compile on my machine wxWidgets-3.0.2. I called from terminal make and make install, but the libraries seem to not be correctly installed. Indeed, if I create a project on Codelite I get many "wx-config: Command not found" errors. Can someone help me to get me started on installing the libraries and creating a simple project that includes wx-widgets?
I use homebrew which is installed by copying and pasting one line from the homebrew website.
Then, the installation of wxWidgets is simplicity itself with:
brew install wxmac
Any problems, you just call the doctor with
brew doctor
Now you have a proper package manager you can install ImageMagick, GNU Parallel, GNU awk, Oxygen, webkit2html, zeromq, tree, SDL, Redis, sqlitebrowser, pandoc, exiftool, ffmpeg, 7zip, awscli, etc...
You can then compile your wxWidgets programs with
g++ `wx-config --cxxflags` -o sample sample.cpp `wx-config --libs`
I can successfully compile and install wxWidgets on Yosemite with these commands:
- Get the latest sources of wxWidgets 3 from wxwidgets.org and unpack them.
- Move the unpacked directory someplace where you want to keep it.
- Open a terminal and change into the wxwidgets directory.
- Create two directories: build-release and build-debug (don't rename those!)
- Change into wxwidgets/build-release
- Run
../configure --with-osx_cocoa --disable-shared --with-opengl --enable-universal-binary=i386,x86_64 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6
- Run make, then sudo make install
- Change into wxwidgets/build-debug
- Run
../configure --enable-debug --with-osx_cocoa --with-opengl --enable-universal-binary=i386,x86_64 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6
- Run make, then sudo make install
Be aware that these instructions are for compiling against the Mac OS X 10.6 SDK, which I have at /Developer/SDKs/MacOSX10.6.sdk. You can try to omit the --with-macosx-sdk parameter altogether, which will compile using the latest SDK. Also ensure that you have Xcode and the command line developer tools installed.
These commands will install static libraries for the release build and shared libraries for the debug build. You can change this by supplying or omitting the --disable-shared parameter.
The instructions for building and installing wxWidgets are included in the distribution and can also be viewed online.
If your IDE doesn't find wx-config, you must not have the location where you installed it (/usr/local/bin) by default in your PATH. Add it there to fix this.
Like suggested by VZ, you must change your PATH.
But not the variable PATH in your environment Windows but the variable PATH in your C++ project. It's strange but maybe it's different.
Go into (for eclipse) :
C/C++Build->Environment->PATH (add the path of wx-config in the beginning).
Press : Apply, OK and build the project.
I think is strange that Eclipse don't update the PATH after rebooting the OS. Maybe we must add an option to Eclipse for building WxWidget and force Eclipse to update the PATH, but I don't know it.
This change work for me.
Eclipse / MinGW-MSYS / WxWidget 2.8

Stepping into Qt sources in Qt Creator (in Ubuntu Linux)

I'm using Qt Creator in Ubuntu. It's installed from the repositories but as it is now, there is no way to step into the Qt sources when debugging.
How can I enable that?
Since Qt Creator uses gdb, you need to configure gdb. First thing to do is to install Qt debugging symbols:
apt-get install libqt4-dbg
Or, for Qt5:
apt-get install qtbase5-dbg # For the qtbase package
This will install the debugging symbols for Qt libraries. Older releases of Ubuntu had a silly bug that required additional trick to correct those symbol files, but in the current release it works fine.
This will make gdb step inside Qt methods, but it's no fun without sources. So we need sources which can be installed like this, assuming that the source repository is enabled in the APT:
apt-get source qt4-x11
ln -s qt4-x11-4.7.0 qt # a convenience symlink
Or, for Qt5:
apt-get source qtbase-opensource-src
# Make a link as above, if you wish
This will download the sources, unpack them into the current directory and patch them accordingly, no root privileges needed unless the current dir isn't writeable by the current user.
And the last thing is to inform gdb of the sources location, which is done by putting this in the ~/.gdbinit file:
dir ~/vita/qt/src/corelib
dir ~/vita/qt/src/gui
dir ~/vita/qt/src/network
dir ~/vita/qt/src/sql
Add modules and correct paths as needed. The convenience symlink is very useful here, so we don't have to edit this file each time we upgrade to a new Qt version. We only need to download the new sources, patch them and change the symlink.
Note that even we have installed the debugging symbols, we still use the release build of Qt libraries. This means that the code is highly optimized and will sometimes behave very strange when stepping inside Qt binaries. If it is a problem, then it is necessary to build Qt in debug mode, install it separately (say, in /usr/local/qt4-debug) and tell Qt Creator to use that particular installation.
The only way i made it work on Ubuntu is building Qt from sources with configure -debug.
Everything started to work like a charm afterwards.
Qt binary packages for Linux don't contain debug symbols and therefore the debugger doesn't know files or line numbers where to jump to. You need to build Qt yourself with -debug configure option if you want to be able to debug Qt code.
Instructions from Sergey Tachenov instructions would only work if you build your application against the Qt version that you can find from Ubuntu repositories.

Qt on Linux - version conflict?

Trying to move a Qt 4.6.3 project from Windows to Debian Linux (Etch). I've installed Qt by downloading the latest version, then running configure, then make install as root. Yet when I run qmake_qt4 on my project's pri file, here's what I get:
uic: File generated with too old version of Qt Designer
Running uic -v returns 4.2.1. How come? Wasn't make install supposed to put the latest Qt on the system?
By default, Qt installs to /usr/local/Trolltech/Qt-4.6.3 and doesn't add it's bin folder to your PATH variable. Also, it's just named qmake.
Either call /usr/local/Trolltech/Qt-4.6.3/bin/qmake using the complete path or add the /usr/local/Trolltech/Qt-4.6.3/bin/ path to your PATH variable and ensure that it is listed there before any other path that may have a qmake. Best thing to do is to uninstall the the debian qt version if you don't need it elsewhere.

Enabling OpenGL in wxWidgets

I installed the wxWidgets source code, compiled it and am linking the libraries thus obtained with my application code. Now I need to use OpenGL in my wxWidgets application. How do I enable this?
For building on Windows with project files:
Assume $(WXWIDGETSROOT) is the root directory of your wxWidgets installation.
Open the file $(WXWIDGETSROOT)\include\wx\msw\setup.h
Search for the #define for wxUSE_GLCANVAS.
Change its value from 0 to 1.
Recompile the library.
For building on Linux and other ./configure based platforms:
Just use ./configure --with-opengl
(A mashup answer from two partial answers given by others)
If you're using configure to build wxWidgets you just need to add --with-opengl to your command line.
Just to add a little bit... If you're on linux you need to watch the logs when running configure. If it can't find opengl dev packages then it will turn opengl off with one line of warning which is easy to miss.
run it like this to make it more obvious what development libraries you're actually missing (it looks like the --with-opengl is on by default in 3.0.0 and possibly earlier versions of wxwidgets, but it can't hurt to include it I suspect).
./configure --with-opengl > configure.log
Once configure can find all the dev libs you think you're going to use you need to rebuild wxwidgets:
make
sudo make install
I had to install these on linux mint to make wxwidget's configure happy as far as opengl was concerned (and should also work for ubuntu) to get the dev libs I needed.
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
(Assume $(WX_WIDGETS_ROOT) is the root directory of your wxWidgets installation.)
Open the file $(WX_WIDGETS_ROOT)\include\wx\msw\setup.h
Search and find the option wxUSE_GLCANVAS. Change its value from 0 to 1.
Recompile the library.