I'm trying to use ChangeWindowAttributes() function in Qt Creator project on Mac OS X.
But I can't build the project.
What I've tried:
#include <MacWindows.h>
Result (compiler): File not found
#include <Carbon/Carbon.h>
// Or the same:
#include </Developer/Headers/FlatCarbon/MacWindows.h>
Result (compiler): ChangeWindowAttributes was not declared in this scope
#include <Carbon/Carbon.h>
extern OSStatus ChangeWindowAttributes (
WindowRef window,
WindowAttributes setTheseAttributes,
WindowAttributes clearTheseAttributes
);
// And in *.pro file:
LIBS += -framework Carbon
Result (linker): Undefined Symbols ChangeWindowAttributes( ...
Where am I wrong?
According Google it seems that everybody already knows how to include it, so there are no guides anywhere. Maybe someone here also has a link to the guide or something?
By default, QT Creator build your project in your Mac's CPU architecture. The libraries themselves come in x86 and x86_64 universal binaries. This is if you are using the prebuild SDK from Nokia.
If you are running 64-bit capable OS/Mac combination, like 10.6 on a new Intel Mac, it will build it in x86_64. Carbon calls are still available to your code but only those marked as 64-bit compatible one. Open MacWindows.h and find ChangeWindowAttributes. You will see in the comment:
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: not available
If you have to call this (and other 32-bit only) function, you'll have to force Creator to build it in 32-bit (x86). Add these lines to your .pro file:
CONFIG -= x86_64
CONFIG += x86
Clean all and rebuild.
Related
I want to test out QT WebAssembly for my scientific program.
Therefore, I installed emscripten.
$em++ --version
returns
emcc (Emscripten gcc/clang-like replacement) 1.38.30 (commit a5082b232617c762cb65832429f896c838df2483)...
Then I installed Qt using the Qt WebInstaller.
In my installation directory I have a wasm_32 folder which contains bin and qmake:
$ ~/Qt_web/5.13.2/wasm_32/bin/qmake --version
return
QMake version 3.1
Using Qt version 5.13.2 in /home/myName/Qt_web/5.13.2/wasm_32/lib
However, when I start Qt creator, click on Projects I see a Kit called: Qt 5.13.2 WebAssembly but I cannot select it (it is grayed out).
When I click on manage Kits I saw that there is no C and C++ compiler selected for Qt 5.13.2.WebAssembly.
I also get an warning when I change to Qt Versions. The warning says:
ABI detection failed: Make sure to use a matching compiler when building. No qmlscene installed.
This is a list of all compilers which are selectable:
Question:
I do not really understand what emscripten has to do with all that. Is emscripten a compiler? If yes should it have been auto-selected by the Qt 5.13.2 WebAssembly kit?
How does a proper Qt WebAssembly kit look like?
If I select gcc as my compiler I get an error saying:
/home/myName/Qt_web/5.13.2/wasm_32/plugins/platforms/libqwasm.a:-1: error: error adding symbols: File format not recognized
EDIT:
When I open the qt maintenance tool and look at the installed packages I get the following:
EDIT2:
After changing to Qt Creator 4.11.0-beta2 (4.10.83) I was able to follow parts of this description. I was able to select the Plugin, but I still can not change the Device type.
Maybe it has to do with this error that I get now:
EDIT3:
seems as if my emscripten compiler has some problems.
Is the compiler located in:
emscripten/emsdk/clang/e1.38.30_64bit/clang++
emscripten/emsdk/clang/e1.38.30_64bit/clang
One thing I noticed is that If I use add in QtCreator >> Kits >> Compilers and I select Add >> WebAssembly >> C It generates a new entry in Manual >> C++ >> Emscripten Compiler and not in Manual >> C >> Emscripten Compiler. Is this a problem?
EDIT
This is how my Compilers page looks like:
You need to copy the .emscripten file from emsdk directory to your home (/home/myUsername).
You need to fix the paths in the file manually (See example below).
Notice that .emscripten file , at least in the version (1.39.8) i am using, is a python script (maybe a bug?)
example file before edit:
import os
emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\', '/')
NODE_JS = emsdk_path + '/node/12.18.1_64bit/bin/node'
LLVM_ROOT = emsdk_path + '/upstream/bin'
BINARYEN_ROOT = emsdk_path + '/upstream'
EMSCRIPTEN_ROOT = emsdk_path + '/upstream/emscripten'
TEMP_DIR = emsdk_path + '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
after edit:
import os
emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\', '/')
NODE_JS = '/home/myUsername/node/12.18.1_64bit/bin/node'
LLVM_ROOT = '/home/myUsername/upstream/bin'
BINARYEN_ROOT = '/home/myUsername/upstream'
EMSCRIPTEN_ROOT = '/home/myUsername/upstream/emscripten'
TEMP_DIR = '/home/myUsername/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
When above steps are completed qt creator was able to detect the Emscripten Compiler with no errors.
Have you try in the kits tab to set your compiler with this values?
Compiler:
C compiler x86 64 e1.38.27_bit
C++ compiler x86 64 e1.38.27_bit
Qt version:
path to you qmake built with webassembly, for example webassembly binaries or your custom binaries.
Qt mkspec:
wasm-emscripten
Hope this information helps, if you face any other problem let me know.
Is there a way to compile with MingW with CodeBlocks in Windows so they can be used in Ubuntu or Centos distros?
I've tried compiling with GNU GCC option then got the output file with .o extensions under obj/Release/ folder.
When I run I get this error under my Vagrant Ubuntu machine:
-bash: ./main.o: cannot execute binary file
How can I compile it so it runs on my Linux machines?
The technical term for what you're trying to accomplish is cross-compilation. For that, you need to build a specific cross-compiler using GCC sources. If you still want to keep MinGW, there is a page explaining the steps needed to create a ARM cross-compiler : http://www.mingw.org/wiki/HostedCrossCompilerHOWTO. (you'll have to modify the target)
List of targets supported by GCC :
armv5te-android-gcc armv5te-linux-rvct armv5te-linux-gcc
armv5te-none-rvct
armv6-darwin-gcc armv6-linux-rvct armv6-linux-gcc
armv6-none-rvct
armv7-android-gcc armv7-darwin-gcc armv7-linux-rvct
armv7-linux-gcc armv7-none-rvct
mips32-linux-gcc
ppc32-darwin8-gcc ppc32-darwin9-gcc ppc32-linux-gcc
ppc64-darwin8-gcc ppc64-darwin9-gcc ppc64-linux-gcc
sparc-solaris-gcc
x86-android-gcc x86-darwin8-gcc x86-darwin8-icc
x86-darwin9-gcc x86-darwin9-icc x86-darwin10-gcc
x86-darwin11-gcc x86-darwin12-gcc x86-linux-gcc
x86-linux-icc x86-os2-gcc x86-solaris-gcc
x86-win32-gcc x86-win32-vs7 x86-win32-vs8
x86-win32-vs9
x86_64-darwin9-gcc x86_64-darwin10-gcc x86_64-darwin11-gcc
x86_64-darwin12-gcc x86_64-linux-gcc x86_64-linux-icc
x86_64-solaris-gcc x86_64-win64-gcc x86_64-win64-vs8
x86_64-win64-vs9
universal-darwin8-gcc universal-darwin9-gcc universal-darwin10-gcc
universal-darwin11-gcc universal-darwin12-gcc
generic-gnu
There is only one big caveat : since Windows is not POSIX compliant, I don't think you can use signals or pthreads.
Finally, brace yourself because it's a tedious task to build a cx-compiler (lots of obscure bugs). That's why profesionnal devs pays $$$ for "plug'n'play" solutions.
EDIT : this MXE project can be useful to you
I just installed Mac OS X 10.8.3 and Qt Creator 3, XCode, and XCode command line tools. I'm trying to compile a project that works on another computer but each time I go to "build all" I get error: 'QtGui/QAction' file not found
in #include <QtGui/QAction>
I tried adding the second and third line in the .pro file but it didn't help
QT += core gui opengl
CONFIG += qt
QT += gui
TARGET = BasicOpenGL
TEMPLATE = app
UPDATE: I also tried this .pro file and it didn't work
QT += core gui opengl
QT += widgets
TARGET = BasicOpenGL
TEMPLATE = app
I should say this is my first time attempting development on mac.
Compile Output from Qt
Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/john/Qt/5.2.0/clang_64/lib -o mainwindow.o ../Framework/mainwindow.cpp
In file included from ../Framework/mainwindow.cpp:2:
../Framework/ui_mainwindow.h:14:10: fatal error: 'QtGui/QAction' file not found
#include <QtGui/QAction>
^
1 error generated.
make: *** [mainwindow.o] Error 1
15:51:32: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project BasicOpenGL (kit: Desktop Qt 5.2.0 clang 64bit)
When executing step 'Make'
UPDATE: I got it to work but with all the screwing around I'm not exactly sure what did it. I started with a fresh mac image, installed system updates, installed xcode, installed xcode command line tools, installed QT Creator 3.0, installed QT libraries 4.8.1, setup the compilers in QT Creator.
Try doing a make clean followed by a make. I had this exact problem on a Windows 7 system, and this is what worked for me.
In Qt5, QAction header is in QtWidgets include sub-directory, not in QtGui (that's true for Qt4). Though you don't actually need to specify include sub-directories since qmake will handle that for you. You just need to add QT += widgets to your .pro file.
Set the version to Qt5, change all #include<QtQui/*>s into #include<QtWidgets/*>.
And add QT += widgets in your .pro file.
Rebuild the project, when you get the error again, tap into the error message, and change the #include<QtQui/*>s into #include<QtWidgets/*> too.
Some answers here say that you have to change include from <QtGui/QAction> to <QtWidgets/QAction>.
It was the case when you compile under QT-5. But after QT-6 was released you have to do the opposite in QT-6 application.
Now you have to change <QtWidgets/QAction> to <QtGui/QAction>, because now QAction is located in QtGui folder in QT-6.
Although my answer is not related to your very old question, as you had QT-4 problem, still your question pops up first in Google hence I'm posting my answer for those StackOverflow visitors who have same problem but with compiling QT-5 project under QT-6, as I did.
I'm trying to configue QtCreator with no success. I want to open an existing project. When I try to compile and run it, I get only empty black console. It looks like it compiles fine but no output.
I've installed this 32bit version:
Qt 5.2.0 for Windows 32-bit (MinGW 4.8, OpenGL, 689 MB) (Info)
When I start a new project, QtCreator wants me to run cmake. When It's done, it works fine. I can also build HelloWorld with "g++ main.cpp"
Can anyone tell me what should I do step by step? I ran out of strength. I don't know why it doesn't work.
I think it is not very important, but I'm using Win7 64bit. First, I tried to install 64bit QtCreator:
Qt 5.2.0 for Windows 64-bit (VS 2012, OpenGL, 589 MB) (Info)
But I had some problems with compilers. It looked like I didn't have them installed. I also tried an online installer and now this 32bit version. Always same result.
EDIT:
I found out something. This works:
ComputerGraphics.pro
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
INCLUDEPATH += C:/Users/user/Desktop/projekty/PocitacovaGrafika2/opencv/include
LIBS += -LC:\\Users\user\\Desktop\\projekty\\PocitacovaGrafika2\\opencv\\bin \
libopencv_core246d \
libopencv_highgui246d \
libopencv_imgproc246d \
SOURCES += main.cpp \
and main.cpp
#include <iostream>
int main(){
std::cout << "Hello";
return 0;
}
This even doesn't print Hello (.pro is the same as previously):
#include <iostream>
int main(){
std::cout << "Hello";
IplImage* img = cvLoad("Desert.jpg",1);
cvShowImage("img",img);
cvWaitKey(0);
return 0;
}
In debug, it complains:
The gdb process terminated unexpectedly (code 0)
During startup program exited with code 0xc0000135.
My solution:
1)
I've gone through my own tutorial on how to compile opencv for qt-creator with cmake here:
How to link opencv in QtCreator and use Qt library
(but using the latest opencv 2.4.8)
2)
I created a folder opencv on desktop.
I went into newly created opencv_bin/install and copied a folder include into the opencv on the desktop.
I continued into directory: install/x64/mingw and copied both bin and lib into opencv on the desktop.
3)
I moved the desktop/opencv directory into a working directory of my project.
i.e cut: desktop/opencv; paste: somepath/myQtProject/
4)
My .pro contains a reference like this:
INCLUDEPATH += C:/Users/user/Desktop/projekty/PocitacovaGrafika2/opencv/include
LIBS += -LC:\\Users\\user\\Desktop\\projekty\\PocitacovaGrafika2\\opencv\\bin \
libopencv_core248d \
libopencv_highgui248d \
libopencv_imgproc248d \
And in the main.cpp just #include "opencv2/opencv.hpp"
PS: I hope this will also help somebody else.
I am linking to a .a lib and need to link to the right version for the machine that's compiling. Is there a way to detect the type of machine in a .pro file in linux? I found this article, but they only discuss Windows: http://developer.qt.nokia.com/faq/answer/how_can_i_detect_in_the_.pro_file_if_i_am_compiling_for_a_32_bit_or_a_64_bi
Edit: The .a library is Gtest. Another way to solve my problem would be to somehow build a .a file with g++ that will work on either 32-bit or 64-bit platforms. Is that possible?
By doing your conditional on a mkspec, (see Platform Scope Values here), you can check for a very large variety of compiler/platform.
My mkspec directory (Linux64 machine), gives the following differentiations:
aix-g++/ irix-g++-64/ qconfig.pri wince50standard-armv4i-msvc2005/
aix-g++-64/ linux-cxx/ qws/ wince50standard-armv4i-msvc2008/
aix-xlc/ linux-ecc-64/ sco-cc/ wince50standard-mipsii-msvc2005/
aix-xlc-64/ linux-g++/ sco-g++/ wince50standard-mipsii-msvc2008/
common/ linux-g++-32/ solaris-cc/ wince50standard-mipsiv-msvc2005/
cygwin-g++/ linux-g++-64/ solaris-cc-64/ wince50standard-mipsiv-msvc2008/
darwin-g++/ linux-g++-maemo/ solaris-cc-64-stlport/ wince50standard-sh4-msvc2005/
default# linux-icc/ solaris-cc-stlport/ wince50standard-sh4-msvc2008/
features/ linux-icc-32/ solaris-g++/ wince50standard-x86-msvc2005/
freebsd-g++/ linux-icc-64/ solaris-g++-64/ wince50standard-x86-msvc2008/
freebsd-g++34/ linux-kcc/ symbian/ wince60standard-armv4i-msvc2005/
freebsd-g++40/ linux-llvm/ symbian-abld/ wince60standard-x86-msvc2005/
freebsd-icc/ linux-lsb-g++/ symbian-sbsv2/ wincewm50pocket-msvc2005/
hpux-acc/ linux-pgcc/ tru64-cxx/ wincewm50pocket-msvc2008/
hpux-acc-64/ lynxos-g++/ tru64-g++/ wincewm50smart-msvc2005/
hpux-acc-o64/ macx-g++/ unixware-cc/ wincewm50smart-msvc2008/
hpux-g++/ macx-g++40/ unixware-g++/ wincewm60professional-msvc2005/
hpux-g++-64/ macx-g++42/ unsupported/ wincewm60professional-msvc2008/
hpuxi-acc-32/ macx-icc/ win32-borland/ wincewm60standard-msvc2005/
hpuxi-acc-64/ macx-llvm/ win32-g++/ wincewm60standard-msvc2008/
hpuxi-g++-64/ macx-pbuilder/ win32-icc/ wincewm65professional-msvc2005/
hurd-g++/ macx-xcode/ win32-msvc2003/ wincewm65professional-msvc2008/
irix-cc/ macx-xlc/ win32-msvc2005/
irix-cc-64/ netbsd-g++/ win32-msvc2008/
irix-g++/ openbsd-g++/ win32-msvc2010/
In the .pro file, you can have things like:
mkspec:VAR += special_spec_var_value
So for example, when compiling for arm, to link my touchscreen lib I do:
linux-arm-g++:LIBS += -lts