Cross compile, create a layer or use PIP - yocto

I'm new with Yocto and I have some questions.
1st- I want to run a C++ executable (with OpenCV). I have found two methods:
Cross compiling C++ code and copy the executable and OpenCV ".so"
files to Yocto (It works)
Create a layer with this code
Which method is better and why?
2nd- I want to work with python. I found two methods to include Python Libraries:
Creating a Layer
Adding Pip to yocto and using pip to install
Again I have the same question, which method is better?
Thank you so much!!!

Related

How to use a different compiler for single recipe?

I am building a yocto image for a multicore MCU (A7 + M4). The U-Boot and Linux run on A7. M4 is used for some real time operations.
Currently I am building the M4 part (cmake project) first and bitbake only adds the binary file to the image. What I want to do is to integrate the M4 build into the yocto build process. For this I need to specify a different compiler for the M4 recipe but I can't find any way to do it.
After reading yocto manual I think that writing custom do_compile method should work. But I guess there should be some way to use the existing cmake builder.
I think the multiconfig feature is the one you want, as long as both variants have their own MACHINE definition:
https://www.yoctoproject.org/docs/2.6/mega-manual/mega-manual.html#dev-building-images-for-multiple-targets-using-multiple-configurations

Programming in Swift on Linux

I would like to prepare the environment for working with Swift on Ubuntu 16.04.
I installed Swift and Atom editor.
I installed the Script package, which allows me to run code from the Atom editor.
Generally it is nice when I compile and run one file (Ctrl+Shift+B shortcut).
The problem is when I would like to build a project composed of several files.
Classes defined in the other files (not the one I compile) are not visible (compilation error).
Is it possible to configure the editor to compile and run the entire project?
How to import external library, eg ObjectMapper ?
You can use the Atom package build. It allows you to create custom build commands and such by using common build providers. You can build with a Makefile or JSON or CSON or YAML or even Javascript. It provides enough flexibility that you can build just about anything. Just make your build file so that it points to all the files to build with the right compiler (probably swiftc in your case). With a Javascript build file, you can even specify a command to run before and after the build, say, to run your newly built program.
There's a great open source project I have been watching called Marathon. It's a package manager and they have been Working on a deployment on linux. I'm not sure how much success they have had, but you can follow along here and maybe help out.
https://github.com/JohnSundell/Marathon/issues/37
Edit: It looks like it does work on linux!
git clone https://github.com/JohnSundell/Marathon.git
$ cd Marathon
$ swift build -c release
$ cp -f .build/release/Marathon /usr/local/bin/marathon
For dependencies, you should use Swift Package Manager.
You can check how Vapor is built - it is prepared for build apps for Ubuntu too.
Also, Vapor toolbox would help you with other projects
https://docs.vapor.codes/2.0/getting-started/install-on-ubuntu/
You can build a Swift project using VS Code + Swift Development Environment extension
If steps on the link above are not clear enough, I've put more details in a blog post

How to use OpenCV in Matlab?

I have looked at many resources. I just want a simple way to use the newest OpenCV with Matlab 2017a. MinGW doesn't work and a compiler but I can't seem to get Visual C++ working. I can use OpenCV in Visual Studio but what compiler does Matlab want from me and how do I obtain it?
There is a way to use opencv from matlab without compiling any mex files, and without using the computer vision toolbox.
You can call opencv through matlab via python commands.
1) Download and install the CPython distribution, not Anaconda
2) from the command prompt, install the opencv and other packages you want using the pip command > python -m pip install opencv-python
3) Follow the procedure in the matlab help for ensuring matlab knows where to look for the python installation
4) use the syntax py.cv2.function to call the opencv function
If you keep the data types as python data types in matlab while using the py.cv2 functions there isn't too much of a speed hit.
As #Miki mentions in the their comment, have you checked out this page on the MathWorks site? It has many resources, the main one is the Computer Vision System Toolbox OpenCV Interface. It comes with some examples which would be a good starting point. And if those aren't close to what you want, try another one of the community examples on the File Exchange and trying to make small changes to it.
For each version of MATLAB you can find the supported compilers in the documentation. You can also use -v flag as shown blow to see all the paths where MATLAB looks for a C++ compiler.
mex -setup -v

Error using vl_gmm - Attempt to execute script as function

Hello I want to use Fisher Vector for my SIFT descriptors. I tried to use the function from VL_FEAT. I added the directory in MATLAB and also run vl_startup. It runs successfully but when I try the example
It gives me this error:
Attempt to execute SCRIPT vl_gmm as a function:
C:\vlfeat-0.9.19.tar\vlfeat-0.9.19\vlfeat-0.9.19\toolbox\gmm\vl_gmm.m
Anyone help me how can i solve this?
I have a couple of suggestions for you to get VLFeat working. I'm not sure if you have tried them all, but I will suggest them as we go:
Suggestion #1 - Compiling VLFeat if you downloaded just the source
Did you only download the source files? If you did, did you compile VLFeat first? Specifically, did you run vl_compile first when you downloaded the source?
Functions like vl_gmm require a MEX wrapper to be compiled before you can use the function. If you look in the toolbox/gmm directory, there are two files: vl_gmm.m and vl_gmm.c. vl_gmm.m is simply a MATLAB file that contains the documentation on how to use the function. The actual function is in vl_gmm.c and it is a MEX file. You only get this error if you didn't compile VLFeat first because it's trying to run the .m file by default, which contains nothing but documentation.
As such, make sure you compile VLFeat by running the vl_compile.m script before trying to run your example.
Suggestion #2 - Download the pre-compiled binaries
Alternatively, you can get VLFeat pre-compiled by downloading the binaries: http://www.vlfeat.org/download/vlfeat-0.9.19-bin.tar.gz . If you have trouble compiling the libraries, then download the actual pre-compiled binaries through the link I gave you, then try running vl_setup.m from there.

netbeans c++ deployment

I had developed a small program in netbeans using c++. I need to know how can i deploy/run the package on another linux system
Abdul Khaliq
I have seen your code, you probably missing XML files in the current folder... where the executable is located... paste then and then run as ./your-executable
I recommend that you use a makefile to recompile on your target machine which will ensure that your program is deployed properly.
You should use a makefile as suggested. I know that NetBeans can generate one, but it's been a while since I last did so. Maybe this can help: http://forums.netbeans.org/topic3071.html
Typically, once compiled, your executable will need several libraries. Chance is that those libraries will also be available on the target linux system.
Thus, you can simply copy your executable over to the other system. If you run ldd on your executable, you should see the list of libraries your executable is dynamically loading. Those libraries should be available on the target system as well.
In case your executable makes use of resources such as images and other binary files, you can use a resource system (e.g. Qt Resource System) and compile those binary files into your executable.
The easiest way to test is to do the copy, run
ldd yourExecutable
on the target system. It will tell you if you are missing any library. Install those libraries using the system package manager.
Of course, you also have the option to statically build all libraries into your executable. However, this is not recommended since it makes the executable too large and complicates matters.
What type of package is your netbeans compiler creating? deb,rpm? If you are moving the package to a different linux install you will need to use that distributions package type. Ubuntu - deb
Fedora/Redhat - rpm
etc...
I'm not sure how you change this in netbeans but I'm pretty sure it has the ability to. A google search could help you more.