QMake not finding GraphicsMagick libraries - c++

I am trying to link a Qt program with GraphicsMagick, but Qt/qmake refuses to search /usr/local/* for GraphicsMagick++-config. I am using the $$system() command to fetch the flags like so:
QMAKE_CXXFLAGS += $$system(GraphicsMagick++-config --cppflags --cxxflags)
QMAKE_LIBS += $$system(GraphicsMagick++-config --ldflags --libs)
But every time, qmake complains /bin/sh: GraphicsMagick++-config: command not found. I have tested my path, and I can see /usr/local/bin from sh, csh, zsh, and bash. I am not sure why Qt can't find this command. Is there something simple I am missing?
I am running OS X 10.9, with Qt 5.3.1.

Make sure that you run qmake from the same shell where you did the PATH test, running it through a Finder-launched QtCreator might not inherit the environment if you set it in your ~.*shrc file.
I tried your code and qmake properly calls GraphicsMagick++-config with my brew installed GraphicsMagick.
FWIW, even though you might get the same error, a better way to get it to work would be to let qmake figure out the pkgconfig logic itself:
CONFIG += link_pkgconfig
PKGCONFIG = GraphicsMagick++

Related

wxWidgets autoconf setup doesn't set include dirs as -Isystem but as -I

I have inherited a build system that uses autoconf and automake to build. I am not at all familiar with how this works except on a high level.
The build system itself works fine. However a lot of warnings are generated from system headers. In my case wxWidgets. The cause of this is that the include dir of wxWidgets is passed as -I instead of -isystem. I have searched online but I can't find how I can change this.
The following code is in the configure.ac file:
AM_OPTIONS_WXCONFIG
AM_PATH_WXCONFIG(3.0.2, wxWin=1, , ,[--debug=yes])
if test "$wxWin" != 1; then
AC_MSG_ERROR([
wxWidgets must be installed on your system
but no wx-config script could be found.
Please check that wx-config is in path, the directory
where wxWidgets libraries are installed as returned by
'wx-config --libs' is in the linker path (LD_LIBRARY_PATH
or equivalent variable) and wxWidgets version is 2.9.4 or
above.
])
fi
if test "$wxWin" != 0; then
AC_DEFINE(HAVE_WXWIDGETS,1,[define if the wxWidgets 3.0.2. or higher is available])
fi
Then there is a Makefile.am which does the following:
bin_PROGRAMS = project
project_SOURCES = {sources here}
project_CPPFLAGS = $(AM_CPPFLAGS) $(PROJECT_CPPFLAGS) $(WX_CPPFLAGS)
project_CFLAGS = $(AM_CFLAGS) $(PROJECT_CFLAGS) $(WX_CFLAGS)
project_CXXFLAGS = $(AM_CXXFLAGS) $(PROJECT_CXXFLAGS) $(WX_CXXFLAGS)
project_LDFLAGS = $(AM_LDFLAGS)
project_LDADD = $(AM_LIBADD) $(WX_LIBS)
There doesn't seem an option that I can specify it as a system header in some way.
Do anyone of you know how I can tackle this?
The problem has nothing to do with autoconf. It's the wx-config tool that is the culprit. That tool is used to obtain the include directories. For instance invoking wx-config --cxxflag will result in this:
-I/usr/lib/wx/include/gtk2-unicode-3.1 -I/usr/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread
Which is passed to the compiler. There are a couple of ways of solving this. Either manually replace it in the output or patch wx-config.

Missing "libiconv.h" when crosscompiling for Windows with mingw on Ubuntu

I have been working on a program in SDL and I would like to send it to my friends who only run a Windows environment. I have done some reading and found that I should use mingw to cross-compile for Windows. The binary I found and compiled was x86_64-w64-mingw32-g++, however I am getting some issues getting my program to compile. Using the following command I get the following error:
/usr/bin/x86_64-w64-mingw32-g++ sapphire.cpp `pkg-config --cflags --libs sdl2` -lSDL2_image -lSDL2_mixer -lSDL2_ttf -std=c++11
fatal error: iconv.h: No such file or directory
While I realize I should make a makefile eventually, I am not going to do that now.
I tried installing iconv (Version 1.15) from here and used the following commands to compile it:
./configure --prefix=/usr/local
make
make all
My iconv.h is located in /usr/include but if I include that I get another error for missing gnu/stubs.h and if I include that then I get a myriad of errors that I'm not sure how/if I could fix seen here. Does anyone know how I could perhaps fix this? I would appreciate any help!
Thanks in advance!
You can use pkg-config with mingw in a crosscompiler environment but you should take care to where pkg-config searches for his .pc files.
I'm assuming your mingw crosscompiler is installed in /usr/x86_64-w64-mingw32, change it to the installation path where his "include" and "lib" subdirectories are.
Provided SDL windows developement package is installed in the same prefix on your computer and the installation has a correct pkg-config .pc file you can do:
export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig
and then try pkg-config from the command line:
pkg-config sdl2 --cflags
This should point you to some path inside /usr/x86_64-w64-mingw32, if it does your compilation will be successful.
Please note that if you want to compile a package for crosscompile (like the iconv you tried to compile) you should add to the ./configure script parameters:
--host=x86_64-w64-mingw32 --prefix=/usr/xx86_64-w64-mingw32
... and this may work or not, depending the package support the mingw32 compiler or not.
The way you compiled iconv built another linux version of it in /usr/local!
NOTE: As far as I know Ubuntu does not provide a windows package for SDL2, while other linux distro do, so you'll need to cross-compile SDL2 with the option I gave before you can compile your code. SDL2 does support cross-compilation using mingw.

ft2build.h: No such file or directory - Freetype 2.6

I am trying to build from Linux cause I decided to start using Jenkins, my personal work but, even with freetype installed: v.2.6.3, it doens't recognize this ft2build.h.
This is the QT Pro with freetype loaded. I'm now running on UBuntu 16.04:
linux {
message("Build for Linux")
DEFINES += LINUX
DEFINES += BOOST_LOG_DYN_LINK
LIBS += -lGLU
LIBS += -lfreetype
LIBS += -L/usr/lib/x86_64-linux-gnu/-libboost_timer.so -libboost_log.so -libboost_log_setup.so -libboost_system.so -libboost_thread.so -libboost_filesystem.so
}
So i tried to change also the lib pointer doing manually as:
LIBS *= -L/usr/local/lib/ -lfreetype
but still nothing going properly. The error I get is from lGLU
In file included from displays/display.cpp:3:0:
displays/./../oglft/oglft.h:50:22: fatal error: ft2build.h: No such file or directory
compilation terminated.
Makefile:1093: recipe for target 'display.o' failed
I do always run 'qmake make clean' then /usr/lib/x86_64-linux-gnu/qt5/bin/qmake && make && make check to be sure it starts properly. Can someone help me solving the bug?
I've checked where freetype lib is located by doing:
pkg-config --cflags --libs freetype2
and this is what I get
-I/usr/local/include/freetype2 -L/usr/local/lib -lfreetype
PROBLEM SOLVED!
I have had to set FREETYPE in the environment variables as BOOST too and everything is now working properly!
Here is how is mine:
export BOOST=/var/lib/jenkins/workspace/boost_1_59_0
export FREETYPE=/var/lib/jenkins/workspace/freetype-2.6.3
I preferred to move those two libs under Jenkins to avoid permissions problems.
;-)

Adding compilation flags to Qt to use mysql

I am using ubuntu to build a project that uses mysql. To compile the project from the command line I use the following flags:
$(mysql_config --cflags)$(mysql_config --libs)
However, when I am trying to build from Qt, I get that undefined reference to mysql_close and the rest of mysql connection functions.
I tried adding the representation of the previous command line flags to QMAKe in Qt and still same errors.
Any Help?
Add the output of "mysql_config --cflags" to the compiler flags with:
QMAKE_CFLAGS += $$system(mysql_config --cflags)
QMAKE_CXXFLAGS += $$system(mysql_config --cflags)
Likewise for LIBS:
LIBS += $$system(mysql_config --libs)
All of the above goes into your project file (*.pro) of course.
To include Qt's SQL modules, you need this
QT += sql
in your .pro file. You also need to make sure the drivers have been compiled, and put into the plugins folder, libqsqlmysql.so in
~/QtSDK/Desktop/Qt/4.8.0/gcc/plugins/sqldrivers
in my case.
Mysql is not included in the SQL modules by default so Matt Philip's solution won't work.
What you need to do is install the mysql dev package by doing
sudo apt-get install libmysqlclient-dev
and then add it to the pro file like this
LIB += -L/usr/lib/mysql -lmysqlclient
This worked for me on ubuntu

Error when cross compiling Qt for ARM

I am trying to cross compile Qt on Ubuntu Linux for ARM. But I get the following error:
bin/rcc: File does not exist 'dialogs/qprintdialog.qrc'
The build command which produces this is:
bin/rcc -name qprintdialog dialogs/qprintdialog.qrc -o .rcc/release-shared/qrc_qprintdialog.cpp
I tried to manually execute this command by giving an absolute path to dialogs/qprintdialog.qrc but still have the same error although dialogs/qprintdialog.qrc does exist.
I have configured Qt as:
./configure -no-exceptions -no-accessibility -no-xsync -no-xinerama -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-mitshm -no-xinput -no-xkb -no-nas-sound -arch arm -platform linux-g++ -xplatform qws/linux-arm-g++ -release -opensource -fast -I$ARM/usr/include -L$ARM/usr/lib -L$ARM/lib -lrt -lX11 -lxcb -lXau -lXdmcp -lXext -lz -prefix custom_path_to_install
Any help would be appreciated.
An easy way to troobleshot this could be to install Qt Creator. Create a project with your code. Then, don't compile and run inside the IDE, but instead, in your terminal, do to your project folder with all your code (and new Qt Creator file .pro), and enter this:
qmake -project
qmake
make
Don't change -project, it's really the command, not the name of your project. I believe it will do it. Qt create has a .pro file which is then compile into a Makefile via qmake and manage all that for you.