Linking to .so residing in AAR dependency library package - android-ndk

I have native .so libs packaged into AAR. This AAR package is added from remote repository. App's NDK build requires linking of .so from AAR.
How to specify the path in App's Android.mk to link to pre-built .so in AAR package?

It seems there is no straight forward way of doing this. This requires gradle task which sync AAR package from repository and then extract the binaries to appropriate locations in the application.

Related

Meson build: How to use compiled library instead of downloading it as subproject and build

I am trying to build gstreamer using gst-build: https://gitlab.freedesktop.org/gstreamer/gst-build
Glib is one of the subprojects it is downloading and compile. But I am thinking of replacing it with the previously compiled version. How should I do it in the cross-file? Or there is no way other than hacking meson.build
Thanks
Regrds
It depends on the discovery methods that dependency supports, if it uses pkg-config, it's probably as easy as setting [built-in options]:pkg_config_path in your cross file (or the various $PKG_CONFIG_PATH environment variables) to include the pkg-config file. I'm pretty sure that glib uses pkg-config.

How to install kernel modules using debhelper

I have a Makefile that builds a .ko binary, there is a main package with an application in which there is a directory debian/ with all the necessary files to build the package. The question is where to specify and how, so that when the package is unpacked, the modules are assembled and midprobe is made for them.Found tools like dh_installmodules and dkms but couldn't find any example how to use them.

Where are package library and header files installed?

After downloading and installing a package in Ubuntu, how can I check where the library and header files were written to? I believe that this has something to do with the package's .pc file, but I do not know how to find that file either.
For example, I have downloaded the PCL (Point Cloud Library) package, and then in a sample CMakeLists.txt file, I have been given the following:
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
Where are these environment variables defined, and how can I see them?
If I compiled the libraries from source rather than through a package, will this be any different? Will a .pc file be created automatically?
If you install the package containing the libpcl development files
sudo apt-get install libpcl-dev
You can list the installed files
dpkg -L libpcl-dev
an see the location of all headers.
...
/usr/include/pcl-1.7/pcl/filters/fast_bilateral.h
/usr/include/pcl-1.7/pcl/filters/voxel_grid_covariance.h
/usr/include/pcl-1.7/pcl/filters/voxel_grid_occlusion_estimation.h
/usr/include/pcl-1.7/pcl/filters/median_filter.h
/usr/include/pcl-1.7/pcl/filters/crop_box.h
/usr/include/pcl-1.7/pcl/filters/voxel_grid_label.h
/usr/include/pcl-1.7/pcl/filters/covariance_sampling.h
/usr/include/pcl-1.7/pcl/filters/random_sample.h
/usr/include/pcl-1.7/pcl/filters/normal_refinement.h
/usr/include/pcl-1.7/pcl/filters/project_inliers.h
/usr/include/pcl-1.7/pcl/filters/fast_bilateral_omp.h
/usr/include/pcl-1.7/pcl/filters/clipper3D.h
/usr/include/pcl-1.7/pcl/filters/convolution.h
/usr/include/pcl-1.7/pcl/filters/passthrough.h
/usr/include/pcl-1.7/pcl/filters/conditional_removal.h
/usr/include/pcl-1.7/pcl/filters/impl
/usr/include/pcl-1.7/pcl/filters/impl/frustum_culling.hpp
/usr/include/pcl-1.7/pcl/filters/impl/conditional_removal.hpp
/usr/include/pcl-1.7/pcl/filters/impl/convolution_3d.hpp
/usr/include/pcl-1.7/pcl/filters/impl/voxel_grid_covariance.hpp
/usr/include/pcl-1.7/pcl/filters/impl/fast_bilateral_omp.hpp
/usr/include/pcl-1.7/pcl/filters/impl/project_inliers.hpp
/usr/include/pcl-1.7/pcl/filters/impl/morphological_filter.hpp
/usr/include/pcl-1.7/pcl/filters/impl/crop_box.hpp
/usr/include/pcl-1.7/pcl/filters/impl/covariance_sampling.hpp
/usr/include/pcl-1.7/pcl/filters/impl/local_maximum.hpp
/usr/include/pcl-1.7/pcl/filters/impl/plane_clipper3D.hpp
/usr/include/pcl-1.7/pcl/filters/impl/bilateral.hpp
/usr/include/pcl-1.7/pcl/filters/impl/voxel_grid_occlusion_estimation.hpp
....
By default libraries are installed in /usr/lib and header files will be in /usr/include
Usually extension of the library file is .so and corresponding header file will be .h
gui method for finding installed libraries is open software center->Developer tools-> Libraries

Tell Cmake where to find libraries that I have built from source

I want to build in Ubuntu the PCl 1.7 library from source, so I have downloaded and built from source some of its dependencies: VTK 5.8, Boost 1.51.0 and FLANN 1.7.1.
I have built them in a custom directory. All of them are stored under the directory /home/c/pkg. The structure in that dir is:
For Boost:
boost-1.51.0
build: I told the bjam tool to use this dir for installation. Here's the boost/bin.v2 folder.
include: header files.
lib: .a and .so objects.
For VTK:
vtk-5.8.0
build: where CMake was executed.
include: header files.
lib: shared objects.
For FLANN:
flann-1.7.1
build: CMake was executed here.
include: header files.
lib: shared objects.
share: docs.
Other dependencies like OpenNI or OpenSceneGraph have been built from source and installed system wide (to the /usr/...) dir.
I have tested the installation with a little program and I can compile and link to them. So, everything works fine :)
NOTE BEFORE CONTINUINING: I have previous versions of those libraries, like boost-1.4 or pcl-1.6 installed system-wide with the Synaptics tool. I want to keep them, as I'm only testing the newer versions. That's why I have built the libraries in that custom location.
The problem is that when I want to compile PCL 1.7, by default, CMake only recognizes the system-wide installed libraries. So, how can I tell CMake to use the newer libraries I have built from source?.
Thanks for your time!.

CMake to create a exe and lib with (prepackaged headers and dlls)

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(ImageProc)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_package(PCL 1.2 REQUIRED)
find_package(OpenCV REQUIRED)
add_definitions( -fPIC -Wall -O3)
include_directories(${PCL_INCLUDE_DIRS})
#link_directories(${PCL_LIBRARY_DIRS}) Dont think neccesary..
add_definitions(${PCL_DEFINITIONS})
add_executable (ImageProc svm.cpp ImageProc.cpp testImageProc.cpp)
target_link_libraries (ImageProc ${OpenCV_LIBS} ${PCL_LIBRARIES})
add_library(ImageProcLib STATIC svm.cpp ImageProc.cpp)
target_link_libraries (ImageProcLib ${OpenCV_LIBS} ${PCL_LIBRARIES})
Currently, I run this and open with VS C++ and generate an exe and lib.
The exe runs on my machine.
Current limitations:
When I pass the exe to my friend, he cant run it on his machine as he gets hit by host of missing dlls.
When I use the lib files, to create a new project in VS C++, there is a fatal error in not finding a header file.
I know, I can manually add all the dlls and or package all the header and library files for the lib. But it is definitely cumbersome and ugly also.
Question:
Does CMake offer a way, so that when compiling into
An exe (it will automatically find all the necessary dlls into bin directory)
Into a lib (it will automatically source out all the header files and also the neccesary library for the linking part into the lib directory)
Preparing your package for deployment on other development environment can still be a tough task. You will need to setup your own interfaces/API correctly and will need to deal with cross-dll issues, different runtimes, etc.
However, there are a few tools from CMake at your disposal:
Check out the Install and Export. You can use it to specify (in your CMakeLists.txt) which files are necessary for deployment. This way, you can mark which header-files, but also which targets (libs and exes) should be deployed.
Also take a look at CPack in combination with NSIS, which can be used to build NSIS installers of your project.
Together with the InstallRequiredSystemLibraries and BundleUtilities you can then prepare an install or package target. See also this and this question demonstrating how third-party dlls can be added to such a deployment package.
InstallRequiredSystemLibraries is very useful for appending vcredist to your own package installer, which you will surely need if you are installing your project on a non-development pc.

Resources