Build boost with qt app running on ios - c++

I am working on a qt app which runs on am ios device. I am building the app on a Mac OSX laptop. It uses C++ for most part of it. I need to build the app with boost C++ library to use boost asio. So following are the steps I did:
1. Install boost on my mac laptop using port install boost. This puts boost headers into /opt/local/include & boost libs into /opt/local/lib as I see.
2.Next, I used the following lines in my qt app`s .pro file to build
INCLUDEPATH += /opt/local/include
LIBS += -L/opt/local/lib
LIBS += -lboost_system-mt -lboost_thread-mt
Then, I build it. It says "symbols not found for architecture arm64" & "linker command failed with exit code 1"
Can anyone please point out what is the correct way to build boost for a qt app running on ios ?

To use boost on iOS, you need a "cross-compiled" version, for the iPhone's processor architecture. The version you installed locally on your Mac was compiled for architecture x86_64. For an iOS app you need armv7 and arm64.
Fortunately, there seems to be a precompiled boost library for iOS available under https://github.com/danoli3/ofxiOSBoost, which looks like it's exactly what you need. Maybe you can have a look at that.

Related

Entry point not found on OpenCV dll with Qt 5.12

TLDR: Linking OpenCV with QT MingW makes application crash in Debug but not release.
I am trying to use OpenCV in a large multi OS project based on Qt. I have easily managed to build OpenCV for Mac and Linux but I am very much struggling to use it on Windows.
Environment:
Qt 5.12.2 MinGW
MinGW 8.1.0 64bit
OpenCV basically all versions since 4.1.0
CMake 3.19
What I tried
I first tried to build OpenCV from source following his link https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows but had some issues running the application in Debug such as Entry Point not Found in opencv Library (exact error below)
I lately used prebuilt packages from MSys2 using its pacman and tried version 4.2 to 4.5 without real success. I managed a couple of time to link the OpenCV libraries from the installation path of msys (C:\msys64\mingw64\bin) and with this path in the environment PATH I was able to launch the application using the .exe generated by Qt. However once I dragged the needed libraries into our third party libraries folder for deployment the application can't start anymore in Debug (with Qt nor with the .exe).
I tried in Release mode and everything works fine
Now everytime I run the application in Debug with Qt the program crash immediately without even entering the main. I have the following error when I use the .exe:
I have seen that it could be a TBB issue so I tried using a different version from MSys without success.
I tried to change the PATH variables from Qt for the Build and the Run without success.
My includes and Libs in my .pri are used as follow (they are all found during the build)
INCLUDEPATH += -I $$PWD/../../ext/OpenCV/include/opencv4
DEPENDPATH += -$$PWD/../../ext/OpenCV/include/opencv4
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_imgproc430
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_core430
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_dnn430
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_imgcodecs430
LIBS += -L$$PWD/../../ext/OpenCV/lib/$$OSFOLDER/$$ARCHFOLDER -lopencv_highgui430
Okay so I finally managed to get it work!
As I said in my question this error happens sometimes when the TBB version is not correct so here's what I did:
Build manually TBB with this repository: https://github.com/wjakob/tbb which contains a CMake-based build system of the official repository : https://github.com/oneapi-src/oneTBB
Build OpenCV with the version needed using the compilers you will use later in your application:
Uncheck 'BUILD_TBB', check 'WITH_TBB' and point to the previously built TBB libraries and include.
Add the flags you need ( OPENCV_ENABLE_ALLOCATOR_STATS=OFF for instance ) and build it.
Finally add the libraries from 'path/to/opencv-build/bin' instead of 'path/to/opencv-build/install/bin' (maybe that's what we should always do but I wasn't sure) and it worked for me!

Problems using Qt with meson on Mac

I stumbled across the build system meson ( http://mesonbuild.com/ ) which attracted me due to its simplicity and native Qt support.
However, when I followed the tutorial I got the error message
Build type: native build
Project name: qt5 demo
Native cpp compiler: c++ (clang 8.1.0)
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/local/bin/pkg-config (0.29.2)
Dependency QtWidgets found: NO
Meson encountered an error in file meson.build, line 3, column 0:
Qt5 native dependency not found (checked pkg-config, qmake-qt5, and qmake)
which is weird because when I use Qt Creator I can create, compile, and execute Qt projects easily. I am using MacOS Sierra.
Can I somehow tell meson where qmake is located?
Ok, I fixed this issue by adding
export PATH="<path to qmake>":$PATH
to my .bash_profile file, where is the path to the folder containing the qt binaries, such as qmake.

How to build Caffe framework XCode 6.2, iOS 8.3 environment

I am working on build caffe framework for ios, i used the Caffe master source and make files to build the framework for iOS.
I changed the OS target in CMake GUI config as "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
While run Xcode to build project i got the below error messages
/Users/Macpro_ios_v2/Caffe_iOS/src/caffe/common.cpp:1:10: 'glog/logging.h' file not found
"boost/thread.h" file not found
i included usr/local/include and opt/local/include to search paths in the build phase
while run the same xcode project for OSX, it works fine and generates the libs perfectly. If i change the target for iphone OS i got above error.
Please help me to fix the above issuse. Please help how to configure the make list in Caffe master for iphone.
I have caffe dylip, lib-a for OSX. Is it possible to link mac osx libaries in iOS project?
cloudVision,
You should install OpenCV2 from here before you compile the caffe-ios-sample:
http://docs.opencv.org/doc/tutorials/introduction/ios_install/ios_install.html

Qt 4.8.2 With GCC 4.7.0.1 Keeps Crashing

I've downloaded Qt 4.8.2 library, Qt Creator 2.5.2, and manually installed MingW with w32api version 3.13 and GCC/g++ version 4.7.0.1. My OS is Windows 7 Ultimate x64.
I can create a sample "Plain C++ project" in Qt Creator; compile and run that console application using g++ without any issue.
But I cannot run a Qt application. I used Qt Creator, created a dummy Qt Application using Creator's "Qt Gui Application" template. The project can be compiled successfully, without any error or warning. But the binary keeps crashing when I try to run (both from Qt Creator and Windows Explorer) it. Both debug and release builds crash. It crashes even before showing main window.
MingW is installed in C:\MingW and C:\MingW\bin is in PATH. Qt is installed in C:\Qt\4.8.2 and C:\Qt\4.8.2\bin is in PATH.
I analyzed generated exe of the Qt Gui Application output with Dependency Walker and found that it found all required DLLs:
c:\windows\system32\KERNEL32.DLL
c:\windows\system32\MSVCRT.DLL
c:\mingw\bin\LIBGCC_S_DW2-1.DLL
c:\mingw\bin\LIBSTDC++-6.DLL
c:\qt\4.8.2\bin\QTCORE4.DLL
c:\qt\4.8.2\bin\QTGUI4.DLL
So, what's causing the runtime crash?
EDIT
I also tried Qt's example projects: 2dpainting and addressbook - both crashed when they were launched.
You should build Qt with the MinGW compiler you're using to build your application. GCC is generally less sensitive to binary compatibility issues than MSVC is, but Qt is a big, complex framework library. If anything would expose those kinds of issues, Qt would probably be on the short list.
Building Qt is pretty straightforward, but it takes a lot of time and there always seems to be two or three patches I need to make to get things to build successfully.
The last time I built Qt (4.7.3) with MinGW, I had to make the following patches - I'm not sure whether they will still apply to Qt 4.8:
make sure not to enable C++11 mode in the compiler - there are several macros with concatenated string literals that break under the new C++11 extended literal syntax
there is a problem with how some distributions of MinGW incorporate the Microsoft extensions to float.h - I had to sometimes had to add the line:
#include_next <float.h>
to the end of the MinGW-specific float.h so the generic GCC float.h would get processed properly. I had to do this for nuwen 4.7.0 lib/gcc/i686-pc-mingw32/4.7.0/include/float.h and TDM 4.6.1 32-bit distro lib/gcc/mingw32/4.6.1/include/float.h (the 64-bit distro of TDM didn't need this patch).
patch qmake\Makefile.win32-g++ and qmake\Makefile.win32-g++-sh to remove the -static-libstdc++ option that GCC doesn't recognize (and now errors out on instead of ignores)
patch mkspecs/win32-g++/qmake.conf to move the -Wl, in the QMAKE_LFLAGS_EXCEPTIONS_ON macro to its proper place in QMAKE_FLAGS:
QMAKE_LFLAGS = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
copy make.exe to mingw32-make.exe in MinGW's bin directory if there's not already a mingw32-make.exe
Then building Qt consists of:
set QTDIR=<location of Qt source directory> # where configure.exe is
set PATH=%QTDIR%\bin;c:\MinGW\bin;%PATH%
set INCLUDE=
set LIB=
cd %QTDIR%
mingw32-make confclean # (this should fail the first time, since there's nothing to clean)
configure.exe -opensource -debug-and-release -nomake examples -nomake demos -nomake tests -platform win32-g++ # and accept the GPL license
mingw32-make
This takes a while... hopefully nothing else will need patching.
I also got this problem. I'm a Qt n00b and tought, when installing Qt-libraries, that "well I already have Mingw installed so I skip installing the Mingw that comes with Qt". That gave me prolems. When installing mingw that came with Qt everything worked ok.
So my advice to anyone googling to this question (like I did) is to instead of using your already installed Mingw, install the one with Qt and use that (otherwise you have to build the Qt libraries within your Mingw, like the answer from Michael Burr)

Problems deploying Qt application using QtWebkit and OpenSSL on Linux

I have an application that I'm writing that uses QtWebkit and OpenSSL which deploys fine on Mac OS X 10.6 or higher and Windows XP SP2 or higher, but I'm having problems deploying the application on Linux (Unix) platforms. I've made a tarball of the application including a bin and lib folder and set the LD_LIBRARY_PATH to the local lib folder and included all Qt and external libraries on the lib folder. When my application tries to load webpages using SSL, it can't resolve the functions necessary for SSL. I've gotten deployment to work if I install the development libraries for OpenSSL on my target machine, but I'd like to have my application use the release libraries for OpenSSL on the user's machine. Am I missing something in my pro file?
Here's the relevant code from my pro file:
QT += core gui webkit network sql xml
unix:LIBS += -L$$PWD/../../../usr/local/lib/ -lqjson
unix:INCLUDEPATH += $$PWD/../../../usr/local/include
unix:DEPENDPATH += $$PWD/../../../usr/local/include
macx:LIBS += -L$$PWD/../../../usr/local/lib/ -lqjson
macx:INCLUDEPATH += $$PWD/../../../usr/local/include
macx:DEPENDPATH += $$PWD/../../../usr/local/include
win32:LIBS += -L C:/qjson/lib/ -llibqjson
win32:INCLUDEPATH += C:/qjson/include
win32:DEPENDPATH += C:/qjson/include
I'm considering making a deb and rpm package to resolve dependency problems, but I'd rather not make several packages for each available Linux distribution. This is why I went the tarball method first. I'm open to suggestions.
Maybe you didn't compile Qt with support for SSL. Read about it here