QT5 attaching project name with every sourcefile name, compiling error - c++

i want to get started with QT. I donwloaded QT5 MINGW compiler with QT creator and i am trying to build the pre attached example named affine the problem is that the QT5 i think embed the project name with each of source file and thus gives error that file not found. some thing similar
:-1: error: ..affinemain.cpp: No such file or directory
while the file name is just
main.cpp
i don't know how to fix it. I searched lot on internet but could not found anything useful.
I even try to compile from command prompt but i am not fimmiliar with command prompt compiling as i am new to QT and previously i am totally developed with IDE in visual studio and eclipse for java so i have no idea about the make file and compiler command line arguments.
could some body please help me to fix this issue and can you tell please why compiler attaching project name with the source file name?
Thanks in advance

I have got the same problem and my solution may help you.
I am working with Qt5.0.1 now, and there are two distributions to work on windows with it: Qt5.0.1-mingw and Qt5.0.1-msvc2010.
I had to use mingw and there was a problem on my setup that "/" is ignored in path's.
So according to Qt Creator, compiler was called to process file mainwindow.cpp and this file was passed to it
g++ /*truncated*/ ..\qt-example\mainwindow.cpp
Below is the full compiler input:
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN -I..\qt-example -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtGui" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtCore" -I"debug" -I"." -I"." -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\mkspecs\win32-g++" -o debug\mainwindow.o ..\qt-example\mainwindow.cpp
And the error produced.
g++.exe: error: ..qt-examplemainwindow.cpp: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.
So, we can see that "\" is ignored by the compiler and file name is merged with directory name.
The solution to that problem goes to the tools that are used - MinGW (Minimalist ports of GCC and Binutils). And also MSYS - a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. In our case - g++.
MSYS is not shipped with Qt5.0.1-mingw and g++ is not using it, but having MSYS available in your PATH environment variable breaks the system.
MSYS is used for git scm, which I have installed, so my path contains links to MSYS that goes bundled with git. So I have next paths in my PATH environment variable.
C:\Program Files (x86)\git\bin;C:\Program Files (x86)\git\cmd
I have not found how MSYS is used by Qt Creator or g++, or where it is linked, but when I have dropped next path from PATH:
C:\Program Files (x86)\git\bin;
and restarted Qt Creator - g++ succeeded on compiling my file, it worked.
The question why/how it influences the Qt Creator/g++ that should not use MSYS utils installed with git is still open.

i can´t comment.
important : delete all the files in the release and debug folder (compiled version) before try the tips of the autor ...

Related

QT5 and Antlr4.8 not Compiling with Cmake and QT Creator

As in the above im trying to compile a QT5 project inside of QT Creator with cmake and want to add the antlr package.
Infos: Qt 5.12.8, Antlr 4.8, Compilers tried: mingw gcc|g++ , msvc 2015,2017
System: Windows / Linux both do not work
For including Antlr 4.8 i use the provided CPP Package to build Antlr from Source
This is the project i am working on.
https://github.com/MrDiver/ArmSimulator/tree/ArmParser/src/asmeditor/AsmEditor
i include antlr4 with the following https://github.com/MrDiver/ArmSimulator/blob/ArmParser/src/asmeditor/AsmEditor/CMakeLists.txt#L14-L21
and normally it works perfectly fine when i compile something with it. But this time when i try to include the header files for antlr i get this error message
FAILED: CMakeFiles/AsmEditor.dir/managers/processormanager.cpp.obj
H:\Programme\QT\Tools\mingw730_64\bin\g++.exe -DANTLR4CPP_STATIC -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I. -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor -IAsmEditor_autogen/include -Iantlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/armparser/assembler -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/armparser/walker -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/codearea -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/managers -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/armparser -isystem H:/Programme/QT/5.12.8/mingw73_64/include -isystem H:/Programme/QT/5.12.8/mingw73_64/include/QtWidgets -isystem H:/Programme/QT/5.12.8/mingw73_64/include/QtGui -isystem H:/Programme/QT/5.12.8/mingw73_64/include/QtANGLE -isystem H:/Programme/QT/5.12.8/mingw73_64/include/QtCore -isystem H:/Programme/QT/5.12.8/mingw73_64/./mkspecs/win32-g++ -O3 -DNDEBUG -std=gnu++11 -MD -MT CMakeFiles/AsmEditor.dir/managers/processormanager.cpp.obj -MF CMakeFiles\AsmEditor.dir\managers\processormanager.cpp.obj.d -o CMakeFiles/AsmEditor.dir/managers/processormanager.cpp.obj -c H:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/managers/processormanager.cpp
In file included from antlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src/antlr4-runtime.h:31:0,
from H:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/managers/processormanager.cpp:2:
antlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src/Lexer.h:116:46: error: invalid declarator before 'newToken'
virtual void emit(std::unique_ptr<Token> newToken);
^~~~~~~~
antlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src/Lexer.h:116:46: error: expected ')' before 'newToken'
antlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src/Lexer.h:123:25: error: expected unqualified-id before ')' token
virtual Token* emit();
^
[30/31 0.6/sec] Building CXX object CMakeFiles/AsmEditor.dir/armparser/assembler/ARMParser.cpp.obj
ninja: build stopped: subcommand failed.
18:59:55: The process "C:\msys64\mingw64\bin\cmake.exe" exited with code 1.
Error while building/deploying project AsmEditor (kit: Desktop Qt 5.12.8 MinGW 64-bit)
When executing step "CMake Build"
File of Interest: https://github.com/MrDiver/ArmSimulator/blob/ArmParser/src/asmeditor/AsmEditor/managers/processormanager.cpp
Seems pretty much like it can't find std::unique_ptr<Token> but i can't change a lot about this, because these are the antlr sources and they actually work.
So i don't really know anymore where to search for the problem. The library itself compiles fine if i choose it as target in the settings.
What i tried:
Compiling the antlr library outside and just linking it in the cmake file.
Changing the Lexer.h file with #include <memory>.
Compiling the QT project without QT Creator (Resulting in a ton more errors because i cant get the linking for QT to work)
Compiling every Antlr related file outside of the project (Works perfectly fine without QT but not really what i need)
Using different compilers and different Systems.
Searching for a problem with moc but it doesn't seem to influence it. But i doubt i looked hard enough on moc for this.
And im quite new to QT so i don't know everything what the Qt Creator does behind the scenes. It seems like too much if i can't compile it with plain cmake out of the box.
Thanks for the help in advance.
The problem is that Antlr has methods like "emit" that conflict with the Qt reserved word "emit". The solution is to disable the flag "no_keywords" (in qmake add CONFIG += no_keywords, and in CMake add add_definitions(-DQT_NO_KEYWORDS)) as indicated by the docs. Then you must make the following conversions:
emit to Q_EMIT
slot to Q_SLOT
slots to Q_SLOTS
signal to Q_SIGNAL
signals to Q_SIGNALS

--with-sysroot is not honored during a compile on OS X?

I have a C++ project. I am testing a cross-compile with Autotools on OS X for iOS. I configure with:
$ echo $IOS_SYSROOT
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk
$ CXXFLAGS="-DNDEBUG -g2 -O3 -arch arm64" ./configure --with-sysroot="$IOS_SYSROOT" --build=`config.guess` --host=aarch64-ios
When make'ing it results in (line breaks added for clarity):
libtool: compile: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-DHAVE_CONFIG_H -I. ... -DNDEBUG -g2 -O3 -arch arm64 -MT adhoc.lo -MD -MP -MF .deps/adhoc.Tpo -c adhoc.cpp -o adhoc.o
In file included from adhoc.cpp:2:
In file included from /usr/include/c++/4.2.1/iosfwd:44:
In file included from /usr/include/c++/4.2.1/bits/c++config.h:41:
In file included from /usr/include/c++/4.2.1/bits/os_defines.h:61:
In file included from /usr/include/unistd.h:71:
In file included from /usr/include/_types.h:27:
In file included from /usr/include/sys/_types.h:32:
/usr/include/sys/cdefs.h:658:2: error: Unsupported architecture
#error Unsupported architecture
...
Notice the wrong header files are being used. The build system's headers are used rather than the iPhone headers. I'm fairly certain --with-sysroot is not being honored. Searching for the keywords seems to indicate its a widespread problem with Autoconf (based on all the bug reports trying to use the feature).
Manually adding CXXFLAGS="-sysroot=$IOS_SYSROOT -arch arm64 ... seems to fix the issue. This seems to be the same problem (or nearly the same problem) detailed at Bug 79885: --with-build-sysroot= does not get honored throughout the build.
There does not seem to be a AC_SYSROOT (or similar) to copy --with-sysroot into AM_CXXFLAGS. Searching the Autoconf site for the keywords is not returning useful hits: "--with-sysroot" site:https://www.gnu.org/software/autoconf/manual.
How are we supposed to handle Autoconf's --with-sysroot option? What is the practice packagers are supposed to follow?
Here are the Autoconf prject files: cryptopp-autotools. There are two files of interest, and they are configure.ac and Makefile.am. I'm not sure what applies to this problem at the moment.
Here's the message where Autoconf tells users to use it:
$ ./configure --help | grep sysroot
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
I'd prefer to supress the message if Autoconf cannot wire-in --with-sysroot properly. Otherwise, users are going to be filling bug reports against us.

I can't even get the wxWidgets samples to compile using a

So I have been trying to get even just the damn samples for wxWidgets to compile with Mingw and I did like so mingw32-make -f makefile.gcc and I get the following error.
I do not have MSYS installed, and I have the latest version of Mingw
g++ -c -o gcc_mswud\minimal_minimal.o -g -O0 -mthreads -DHAVE_W32API_H -D__WXMS
W__ -D_UNICODE -I.\..\..\lib\gcc_lib\mswud -I.\..\..\include -W -Wall -I
. -I.\..\..\samples -DNOPCH -Wno-ctor-dtor-privacy -MTgcc_mswud\minimal_min
imal.o -MFgcc_mswud\minimal_minimal.o.d -MD -MP minimal.cpp
In file included from .\..\..\include/wx/defs.h:26:0,
from .\..\..\include/wx/wxprec.h:13,
from minimal.cpp:21:
.\..\..\include/wx/platform.h:256:22: fatal error: wx/setup.h: No such file or d
irectory
compilation terminated.
mingw32-make: *** [gcc_mswud\minimal_minimal.o] Error 1'
Any advice would be greatly appreciated
Also how exactly should I be compiling my own projects involving wxWidgets, what do I need to link against wxWidgets in mingw?
wx/setup.h is a file that is created during the compilation process; this file will be different for each different build type (Unicode, ANSI, Debug or Release, etc.). Most likely you compiled wxWidgets for one build type and are trying to compile the samples for a different build type.
As for the include / linker paths I have found the settings below to the bare minimum required to use wxWidgets in your own projects on Windows:
Include Paths
$(WXWIN)\include
$(WXWIN)\lib\vc_lib\mswud (u = Unicode and d=debug, this changes depending on what build type you want)
Pre-processor Definitions
WIN32
_DEBUG (only if you want to build with debugging info)
_WINDOWS
Character Set
"Use Unicode Character Set" (very important for Unicode builds; otherwise you will get compiler errors)
Additional Library Directories
$(WXWIN)\lib\vc_lib
Additional Dependencies
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
odbc32.lib
wxmsw28ud_core.lib
wxbase28ud.lib
wxexpatd.lib
wxjpegd.lib
wxpngd.lib
wxregexud.lib
wxtiffd.lib
wxzlibd.lib
wxmsw28ud_adv.lib
wxmsw28ud_aui.lib
wxmsw28ud_html.lib
wxWidgets libraries are post-fixed with "u" for Unicode and "d" for debug, you need to choose the libraries that match the build type you want. $(WXWIN) is the directory where you built wxWidgets (wxPack will create this environment variable for you to use).

Help on build using g++ on Windows

There is a small project C++ (it has win32 code) that I need to build. It already has its Makefile. I was told to use MinGW. I have never used it before. I downloaded and installed the latest MinGW installer.
Then, I opened the MinGW shell and did make. The exe file was created. But when I try to run it I get libgcc_s_dw2-1.dll is missing! Why do I get this error? Shouldn't the exe be self-contained and run anywhere?
UPDATE
Here's more information, from the Makefile:
CC = g++
CCOPTIONS=-DWINDOWS -DFORCEINLINE -DMINGW -DSRTP_SUPPORT -D__EXPORT= -D_WIN32_WINNT=0x0501 -DNOMVS
setup.exe: setup.o common.o
$(CC) -ggdb -g -O0 -o $# setup.o common.o -mno-cygwin -mwindows -lwsock32 -lws2_32 -lwinmm -lgdi32 -lcomctl32 -lmapi32 -lVfw32
Whether or not the exe should be self-contained depends on how you built it. We need to see the commands that were executed, or post the makefile. But that DLL does not seem to be part of the current version of MinGW. Also, please clarify if you are actually doing this under cygwin, or if you added the tag by mistake.
Edit: A bit of googling seems like it has to do with the horrible "official" MinGW installation. Remove it, and download the Twilight Dragon build from http://tdm-gcc.tdragon.net and then rebuild completely. The "official" build is cr*p anyway - I don't know why anyone uses it.
If what you want to do is a stand alone application with MinGW, you should add -static to the linking options.
On a side note, if you're making a Win32 application, add the -mwindows option to the C++ compiler so it doesn't open a console together with your main window.

Missing Python.h while trying to compile a C extension module

I'm following this tutorial on how to extend Python with C\C++ code.
The section named "Building the extension module with GCC for Microsoft Windows" fails for me with the following error:
fatal error: Python.h: No such file or directory
The section named "Building the extension module using Microsoft Visual C++" also fails with a similar error:
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
What should I do to solve this?
For Linux, Ubuntu users to resolve the issue of missing Python.h while compiling, simply run the following command in your terminal to install the development package of python:
In Terminal: sudo apt-get install python-dev
Good luck
Do you have the python dev files so that you can find Python.h?
Do you have the location of Python.h specified to your compiler? with gcc this is usually done through a -I path to include.
Figuring out which of those is failing will solve your problem.
from the article you linked:
gcc -c hellomodule.c -I/PythonXY/include
gcc -shared hellomodule.o -L/PythonXY/libs -lpythonXY -o hello.dll
They assumed you installed python in the default location c:\pythonXY(Where X is the major version number and Y is the minor version number).(in your case Python26) If you put python somewhere else replace /PythonXY with where ever you installed it.
The Python official documentation has already made it clear. Check it out here
The header files are typically installed with Python. On Unix, these are located in the directories prefix/include/pythonversion/ and exec_prefix/include/pythonversion/, where prefix and exec_prefix are defined by the corresponding parameters to Python’s configure script and version is '%d.%d' % sys.version_info[:2]. On Windows, the headers are installed in prefix/include, where prefix is the installation directory specified to the installer.
To include the headers, place both directories (if different) on your compiler’s search path for includes. Do not place the parent directories on the search path and then use #include ; this will break on multi-platform builds since the platform independent headers under prefix include the platform specific headers from exec_prefix.
And they have provided a convenient way to get the correct cflags that we should pass to compiler. here
So for example, here is what I got after running the command
root#36fd2072c90a:/# /usr/bin/python3-config --cflags
-I/usr/include/python3.5m -I/usr/include/python3.5m -Wno-unused-result -Wsign-compare -g -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
Pass those flags to the compiler, and it will work.