Cross-Compiling Qt for Embedded Linux Applications - c++

Where qmake.conf file is located and how it should look for armhf debian wheezy platform? (BeagleBone Black)
I am trying to follow these steps, but some of them are unreasonable like that one about qmake.
Also what does export PATH=path/to/cross/compiler:$PATH will do?
I enter something like this in path/to/cross/compiler
export PATH=/usr/bin/arm-linux-gnueabihf-g++:$PATH

export PATH=/usr/bin/arm-linux-gnueabihf-g++:$PATH
you should add directory to PATH not path to file, in your case it is /usr/bin,
but because of /usr/bin is already in your PATH you can skip this step.
Where qmake.conf file is located and how it should look for armhf debian wheezy platform?
Look at mkspecs/linux-arm-gnueabi-g++/ in qt source directory, your qmake.conf should looks like it, you can just modify this file to point to your compiler.

After a week of trying to configure arm qt cross-compiler on my Debian 7 Wheezy, I decided to try to follow these steps on Ubuntu 14.04, and everything went as expected! So, don't lose your time playing with Debian Wheezy host machine, try with newest Ubuntu distribution and save your time!

Related

Qt - How to deploy application dynamically on Linux?

I have an application that I built using Qt Creator on Linux and want to deploy it now. However, I don't want to statically build it as I don't want it to be open-sourced. I tried the ldd ./YourExecutable command, however that only lists (and not add) the additional dependencies the application needs in order for it to run. My question is, how do I gather the necessary dependencies without having to individually look for these files? Is there a tool, such as windeployqt.exe on Windows, that I can use on Linux for the same purpose? Or is there a better approach than the one I'm thinking of?
Get Cygwin setup.exe: http://www.cygwin.com/
1.1. Run setup.exe and continue to package selection list.
1.2. Under Devel catagory select tools you need for compiling your source. For
example 'GNU make'.
1.3. Finish installing.
Get linux crosscompilers for cygwin:
"cygwin-gcc-linux.tar.bz2" (68.2 Mb).
md5sum: 340e91a346f5bb17e660db10e43005b8
These compilers are made with crosstool 0.28-rc37. This package contains:
gcc-3.3.4 and gcc-2.95.3 for i386 (glibc 2.1.3) and gcc-3.3.3 for amd64
(glibc 2.3.2).
Note! There is now newer version of GCC avaible with glibc 2.3.2:
"cygwin-gcc-3.3.6-glibc-2.3.2-linux.tar.bz2 (i386, x86_64)".
2.1. Copy 'cygwin-gcc-linux.tar.bz2' to 'c:\cygwin' or install directory which
you selected in setup.exe.
2.2. Open Cygwin shell and change directory to root with 'cd /'.
2.3. Uncompress to Cygwin root with command:
'tar -jxvf cygwin-gcc-linux.tar.bz2'.
Cross-compilers are installed under '/opt/crosstool'. You can use theim
directly or with commands: gcc-linux, g++-linux, gcc-linux-2.95,
g++-linux-2.95, gcc-linux-x86_64 and g++-linux-x86_64.
From: Cross-compiling on Windows for Linux
More info here.
It sounds like you want to use the shared library deployment option:
http://doc.qt.io/qt-5/linux-deployment.html#creating-the-application-package
Then if you wanted to go further than that, you could look into making a .rpm or a .deb .
There are lots of examples of qt projects that are now available on GitHub and have packages made. Usually for prebuilt binaries you need to make one for x86 and a separate one for x64.
Hope that helps.

"Cannot execute binary file" when running compiled c++ programs with Eclipse on Ubuntu for Windows platform

I would like to move from Visual Studio on Windows platform to Eclipse on Ubuntu for c++ development, since I develop almost all my programs on Java, with Eclipse, and I just use a Windows virtual machine in order to develop C++ programs for Win OS. So if I would be happy being able to not use Windows VM at all. However, I've managed to configure MinGW and Eclipse successfully enough to compile programs, but not to execute them.
Steps I've gone through so far:
I've installed mingw32 package and dependencies:
$ sudo apt-get install mingw32
I've installed Eclipse Mars for C/C++ development (manually, to keep this installation isolated from other Eclipses I have) and created a new project in this way:
- New C++ project.
- [...]
- Cross-prefix: i586-mingw32msvc-
- Cross path: /usr/bin/
With this configuration I'm able to correctly build a .exe which I can successfully execute on Windows, but when trying to debug it or execute it under Eclipse I get this error: "cannot execute binary file".
Googleing I've seen some posts suggesting to use wine in order to execute the .exe, but I thought mingw32 would be able to execute it. Am I wrong and this is not possible or just doing something wrong?
Mingw32 is a windows compiler, and will compile source to a Windows executable file. Additionally, the compiler cannot execute files (as worded in the question), it just compiles the source code to an executable form, in this case the windows executable (*.exe). So yes, in order to run the .exe in Ubuntu you would need something like Wine which emulates a Windows environment
mingw is a set of GNU tools for building native Windows executables.
It does not execute anything.
If you really want to cross-compile for Windows, you need Windows or an emulator for the execution.
To build for Ubuntu you can just use the native compilers.
sudo apt-get install gcc

Qt 5.1.1 compiler setup on Ubuntu

First of all, I should point out that I've never used linux before.
I have a clean install of 64bit ubuntu, I downloaded Qt 5.1.1 for linux 64 bit from http://qt-project.org/downloads, ran the .run file, installed it and gcc which is included in that download, opened Qt Creator, made a new project and tried to compile it. It wont compile and I keep getting this error message
:-1: error: Qt Creator needs a compiler set up to build. Configure a compiler in the kit options.
I added a gcc compiler, but what do I need to put for the compiler path, platform codegen flags, platform linker flags and ABI?
You don't have to input the path of your compiler because gcc and g++ paths are available in the $PATH enovironment variable. So just use "gcc" and "g++" and that should work. Just make sure you restart Qt Creator after the installation of g++.
One more thing. You need a compiled version of Qt installed on your computer. So also install Qt libraries with
sudo apt-get install qt4-dev-tools
If you want to use the new version of the library you have to add it to $PATH. You can do this in the terminal with
export PATH=/path/to/Qt/qtbase:$PATH
And then run Qt Creator from the same terminal, in which you did the last command.
Good luck!
You will have to install the dependencies as well. I got it working when I followed the steps in the following link.
Try this:
http://wiki.qt.io/Building_Qt_5_from_Git

How do I install Eclipse with C++ in Ubuntu 12.10 (Quantal Quetzal)?

I just installed Ubuntu 12.10, and I tried to install Eclipse and C++, but I failed miserably.
I started with an installation from the Software Center, Eclipse worked, but only in Java. Then I started googling for installation guides and tutorials, but after hours of downloads and installations, the C++ in Eclipse still doesn't work.
So now I have two questions:
How do I clean up this mess?
Actually, how do I know if there is a mess?
According to the Ubuntu Software Center, Eclipse is installed and has three add-ons.
How do I know if the other installations of other Eclipse versions/packagings overwrote each other or if I have multiple installations?
How do I install the latest version of Eclipse and C++ in Ubuntu 12.10?
There is a package called eclipse-cdt in the Ubuntu 12.10 repositories, this is what you want. If you haven't got g++ already, you need to install that as well, so all you need is:
sudo apt-get install eclipse eclipse-cdt g++
Whether you messed up your system with your previous installation attempts depends heavily on how you did it. If you did it the safe way for trying out new packages not from repositories (i.e., only installed in your home folder, no sudos blindly copied from installation manuals...) you're definitely fine. Otherwise, you may well have thousands of stray files all over your file system now. In that case, run all uninstall scripts you can find for the things you installed, then install using apt-get and hope for the best.
I used (the suggested answer from above)
sudo apt-get install eclipse eclipse-cdt g++
but ONLY after then also doing
sudo eclipse -clean
Hope that also helps.
I also tried http://www.eclipse.org/cdt/ in Ubuntu 12.04.2 LTS and works fine!
First, I downloaded it from www.eclipse.org/downloads/, choosing Eclipse IDE for C/C++ Developers.
I save the file somewhere, let´s say into my home directory. Open a console or terminal, and type:
>>cd ~; tar xvzf eclipse*.tar.gz;
Remember for having Eclipse running in Linux, it is required a JVM, so download a jdk file e.g jdk-7u17-linux-i586.rpm (I cann´t post the link due to my low reputation) ... anyway
Install the .rpm file following http://www.wikihow.com/Install-Java-on-Linux
Find the path to the Java installation, by typing:
>>which java
I got /usr/bin/java. To start up Eclipse, type:
>>cd ~/eclipse; ./eclipse -vm /usr/bin/java
Also, once everything is installed, in the home directory, you can double-click the executable icon called eclipse, and then you´ll have it!. In case you like an icon, create a .desktop file in /usr/share/applications:
>>sudo gedit /usr/share/applications/eclipse.desktop
The .desktop file content is as follows:
[Desktop Entry]
Name=Eclipse
Type=Application
Exec="This is the path of the eclipse executable on your machine"
Terminal=false
Icon="This is the path of the icon.xpm file on your machine"
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE
Name[en]=eclipse.desktop
Best luck!
I was in the same boat. Installed Eclipse, realized need CDT.
sudo apt-get install eclipse eclipse-cdt g++
This just adds the CDT package on top of existing installation - no un-installation etc. required.
http://www.eclipse.org/cdt/
^Give that a try
I have not used the CDT for eclipse but I do use Eclipse Java for Ubuntu 12.04 and it works wonders.

32-bit OpenCV on OS X Lion? Possible?

I've been googling and trying for days now, trying to figure out how to get 32-bit OpenCV working on OS X Lion, but can just find 64-bit version.
So i have the following questions:
OpenCV libraries come in 32-bit or 64-bit arch, is that correct?
How do I get 32-bit OpenCV working on Lion? I've trying the following ways:
- Install OpenCV via MacPorts: nope, MacPorts installs a 64-bit version.BI removed OpenCV and MacPorts.
Install OpenCV 2.4.1 via Homebrew, using the following command:
brew install opencv --build32
but looks like they are 64-bit too. Removed OpenCV and Homebrew.
Install OpenCV 2.4.1 by myself using standard unix makefiles. Nope, they still look like 64-bit.
I've written "they look like 64-bit" because i have to replace OpenC in a Xcode project made under OS X Snow Leopard, targeted for 32-bit Mac, and I always get tons of errors like:
ld: warning: ignoring file /usr/local/Cellar/opencv/2.4.1/lib/libopencv_calib3d.2.4.1.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
so i suppose that the OpenCV stuff is 64-bit. If i force the project to run in 64-bit, it rubs but doesn't work properly and gets stuck.
Is there a standard way to check if my OpenCV libraries are 64-bit or 32-bit?
Where can i get 32-bit OpenCV?
Solved the problem.
Recap: it is possible to have 32-bit OpenCV libraries on 64-bit Mac OSX Lion.
How?
Step 1: Download OpenCV 2.4.0
Step 2: Download and install CMake.
Step 3: Untar the OpenCV package.
Step 4: Make a separate directory inside the OpenCV package for building
mkdir build
cd build
cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 -D CMAKE_C_FLAGS=-m32 -D CMAKE_CXX_FLAGS=-m32 ..
(this will force the 32-bit compile)
make -j8
sudo make install
Step 5: Enjoy!
For forther reference please visit Mac OS X OpenCV Port Page
Thanks all for putting me on the right track:
#karlphilip: I tried to do as you suggested, but without the make options the compile phase fails, because the architectures are incoherent.
#hamstergene: MacPorts got stuck after the new installation, maybe I have some remains of the older install :( (strange, i followed the official instrusctions to remove it).
#Adrien: That's what I've done, but i had to merge 2 approaches :)
I ve had a hard time configuring OpenCv libraries on a number od different OSs. Turns out that the thing is auto-generating a sample project and then bulding business logic inside it.
See the installation instructions here
The web site of the OpenCV project has been significantly upgraded in the last year.
A new tutorial section is avaiable, i was able to install OpenCV on my 32-bit core Mac OS Lion.
A very cool tutorial is also available at Sadeep's Tech Blog, covering an interesting range of details.
Hope this helps!
Here's something you can try: download OpenCV 2.4 sources and edit the CMakeLists.txt in the root directory. Around line 242 you will see:
# ----------------------------------------------------------------------------
# Path for build/platform -specific headers
# ----------------------------------------------------------------------------
set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
add_definitions(-DHAVE_CVCONFIG_H)
ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
below the add_definitions() call, add this one:
add_definitions(-m32)