How do I cross-compile a QT application for imx6? - linux

How do I cross-compile a QT application for a Freescale Hummingboard(imx6(arm))?
There are some guides around, but I've not been able to complete one with success.
The following (and more) guides give me a compile error on ./configure
http://forum.solid-run.com/linux-on-cubox-i-and-hummingboard-f8/qt5-3-on-hummingboard-t2072.html
https://community.freescale.com/docs/DOC-94066
When I run the ./configure command (With recommended commands, I've tried this with a lot of possibilities for commands but got none working). I got a compile error for all the external libraries QT uses (zlib, libjpeg, libpng, etc.). So it's a dead end from there.
I've tried a lot more stuff, I don't even remember all the stuff I've tried, but I got nothing working.
I'm trying to use mini-distribution for the Hummingboard. It's a system without window manager that is able to run QT applications (QT5). The build tool I'm trying to use is gcc-linaro-arm-linux-gnueabi, I'm using QT Creator. I've got QT working on the Hummingboard, I just can't compile anything for it.

I managed building an application for the IMX6 finally. Here is how I did it for other's. It's not an optimal solution but it is an solution.
I use Buildgear to build mini-distirbution as OS (Google it, not enough links with my reputation). I append my own application to this mini-distribution to also build it. This is done by placing creating a folder in the buildfiles/cross/cross-hummingboard folder and adding a buildfile (mine look like this http://pastebin.com/bZkJUiry). In this folder I also place a .tar of the project files (including the .pro). To get it to build I add "qt-gui" as a dependency to the fs (buildfiles/cross/cross-hummingboard/fs) by adding it to the list of depends.
I then run buildgear build fs, which will create an (Tarred) image including my (working) qt-application! I then extract the ./qt-gui executable and ssh it to the Hummingboard.
Of course this is all a bit cumbersome so I made a script that automates this all: http://pastebin.com/jFM6rZyY
It copies and Tars sources, compiles it together with the fs, extracts the executable, ssh's the file to the hummingboard and runs it. Takes about 3 minutes building but it works which is what counts for me at this point.

Related

How do you pull library dependencies of binary you want to package using snapcraft

I am trying out the new linux packaging tool http://snapcraft.io/create/
It does have some documentation but it's not very mature and doesn't contain everything.
What I am trying to do is to generate a package for my binary that is compiled using Qt framework, thus it depends on a load of .so files. I couldn't find in documentation any way to convince snapcraft to pull all these dependencies and add them to the program hierarchy (the mounted squashfs).
So in order to "temporarily fix that" I hacked a very lame shell script that executes ldd on my binary and does this on its own. That "sort of" works because now indeed all the necessary libraries are in the image, but the program can't find them, because most of them have own paths and are not in root lib folder /usr/lib
The example of error I am getting when I try to start my program is:
/snap/huggle/x1/usr/bin/huggle: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory
But the library is there:
/snap/huggle/x1/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
It just has no clue how to find it. On other hand, given that snapcraft is advertised as awesome simple stupid packaging tool, I find it quite weird that something so simple as packaging a C++ binary would be so complicated. How should I do this properly?

Compiling STK (Synthesis Toolkit) for use in Code::Blocks

I realise this is a newb question but I've been racking my brains for hours.
So I want to use the STK (Synthesis Toolkit) to generate sine waves etc. I've downloaded the source files from https://ccrma.stanford.edu/software/stk/download.html
I unzipped the tar.gz using 7zip.
I opened up the demo.cpp project file (under /projects/demo/demo.cpp) and whenever I try to compile it, I receive lots of errors, all starting with "undefined reference to"
I have set the compiler search directory to include the root folder of the stk kit (unzipped as "stk-4.5.0"). My understanding is that I also have to find file for the linker, that is of the type .lib? Is that correct? I haven't been able to find a .lib file to link to.
I feel like this is a simple fix - what am I missing?
You've downloaded a source , not the compiled library which might be used by linker (.lib file) There are three solutions:
1. Compile whole src folder of your download ( see instructions on their website). Frankly, I've tried to do that recently but failed, especially under Windows although I don't have any experience in this so you can try yourself.
2. Use precompiled library available in some Linux repositories. I had success with Slacko Puppy linux. Package simply adds libstk.a (linux static library) to /usr/lib and stk headers to /usr/include/stk (notice you have to add exactly that path to compiler, since /usr/lib is not enough). This gave me best results.
3. If you use only several classes, you can copy their .cpp files directly to your project source folder. Remember to add parent classes, too (see STK site -> Classes). Again I recommend that you give the compiler path to include folder you've unzipped, but copying only selected headers should also work.
I've found this article helpful (see also A1): http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/
Hope I've helped

CMake - set_property could not find TARGET xxx. Perhaps it has not yet been created

Greetings, what I'm trying to do is to port an existing Windows application to Linux using CMake with CMakeLists, which I generated with the vcproj2cmake Script (https://github.com/sixman9/vcproj2cmake).
With the CMakeLists.txt and CMake I was able to successfully port a VS 2005 project to VS 2010. Now I try to port the same VS 2005 project to Linux, so that I can edit it with KDevelope.
The project itself is small and I think it would be easier to just create a new project and copy all relevant files (if that would work), the problem is, that it's not only one project but many, hence I was looking for a way to port a project in an as simple as possible way.
In Linux I was able to create a CMakeLists.txt using the vcproj2cmake script. The next step would be creating a KDevelope project using CMake. And this is where I'm stuck.
Everytime I try to run CMake I get the following error:
CMake Error at CMakeLists.txt: 196 (set_property) :
set_property could not find TARGET Test_Project. Perhaps it has not yet been
created.
Test_Project: installing /root/Desktop/Test_Project/vs8/CMakeLists. txt rebuilder (watching /root/Desktop/Test_Project/vs8/Test_Project. vcproj)
Configuring incomplete, errors occurred!
See also “/root/Desktop/Test_Project/vs8/CMakeFiles/CMakeOutput.log”.
I searched for a solution or an approach for quite a time now, but the only results that I get are project-specific, or at least I think they are.
Content of the CMakeLists.txt from line 196:
set_property(TARGET Test_Project PROPERTY PROJECT_LABEL "Test_Project")
v2c_rebuild_on_update(Test_Project "${CMAKE_CURRENT_SOURCE_DIR}/Test_Project.vcproj" ${CMAKE_CURRENT_LIST_FILE} "vcproj2cmake.rb" ".")
include(${V2C_HOOK_POST} OPTIONAL)
Perhaps there are more efficient ways to port many projects form Windows to Linux, I'm open for any suggestion.
It is a bit difficult to help without having your project - since you are using a third party tool to convert a VC project you should ask the author of that tool. :D
If you have many projects which you are going to maintain, I suggest that you select one where you can create a cross platform (Windows/Linux) CMake config for which you can reuse for other projects.
Most of the config should be the same for all platforms you are building for - the difference should be which generator is used and what libraries to link in the final executable (if you are building one that is). The generator is specified when running cmake.
In my opinion you should try an out of source build with the following structure:
/$COMMON_DIR/CMakeLists.txt
/CMakeLists.txt
/src/
/build/
/build/vcX
/build/generate_vcX.bat
/build/linux
/build/generate_linux.sh
$COMMON_DIR should contain the CMake code you expect to be common for all you projects - like a function to create a static library for a module which searches for files in /src and another function which can be used to add an executable for certain platform.
The CMakeLists.txt in the root of your project (repository, I assume) should call the functions defined in $COMMON_DIR and possibly add some project specific defines or link flags.

How to generate a .so file

I am writing an extension for the Scratch text editor application on Elementary OS Luna. But the documentation is practically non-existent for extension creation and I have no idea how to proceed after writing my main code for the extension.
I've already written the extension. I cannot use or test it yet as it needs to be "installed". I spent hours looking for docs but they do not exist. I did however, find a comment on the scratch launchpad page that says
Generally you have to generate a pluginname.so file and put it in
lib/scratch/plugins/pluginname with a pluginname.plugin file
Great. This seems like the last part of creating an extension for Scratch. What is a .so file, and how do I generate one? I've already created the other necessary files like the .plugin file and the .vala file.
Yes, I have searched for .so files but all I found were random things about it like using it with C, or C++ headers but obviously that won't work for me, since I'm using Vala?
How do I generate a .so file? What do I generate it from?
I think the The Vala tutorial could be helpful on creating the actual Shared library or Shared Object.
You can use the autotools, cmake or you can compile and link a shared library directly from the command line, quoted from the Vala tutorial:
Compilation and linking using Command Line
Vala is not yet capable of directly creating dynamic or static
libraries. To create a library, proceed with the -c (compile only)
switch and link the object files with your favourite linker, i.e.
libtool or ar.
$ valac -c ...(source files)
$ ar cx ...(object files)
or by compiling the intermediate C code with gcc
$ valac -C ...(source files)
$ gcc -o my-best-library.so --shared -fPIC ...(compiled C code files)...
From the Scratch Wiki
Due to browser security restrictions, Scratch 2.0 cannot interact with
hardware devices directly. Instead, hardware extensions come with a
helper app, a separate application that the user must install and run
on their computer. Scratch communicates with the helper app via HTTP
requests, and the helper app talks to the hardware. In the future,
some extensions may package their helper apps as browser plugins.
Here are the steps for creating and testing a Scratch extension:
Create an extension description file
Create your helper app and start it
Open the Scratch 2 Offline Editor
Import the extension description (shift-click on "File" and select "Import Experimental Extension" from the menu)
The new extension blocks will appear in the More Blocks palette
Test your extension and iterate!
Helper apps can be written in any language that supports server sockets, such as Python, Node.js, Java, C, etc.
Like you I've chased around the wiki but I cannot find an example with source. So all I can do is to address your question generally.
If you look at Build .so file from .c file using gcc command line you'll see how a simple .so can be created. However what code goes into a Scratch extension I don't know. Sorry.
Edit: More googling and I've found a sample from Nathan Dinsmore on GitHub that doesn't use C rather it uses JavaScript, and though it doesn't create a .so extension, it does have what appears to be a full description of creating an extension. He also provides a couple of tutorials.
Edit++ : And here is another sample written in Java.

How to link ".a" fat-static-libs with Apportable?

How do I link ".a" fat-static-libs with Apportable?
In the beginning, I did get a warning,
Warning: Library not found for lib-name. Try adding this to the
'deps' array in the 'add_params' section of your configuration.json
file. Check ~/.apportable/SDK/System for the directory names that
correspond to 'deps' entries.
I did add it to "deps" in the JSON right where it says this:
// A list of dependencies. Typically these correspond to frameworks in the xcode project.
My library isn't a framework, though. It's just a .a static library that has armv7, armv7s, and i386 parts which I assembled using lipo from two libraries (an armv7 and armv7s .a and a i386 .a) built with Xcode. They both use a single framework which is this Boost framework.
Adding it under deps squelched that warning message, but the apportable linker is still giving undefined references, so it is still not properly linking this file.
Now I know that Apportable has to re-jitter all this stuff, since Android won't know what to do with a Mac-executable format, so it's probably got to go pick apart my library and possibly turn it into an ELF-library before final linking. I'm not sure how to go about debugging this at this point, but is this supported at all?
Since you get "library not found" that means Apportable simply can't find the file. Hence the problem is merely with the file's location (or existence) and not what's in the library or how it is built.
The most common issue with dependent targets, especially Xcode projects dropped into other Xcode projects respectively workspaces with multiple projects, is that the resulting output of each target/project goes to different folders. Then Apportable (as well as xcodebuild under some circumstances) can't find the resulting libraries.
First step you should try is to make sure that the target dependencies are set. Select the app target, go to the Build Phases pane and under Target Dependencies add all frameworks and libraries that appear in the list and that your project depends on. This should ensure that the dependent frameworks/libraries do get built - because Xcode's built-in automatic dependency resolution isn't available to command line tools from what I understand. So you need to explicitly specify the dependent projects respectively their output.
If that doesn't help, you can force all targets to write their output to the same folder. Under Build Settings for every target change the Build Products Path (symbolic name: SYMROOT) to the same folder, for example ~/myprojectsbuildoutput
That way even dependent other projects will place their output in the same folder and xcodebuild as well as Apportable (it depends on xcodebuild) will be able to find the library files.
Tip: make sure your project builds successfully on the command line. Open Terminal, cd into the folder where the .xcodeproj bundle is and enter xcodebuild. If xcodebuild fails merely due to validation, disable Validate Built Product under Build Settings of the app target. If xcodebuild fails, Apportable likely isn't going to work either because it depends on xcodebuild. So as a prerequisite make sure that xcodebuild works on your project.
If xcodebuild also gives you "library not found" try calling it with a specific SYMROOT:
xcodebuild SYMROOT=~/myprojectsbuildoutput
If that then works you know you have to update each target's Build Projects Path. From what I know it's not currently possible (or not documented) to pass custom xcodebuild parameters via Apportable, so it needs to be set up in the .xcodeproj itself.

Resources