QtCreator cannot find stddef.h working on linux - qt

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.

Related

Codelite 17.0.0 occurs "process_begin: CreateProcess(NULL, makedir Debug, ...) failed."

I am just learning C++ via Codelite, which was updated on 01/11. After updating to the latest version, 17.0.0, I get the error
process_begin: CreateProcess(NULL, makedir Debug, ...) failed.
mingw32-make[1]: *** [AssignmentOperator.mk:90: Debug/.d] Error 2,
mingw32-make: *** [Makefile:5: All] Error 2
when I run a simple code.
#include <iostream>
int main(){
std::cout<<"Hello"<<std::endl;
return 0;
}
and get nothing in the terminal window.
How can I fix this problem? Thanks a lot.
I guess the probrem occured since the updating of Codelite, but I have no idea how to fix it.
Looks like a an old relic that was not handled properly during upgrade.
This can be fixed in 2 ways:
Update the mkdir command as defined by your compiler setup:
Go to Settings -> build settings and select your compiler from the list
Select the Tools tab
Select the last entry at the bottom mkdir
Replace the content with the mkdir that comes with CodeLite, for example, if you have installed CodeLite under C:\Program Files\CodeLite (the default path), set it to
"C:/Program Files/CodeLite/mkdir.exe" -p
Notice the double quotes around the command itself
Change the makefile generator used
Right click on your project and open the project settings
In the General tab, under the Makefile Generator change the selection from Default -> CodeLite Makefile Generator
I'm using Mac OS 13.1, and codelite 17.0.0, and when I 'clean', build completed successfully. But when I run its show 'make: ***[All] Error 2.
What happened? just new to learn C++
I had the same problem with Codelite 17 in windows.
Solution:
In Settings - Build - Tools under Makedir select the Path of mkdir.exe within in the Codelite folder (surrounded by " -quotes).
Although context help says to leave it empty in order to use the OS' own mkdir, Windows' mkdir is quite different to the mkdir of other *ix-like OS.
Furthermore for me it was necessary to explicitly add -p
There is a hint in Codelite's change dokumentation in the recent monthly build 17.1 that it solves this problem as a bugfix.

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

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.

QPSQL driver not loaded

I know that there are few topics on the Internet about QPSQL driver not loaded problem but none of the solutions have helped me.
Let's start from the beggining. This is what I'm using:
Windows 7 x64
PostgreSQL 9.3
QtCreator 2.4.1
Based on Qt 4.7.4 (32 bit)
First of all I've tried to use tutorial from http://qt-project.org/doc/qt-4.8/sql-driver.html#qpsql . The problem with that solution is that cd %QTDIR% command result is changing my working directory to C:\QtSDK\Desktop\Qt\4.7.4\mingw which has not any src directory but fortunately has got plugins\sqldrivers. Unfortunately there is no folder pqsl. Even if I ignore that problem and skip into next step - qmake "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro it shows me that it cannot find file psql.pro and there is no psql.pro file in my whole Qt directory. I've decided to leave that solution and to find another one.
Somewhere in the Web I've found that I need to write those lines into my .pro file:
INCLUDEPATH += $$quote(C:/Program Files/PostgreSQL/9.3/include)
LIBS += -L$$quote(C:/Program Files/PostgreSQL/9.3/lib)
I've done that. But the driver not loaded problem is still appearing.
What should I do. Am I missing something?
If it helps after running
qDebug() << QSqlDatabase::drivers();
command it displays only ("QSQLITE")
P.S. I hope that my problem is understandable - english is not my native language.

table_editors-moc.ads not found

I'm using gcc (GCC) 4.5.4 20120510 for GNAT GPL 2012 (20120509)
and qtada from qtada-gpl-3.2.0-20120708-3871-qt4.8.2-2.exe installer.
I'm trying to compile example from "..\GNAT\2012\examples\qtada\sql\cached_table", but it say "table_editors-moc.ads not found",
The error came from statement :
with Table_Editors.MOC; pragma Warnings (Off, Table_Editors.MOC);
-- Child package MOC must be included in the executable.
Where can i found the "Child package MOC" that contains "table_editors-moc.ads" and another moc file??
I don't know Qt or QtAda, but a quick search indicates that Qt uses a Meta Object Compiler (MOC) to auto-generate source code from macros. Could it be that your Table_Editor.MOC is supposed to be generated?
I'm surprised that QtAda has installed its examples at \GNAT\2012\examples; judging by the way GNAT is set up on this Mac, I'd have expected \GNAT\2012\share\examples.
However .. I suspect that QtAda's file system layout is complicated enough that you'll need to use a "GNAT Project file" to do the build. I hope there's a .gpr file in the same directory as your example code (if not, I can't help); if so, and assuming it's called cached_table.gpr, then in a command window say
gnatmake -p -P cached_table.gpr
or (following the documentation for QtAda 3.1)
gprbuild -p -P cached_table.gpr

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.

Resources