Program installed with CMake /CPack / NSIS64 cannot find Qt plugins - qt

I am trying to install a C++/Qt/Qml program with CMake. I tried the IFW generator, but I'd rather stick to NSIS64.
Setup install file is correctly generated, and program is correctly installed. But my installed Qt program crashes right away, because
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
It is an easy to solve problem when running the program from the command line: we just need to set QT_QPA_PLATFORM_PLUGIN_PATH to the current directory (I installed/copied qwindows.dll there).
It is strange that the .exe does not look into the current program directory for Qt plugins. Anyways, a way to solve my problem would be: how to set an environment variable in a shortcut .lnk (created by NSIS)?
I have tried a bunch of things with NSIS (added in NSIS.template.in):
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\#CPACK_NSIS_DISPLAY_NAME#.lnk" "QT_QPA_PLATFORM_PLUGING_PATH=$INSTDIR\bin $INSTDIR\bin\#CPACK_NSIS_DISPLAY_NAME#.exe"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\#CPACK_NSIS_DISPLAY_NAME#_cmd.lnk" \
"C:\Windows\System32\cmd.exe" "/c SET QT_QPA_PLATFORM_PLUGING_PATH=$INSTDIR\bin && start $INSTDIR\bin\#CPACK_NSIS_DISPLAY_NAME#.exe"
but this does not compile.
Maybe there is a different way to achieve this. Even if that would work, I would like to avoid setting QT_QPA_PLATFORM_PLUGING_PATH globally during the install, if possible, and restrain it to the program launch.
NOTE: documentation says:
CreateShortcut "$SMPROGRAMS\My Company\My Program.lnk" "$INSTDIR\My Program.exe"
"some command line parameters" "$INSTDIR\My Program.exe" 2 SW_SHOWNORMAL
ALT|CONTROL|SHIFT|F5 "a description"
but I am not too sure about how to use this in my case.

Related

QtCreator cannot find stddef.h working on linux

I just freshly installed Qt Creator 4.1.0
Based on Qt 5.7.0 (GCC 4.9.1 20140922 (Red Hat 4.9.1-10), 64 bit)
This error drives me crazy after I fixed all kit errors, actually I spent some time on google looking for proper compiler. This could be something with compiler version I think:
/usr/include/c++/5.3.1/cstddef:45: error: stddef.h: No such file or
directory
I saw solutions for windows everywhere but could not find for linux, does anyone has experience how to fix it?
Screenshots
rpm -qa | grep devel | sort
expat-devel-2.1.0-10.fc22.x86_64
fontconfig-devel-2.11.94-4.fc22.x86_64
freetype-devel-2.5.5-2.fc22.x86_64
gdbm-devel-1.11-4.fc22.x86_64
glibc-devel-2.21-13.fc22.i686
glibc-devel-2.21-13.fc22.x86_64
java-1.8.0-openjdk-devel-1.8.0.65-3.b17.fc22.x86_64
kernel-debug-devel-4.2.5-201.fc22.x86_64
kernel-debug-devel-4.2.6-200.fc22.x86_64
kernel-devel-4.2.6-200.fc22.x86_64
libdb-devel-5.3.28-12.fc22.x86_64
libdrm-devel-2.4.61-3.fc22.x86_64
libICE-devel-1.0.9-2.fc22.x86_64
libpng-devel-1.6.16-3.fc22.x86_64
libSM-devel-1.2.2-2.fc22.x86_64
libstdc++-devel-5.3.1-6.fc22.i686
libstdc++-devel-5.3.1-6.fc22.x86_64
libXau-devel-1.0.8-4.fc22.x86_64
libxcb-devel-1.11-8.fc22.x86_64
libXcursor-devel-1.1.14-4.fc22.x86_64
libXdamage-devel-1.1.4-6.fc22.x86_64
libXext-devel-1.3.3-2.fc22.x86_64
libXfixes-devel-5.0.1-4.fc22.x86_64
libXft-devel-2.3.2-2.fc22.x86_64
libXi-devel-1.7.4-2.fc22.x86_64
libXinerama-devel-1.1.3-4.fc22.x86_64
libXrandr-devel-1.4.2-2.fc22.x86_64
libXrender-devel-0.9.9-1.fc22.x86_64
libxshmfence-devel-1.2-1.fc22.x86_64
libXt-devel-1.1.4-10.fc22.x86_64
libXv-devel-1.0.10-2.fc22.x86_64
libXxf86vm-devel-1.1.4-1.fc22.x86_64
libX11-devel-1.6.3-1.fc22.x86_64
mesa-libGL-devel-10.6.9-1.20151008.fc22.x86_64
mesa-libGLU-devel-9.0.0-7.fc22.x86_64
perl-devel-5.20.3-328.fc22.x86_64
python3-devel-3.4.2-6.fc22.x86_64
qt-devel-4.8.7-4.fc22.x86_64
systemtap-devel-2.9-1.fc22.x86_64
systemtap-sdt-devel-2.9-1.fc22.x86_64
xorg-x11-proto-devel-7.7-12.fc21.noarch
zlib-devel-1.2.8-7.fc22.x86_64
I had this problem as well, and for me I had to disable ClangCodeModel plugin. To do this, I went to Help->About Plugins...->Uncheck ClangCodeModel (under C++ category). After restarting QT Creator, everything was working fine. I found this solution on QT Forums
If the compiler works from a terminal, it should work from QtCreator. So first make it work from the terminal.
From a terminal, create a file main.cpp with:
#include <cstddef>
int main()
{
return 0;
}
Then type the command:
gcc -H main.cpp -o main
If the compilation works, there must be a problem in your kit definition in QtCreator. Possibly make sure the folder where stddef.h is in the include file list of your kit. But you should not need to do that. Temporarily, you can add the include path to your project (see How to add include path in Qt Creator?) to check this is really the problem. Then you'll need to find a way to fix the kit for good.
If the compilation does not work, fix your environment (possibly using sashoalm's commented link). QtCreator is just and IDE, if you run it with a broken compiler it won't fix it for you. The compilation output will show where files (cstddef and then stddef.h) are picked from (-H option). Try cpp -v to see where included files are searched.
On my machine, compilation output gives me:
. /usr/include/c++/4.8/cstddef ..
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h ...
/usr/include/x86_64-linux-gnu/c++/4.8/bits/os_defines.h ....
/usr/include/features.h .....
/usr/include/x86_64-linux-gnu/sys/cdefs.h ......
/usr/include/x86_64-linux-gnu/bits/wordsize.h .....
/usr/include/x86_64-linux-gnu/gnu/stubs.h ......
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h ...
/usr/include/x86_64-linux-gnu/c++/4.8/bits/cpu_defines.h ..
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h Multiple include
guards may be useful for: /usr/include/c++/4.8/cstddef
/usr/include/x86_64-linux-gnu/bits/wordsize.h
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h
/usr/include/x86_64-linux-gnu/gnu/stubs.h
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h
see stddef.h was found in /usr/lib/gcc/x86_64-linux-gnu/4.8/include
And cpp -v gives:
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
Note: If you created the kit manually, I would recommend that you uninstall QtCreator. Make gcc work from a terminal and then reinstall QtCreator. This one should create the kits automatically and they should then work.
This is a common problem with QT I experience a lot with all versions of Fedora, the problem is that the path to "/usr/lib64/qt5/bin" is missing from the user environment.
To check for the path at a command line what the path is present set to enter the following: echo $PATH
You should see the "/usr/lib64/qt5/bin" listed somewhere in the response if it is not present then edit the .bashrc file in the root of your home directory as follows: -
Add QT5 build environment
if! [[ "$PATH" =~ "/usr/lib64/qt5/bin" ]]
then
PATH="/usr/lib64/qt5/bin:$PATH"
fi
Just above the "export PATH" statement
You will need to log off and on again for the changes to take effect.

WinPython with PyQt5

I'm trying to get PyQt5 working with WinPython. PyQt5 comes with a readme file for installation, and I have unsuccessfully tried a few combinations of what I thought the first part of the readme tells me to do.
I have:
Windows 7 Home Premium 64-bit
WinPython-64bit-2.7.9.1
Qt 5.4
PyQt-gpl-5.4
PyQt-gpl-5.4 is in the folder (only partially sure that this is where I should have put it)
C:\WinPython-64bit-2.7.9.1\python-2.7.9.amd64\Lib\site-packages\PyQt-gpl-5.4
My current attempt at getting everything working is: I'm trying to run the configure.py file in PyQt-gpl-5.4, but when I do so I consistently get the following error:
Error: PyQt5 requires Qt v5.0 or later. You seem to be using v4.8.6.
Make sure the correct version of qmake is on your PATH.
What I think is the required version of qmake being referred to is in the folder
C:\Qt\5.4\mingw491_32\bin
However, I have no idea how to fix the error by adding the qmake in this folder to PATH. My most recent attempt was to add the folder using Spyder's Tools->PYTHONPATH manager, but this made no difference. I also tried adding it using sys.path.append('C:\Qt\5.4\mingw491_32\bin'), but this didn't work either. I have since removed the folder name from both of these locations.
How do I get PyQt5 working with WinPython-64bit-2.7.9.1, or I think equivalently, how to I get the configure.py file in the PyQt-gpl-5.4 folder to run?
Thanks.
You definitely don't want the source code (i.e. PyQt-gpl-5.4) in the site-packages folder, because that's where the compiled modules will end up. Instead, it should just go in a temporary folder whilst you compile it.
When you run configure.py, you must take care to use the executable for the specific python that you are targeting. I do not know anything about WinPython, but for a normal python installation this means doing something like this:
C:\Python34\python configure.py
As a first step, before attempting to actually compile anything, it would be advisable to take at look at all the configuration options that are available, like this:
C:\Python34\python configure.py --help
(There's also the Installing PyQt5 section in the PyQt Docs).
This will tell you, for instance, that the simplest way to specify the Qt installation you are targeting would be something like this:
C:\Python34\python configure.py --qmake C:\Qt\5.4\mingw491_32\bin\qmake
EDIT:
Sorry, that last part is wrong: the --qmake option isn't available on Windows, so you have to add the directory containing the qmake executable to your PATH. This can be done with the following command:
set PATH=%PATH%;C:\Qt\5.4\mingw491_32\bin

how to recompile Qt statically?

I searched whole internet for this problem.
I want compile Qt statically to run my program without any DLL.
I read several instructions in the internet.that they all told me sth like this:
cd %qtdir%
configure -static -[other option]
make sub-src
but when I use make in cmd,I get this error :
'make' is not recognized as an internal or external command,operable program or batch file.
and I tried nmake and mingw32-make too. I don't know in what qt directory I must do this.
I wanna a very simple instruction...
In Linux the default compiler is g++, which provices "make". If you are on Windows, and you want to use "make", you need to install the mingw distribution[1].
As pointed out by Dídac Pérez, if you want to use the MSVC compiler[2], you should use the visual studio command prompt, that sets all the environmental variables for you by calling a bat file.
Therefore the instructions would be:
open a visual studio command prompt and navigate to your Qt source
directory
type "make confclean" to remove traces from a previous compilation
setup a static configuration, by passing the adequate flag (e.g.:
"configure -static ")
type "nmake" to call the visual studio compiler
get a cup of coffee and wait a couple of hours (depending on your
processor(s) :-))
[1]http://www.mingw.org/
[2]http://www.visualstudio.com/en-us/downloads#d-2010-express

netbeans, Qt, & Qmake "command not found"

All,
I am (trying to) using Netbeans to build a simple Qt app (from a tutorial) and I cannot build it because I get this error:
/C/Qt/2010.02.1/qt/qmake/qmake.exe VPATH=. -spec win32-g++ -o qttmp-Debug.mk nbproject/qt-Debug.pro
make[1]:/C/Qt/2010.02.1/qt/qmake/qmake.exe: Command not found
when the file is exactly there, and I can open a terminal and execute it.
Note in the error message: "/C/Qt..." The actual path is C:/Qt...
I have used the tools/options/c++ dialog to browse to the file and select it, and it is specified as C:\Qt... just like all the other tools. What is corrupting the C: and making it /C/ ?
Now, if I remove the path to qmake, and have it use the PATH environment variable, it finds it, but then it fails due to 'multiple targets'...
Obviously, pilot error, but where? I have seen several posts on this, and they all say to make sure it is in the path, and it is, so now what? (I can open a terminal and type 'qmake' and I get the 'Usage: qmake..." so I know it is visible.
Windows 7, Netbeans 7.0, MinGW (I also have cygwin installed...).
Any and all help greatly appreciated.
:bp:
Addenda: I changed the path to my 'make' to use the MinGW one rather than the cygqin one, and now it can find qmake, but I get other errors: 'Could not find mkspecs for your QMAKESPEC(win32-g++) after trying:...
Any additional thoughts?
QMake requires more than just a path to work correctly. On my Windows box, there is a menu option for 'Qt Command Prompt' under the 'Qt SDK 2010.05' group in the Start Menu. Running it produces the following:
Setting up a MinGW/Qt only environment...
-- QTDIR set to C:\Qt\2010.05\qt
-- PATH set to C:\Qt\2010.05\qt\bin
-- Adding C:\Qt\2010.05\bin to PATH
-- Adding C:\WINDOWS\System32 to PATH
-- QMAKESPEC set to win32-g++
You will want to make sure the environment you launch qmake in has all of those set.
The most probable reason you are see '/C/...' is because you are causing a mingw shell to run when you execute your build.

Installing Qt SDK, cannot link to the C++ libraries

So I have installed the QtSDK on my Windows 7 64 bit machine. However, it seems like when I try to run a simple program like hello world such as:
#include <iostream>
int main(....) {
std::cout << "Hello World\n";
}
My program first gets the error:
CreateProcess: No Such file or directory.
So what I did was I went to this link here:
http://wiki.codeblocks.org/index.php?title=Installing_MinGW_with_Vista
And I first tried to add the directory to the
PATH: C:\MinGW\libexec\gcc\mingw32\MinGW-Version
(my directory is slightly different but follows same idea)
where MinGW-Version is the Version of MinGW you are using
So now that got rid of that error but now I get the error:
iostream: No such file or directory
So now I add the path where the iostream library is and that fixes that error but then I get all these other errors where it can't find other standard C++ libraries such as stddef.h or stdio.h etc. So it seems as if the C++ libraries cannot be linked to. I have tried various other things such as including C:\MinGW\bin in my path and have tried uninstalling and reinstalling Qt. Also I have checked that Qt is using the right gcc compiler by going to Tools->Options->Toolchains in Qt Creator.
It seems that the linking to C++ libraries is not correct for some reason. Could anyone help me or guide me as to why this may be happening and how to fix this?
I'm not sure why it's not working, so I'll just tell you how my environment is set up. I don't think you need to add any library paths to the system path. You should only need to add C:\MinGW\bin.
So get rid of everything except for that. Also, are you setting this through cmd or control panel? If doing it in the control panel, make sure you are putting it in the "Path" variable not "PATH" -> the former is in the lower box. I've had problems before using "PATH" in the upper box - not sure what the difference is to be honest.
The QtSDK installation usually install the mingw compiler for you in ...\QtSDK\mingw. The libraries and dlls in ...\QtSDK\Desktop\Qt\4.7.3\mingw were compiled with this compiler. The mingw compiler you installed to c:\MinGW may be a different version than that. If you want to use this compiler you would have to recompile the Qt libraries.
C++ librairies in Qt.
Go to this URL http://doc.qt.digia.com/qtcreator-2.4/creator-overview.html for how to.
It seems (I did not try it, yet) that other librairies can be easily linked to a Qt Project.
This could solve the problem.
Pythagooric

Resources