Trying to compile some code that is primarily Qt, but has a bunch of calls into the the Carbon layer.
In Linking, all of the Carbon calls come up unresolved.
My config cmdline build has this: -sdk /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -carbon -universal
My project has this: CONFIG += i386 ppc, and
this: QMAKE_CXXFLAGS += -mmacosx-version-min=10.4
As you can see, I'm targeting/using the 10.4u sdk.
All of the Carbon calls come up unresolved. Is there a way to specify the carbon libs directly on the link line?
I have no idea how to set this in Qmake, but linking to the Carbon framework is done via -framework Carbon, e.g.
g++ a.cpp -o a -framework Carbon
Since -framework is a linker option, you could try using it on Qmake’s equivalent of LDFLAGS. Alternatively, you could pass -Wl,-framework,Carbon to the compiler driver.
Related
I am statically linking an QT application, but for some reason when i open the executable i am getting errors for missing dlls.
Basically i am linking the following libs:
### LINKER FLAGS ###
LDFLAGS = -LC:/Qt/5.15.0/mingw81_32/lib
LDLIBS = -lQt5Widgets -lQt5Gui -lQt5Core
Why am i getting errors for missing dlls when i am statically linking everything?
The compilation and linking passes correctly, the executable is generated also..i have no idea why it needs dlls.
EDIT:
Missing dlls:
libgcc_s_dw2-1.dll,
libstdc++-6.dll,
Qt5Code.dll,
Qt5Widgets.dll
To elaborate on CristiFati's reply, you need a line like this in your project file:
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
though I'd prefer:
QMAKE_LFLAGS_RELEASE += -static-libstdc++ -static-libgcc
Note that if you want a truly standalone, self-contained binary, you'll need to build yourself a static Qt library. That's kind of a big deal, and unfortunately not as well documented as most of Qt-land is.
I want to use clang-cl with address sanitizers on Windows. When trying with the prebuilt llvm/clang packages from the official installers, I get linker errors because my application needs linking to the dynamic CRT (/MD) instead of the static CRT (/MT, the packages in the llvm/clang installers have compiler-rt built with this).
I want to use this with Qt, because I did not manage to build Qt itself with /MT .
According to these slides from a google engineer, building compiler-rt/asan with /MT is possible.
What do I have to change compared to these instructions when building llvm/clang in order to build compiler-rt with /MT ?
It turns out that my linker errors had another reason.
To find the required libraries, build a small hello-world app with the following command, inspect the resulting linker command and link to the required libraries explicitly:
clang-cl -v -fsanitize=address /MD test.cpp
PR35343 (currently unresolved) is about supporting automatic linking of sanitizer libs in lld-link, like it is done on other platforms.
I used Qt 5.7 and gcc 4.9.2. Qt Core module throw Qt requires C++11 support error.
This page say that
gcc 4.9.2 fails to compile Qt.
So I installed gcc 4.8. I check using below command on terminal :
$ g++ --version
g++ (Ubuntu 4.8.4-1ubuntu15) 4.8.4
My kit uses cmake not qmake. I add TARGET_LINK_LIBRARIES ( xxxx yyyy /usr/bin/c++ -std=c++11 to CMakeLists-txt.
I restart my pc and run my application again. Same error is throwed.
/opt/Qt/5.7/gcc_64/include/QtCore/qbasicatomic.h:61: error: #error "Qt requires C++11 support"
# error "Qt requires C++11 support"
^
How can I solve it?
If using QtCreator, you can add this to your .pro file:
CONFIG += c++11
https://wiki.qt.io/How_to_use_C%2B%2B11_in_your_Qt_Projects
Its has been a while.
How I finally solve it is indicating in CMakeLists.txt the following line just after project(MyProject):
add_compile_options(-std=c++11)
That says to cmake, to create a Makefile that will use c++11 solving issues.
solution for me was (in your .pro file):
QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -mmacosx-version-min=10.7
QMAKE_LFLAGS += -mmacosx-version-min=10.7
Turn c++11 on explicitly:
set(CMAKE_CXX_FLAGS "-std=c++11" CACHE STRING "compile flags" FORCE) after project(...) declaration.
add_library(MyLib SHARED ${PROJECT_HEADERS} ${PROJECT_SOURCES})
...
set_property(TARGET MyLib PROPERTY CXX_STANDARD 11)
set_property(TARGET MyLib PROPERTY CXX_STANDARD_REQUIRED ON)
SOMETIMES, this will not be a configuration issue as mentioned in other answers. In my case, the problem was one file that happened to have been saved with a .CPP extension rather than .cpp. QMake (Qt5) was misidentifying the file and trying to compile it with the C compiler rather than the C++ compiler. The QMake from Qt4 was not exhibiting this issue. Renaming the file fixed the issue.
My comment at the time was "Could this really be that f&%%& simple!!"
I work on Mac OS 10.8.5 and Qt 5.1.1 with among other things, qdebug class which work well with some projects and doesn't compile with some others. I've already tried to re-install Qt which didn't change a thing.
It is certainly due to the use of SDL library (?!) but it used to work fine. Here's a part of the compilation output :
In file included from ../../Stage/Joker/tests/SDLTest/main.cpp:7:
In file included from /Applications/QT/5.1.1/clang_64/include/QtCore/QDebug:1:
In file included from /Applications/QT/5.1.1/clang_64/include/QtCore/qdebug.h:46:
In file included from /Library/Frameworks/QtCore.framework/Headers/qhash.h:46:
/Library/Frameworks/QtCore.framework/Headers/qchar.h:76:5: error: unknown type name 'QT_ASCII_CAST_WARN_CONSTRUCTOR'
QT_ASCII_CAST_WARN_CONSTRUCTOR QChar(char c);
^
If needed, I can provide more output or unworking Qt classes.
I build my code with Qt => Build => Run
Unfortunatly, I'm unable to reproduce the code on an other computer.
Here's the pro file (which work well with all my co-workers, except me) :
TEMPLATE = app
SOURCES += main.cpp
OBJECTIVE_HEADERS += ../../libs/PhGraphic/SDLMain.h
OBJECTIVE_SOURCES += ../../libs/PhGraphic/SDLMain.m
LIBS += -framework Cocoa
QMAKE_CXXFLAGS += -F/Library/Frameworks
QMAKE_OBJECTIVE_CFLAGS += -F/Library/Frameworks
LIBS += -F/Library/Frameworks
LIBS += -framework SDL -framework SDL_image -framework SDL_ttf
I'd once had this problem after installing a software: it created a QtCore.framework in the /Library/Framework folder that overrided the QtCore of your current Qt kit (due to QMAKE_CXXFLAGS += -F/Library/Frameworks).
It's qDebug, and there are two overloads:
a stream-returning function
qDebug() << "foo";
a printf-style function
qDebug("foo");
You need to provide a minimum reproducible test case for us to help you.
How are you building your code? Are you using qmake to produce the Makefile? We'd need to see the .pro file at the minimum, and please minimize it by removing useless boilerplate comments etc.
I am new to using OpenGL with Qt Creator and I have been playing around with the information I got from various tutorials. However, I never was able to find out where the OpenGL function definitions actually are!
I was thinking that when I linked the opengl module to the qmake file like this:
QT += core gui opengl
the OpenGL stuff was included, but then I thought again when I was reading about the QGLWidget.
So where does the OpenGL API become included into my code?
P.S. My OS is Windows 7 and I my graphics card is AMD Radeon HD 6250 Graphics.
The QT variable is used to include Qt modules into your project. By adding opengl you're adding the Qt OpenGL module which contains Qt code that uses OpenGL (and links to it). If by "include" you mean link, than the OpenGL module of Qt (libQtOpenGL.so) links the various OpenGL libraries. Also, the Qt module includes the headers of the Qt OpenGL module which in turn includes OpenGL headers.
The OpenGL headers and the OpenGL libraries are wherever your OS keeps those. Your project knows where those are because of the Qt mkspecs for your platform, whatever it is. In the mkspecs, include paths and link paths are already included.
For instance, now I'm on a Mac OS X, and Qt mkspecs are installed in /usr/local/Qt4.8/mkspecs. Here I have all the platform descriptions, under common you can find mac.conf, which is a part of the description of my platform. Inside it you can see:
QMAKE_INCDIR_OPENGL = /System/Library/Frameworks/OpenGL.framework/Headers \
/System/Library/Frameworks/AGL.framework/Headers/
This information is used when Qt Creator (qmake) is asked to produce a Makefile for any application. This way your application knows where to find the headers for OpenGL. Your project will automatically add that to the include paths only when you add the opengl module.
As another example, this is part of the definition for the Linux platform:
...
QMAKE_INCDIR =
QMAKE_LIBDIR =
QMAKE_INCDIR_X11 = /usr/X11R6/include
QMAKE_LIBDIR_X11 = /usr/X11R6/lib
QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS]
QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS]
QMAKE_INCDIR_OPENGL = /usr/X11R6/include
QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib
QMAKE_INCDIR_OPENGL_ES1 = $$QMAKE_INCDIR_OPENGL
QMAKE_LIBDIR_OPENGL_ES1 = $$QMAKE_LIBDIR_OPENGL
QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_OPENGL
QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL
QMAKE_INCDIR_EGL =
QMAKE_LIBDIR_EGL =
QMAKE_INCDIR_OPENVG =
QMAKE_LIBDIR_OPENVG =
...
I suppose you can understand on your own what this means ;-)
So to answer your question: the include paths and the link paths to the OpenGL libraries are included into the Makefile qmake produces for your application taking the information stored in the mkspec file which is located somewhere in your system. The actual OpenGL headers and libraries are located in a default location in your system, and this has nothing to do with Qt itself. You might need to include the headers in your source code if you use OpenGL libraries directly (or you might not need, it depends), but the include paths should already be provided by your mkspec files.
EDIT: Look what happens automatically when adding the opengl module: this is the command line Qt Creator uses to compile a C++ file without the opengl module (on Mac):
g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8/mkspecs/macx-g++ -I../TextEdit -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I. -I. -I../TextEdit -I. -F/Library/Frameworks -o main.o ../TextEdit/main.cpp
now this is what happens after adding it:
g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8/mkspecs/macx-g++ -I../TextEdit -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/Library/Frameworks/QtOpenGL.framework/Versions/4/Headers -I/usr/include/QtOpenGL -I/usr/include -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -I. -I. -I../TextEdit -I. -F/Library/Frameworks -o main.o ../TextEdit/main.cpp
Your project has been told where to look for the OpenGL headers.
Qt do not contain OpenGL API definition. It must be present in OS already (usually bundled with GPU driver).
Look for documentation of your gpu driver or OS docs.
Try "GLEW", "glut", "GLU", and "GL" instead of "opengl", I'm not sure how it works with Qt Creator, but these are linker flags for opengl.