Conan.io and netbeans - howto setup a project - netbeans

I'm trying NetBeans as my new IDE for c++. I would love to use conan.io as package manager.
My conanfile.py looks like this (from the conan site):
class MyConanTestProj(ConanFile):
settings = "os", "compiler", "build_type", "arch"
requires = "Protobuf/3.1.0#inexorgame/stable", "Boost/1.64.0#conan/stable" # comma separated list of requirements
generators = "cmake", "txt"
default_options = "Poco:shared=True", "OpenSSL:shared=True", "Boost:shared=True"
def imports(self):
self.copy("*.dll", dst="bin", src="bin") # From bin to bin
self.copy("*.dylib*", dst="bin", src="lib") # From lib to bin
# self.copy('*.so*', dst='bin', src='lib')
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
My CMakeLists.txt:
project(MyTestProj)
cmake_minimum_required(VERSION 2.8.12)
add_definitions("-std=c++14")
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(testProj testProj.cpp)
target_link_libraries(testProj ${CONAN_LIBS})
testProj.cpp: (just to see it compile and link...)
#include <boost/filesystem.hpp>
int main(void) { return 0; }
When I create a build dir and run conan install and so on it works:
mkdir build -p && cd build && conan install .. && cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && cmake --build
But in NetBeans it shows me an unresolved include (netbeans has no idea there conan has stored the boost files).
How to configurate netbeans to use the include paths generated by conan?
Conan created conanbildinfo.cmake and conanbuildinfo.txt with the full paths included but i don't know how to use them in netbeans.
Hope someone could tell me how to setup this correctly (or give me a short example project for netbeans) - Thanks!

Netbeans might be using a particular build folder layout, as previous versions of CLion did in the past, just putting the "temporary" build folders somewhere in the system.
I guess that the CMake execution is complaining about not finding the conanbuildinfo.cmake file, not the Boost headers.
So, the first thing is to know which folder is being used by Netbeans as CMake binary dir. You could add to your CMakeLists.txt:
if(NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message(FATAL_ERROR "Missing conanbuildinfo. Move to ${CMAKE_BINARY_DIR} folder, and run conan install there")
endif()
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
Then, just cd to that folder, conan install with the respective configuration (note that this process may need to be run for different configurations, like Debug/Release).

Related

meson find_program() not finding python program in yocto environment

I have an external application that converted to an exe using pyinstaller. This needs to be added in yocto framework. But the application has a dependency on pylint & pyinstaller. pylint is already part of yocto framework. I used meson.build file in my application and have a recipe file in yocto that will source the entire application from git repo and builds using instructions in meson.build. In my application meson build file uses find_program() to find pylint program installation. It works currently on my laptop, but when I build my application recipe in yocto environment, it is unable to find pylint. Even though I added "python3-pylint" in IMAGE_INSTALL_append.
| Program python3 found: YES (.../usr/bin/python3-native/python3)
| Program python3 (pylint) found: NO
|
| ../git/src/meson.build:10:0: ERROR: python3 is missing modules: pylint
pyinst = find_program('pylint') // as per meson this is probably searching in /usr/local/bin. But this is not the case in yocto. How can I modify find_program() call to find this in the right location in yocto framework. Or is there any method to handle this?
meson.build under source file folder:
# get & run pylint to check for errors
prog = import('python').find_installation('python3', modules: ['pylint'])
if not prog.found()
message('pylint not found')
else
message(prog.path())
cmd = find_program('pylint', prog.path())
message('Running pylint on src files')
foreach each : src_files
run_command(cmd, '--confidence=HIGH', each)
endforeach
endif
project's meson.build
project('proj_name',
['cpp'],
version : '0.1',
license : 'MIT',
default_options: [
'cpp_std=c++11']
)
project_pretty_name = 'proj_name'
project_url = '<git repo of project>'
python = import('python')
python3 = python.find_installation('python3', required: false)
subdir('src')
subdir('tools') # cpp tools
subdir('build')
yocto recipe file:
inherit meson pkgconfig python3native
DEPENDS += "${PYTHON_PN}-distro-native"
DEPENDS += "zlib"
RDEPENDS:${PN} += "${PYTHON_PN}-requests \
${PYTHON_PN}-pylint"
SRC_URI += "<git branch>"
SRCREV = "<src-rev>"
S = "${WORKDIR}/git"
FILES:${PN}:append = " ${bindir}/mesonexe"
Your Meson build requires pylint to be available during compilation, therefore you need to add:
DEPENDS += "${PYTHON_PN}-pylint-native"
and then you will need to ensure the pylint recipe is available in one of your configured Yocto layers. It's in meta-openembedded/meta-python.
Finally, the python3-pylint recipe and one of its dependencies (python3-astroid) do not have native support enabled, so you'll need to create the followin .bbappends as well:
# python3-pylint_%.bbappend
BBCLASSEXTEND += "native"
# python3-astroid_%.bbappend
BBCLASSEXTEND += "native"
You should then see the following line in the Meson output:
Program pylint found: YES (.../recipe-sysroot-native/usr/bin/pylint)
As a suggestion - if this recipe is building your own source code, I'd suggest linting the code as it is pushed into the repository (via a CI job), rather than at compile-time. This will reduce the dependencies required to build your project.
Of course, there would still be an optional Meson target for developers to lint their code before they push new code. Perhaps something that is enabled for non-release builds by default.

Yocto custom application through custom layer does not copy source files to destination rootfs

I am trying to install a custom application on my Yocto build.
I currently use a Raspberry Pi 4 64 bit setup, for which I want PyQt5 to display an application directly on the frame buffer (so no windowing manager or desktop envoirement).
My current build with Yocto completes and boots on the Raspberry Pi. All the Qt5 libraries are also present in the root fs after the bitbake build.
Although, I'm having problems getting a custom layer, that adds a custom recipe with a custom application to also copy over to the destination root fs.
My custom layer is called 'meta-rpikms' with recipe 'recipes-kms-qt-app' which contains the application bb files. This files is called 'basicquick_0.1.bb' and has the following contents (this test application tries to add a EGLFS friendly Qt5 applicaiton, i'll try PyQt5 later):
SUMMARY = "Simple Qt5 Quick application"
#SECTION = "examples"
LICENSE = "MIT"
#PACKAGE_ARCH = "all"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
DEPENDS += "qtbase qtdeclarative qtquickcontrols2"
SRCREV = "${AUTOREV}"
SRC_URI = "git://github.com/shigmas/BasicQuick.git"
S = "${WORKDIR}/git"
require recipes-qt/qt5/qt5.inc
do_install() {
install -d ${D}${bindir_native}
install -m 0755 BasicQuick ${D}${bindir_native}
}
FILES_${PN} += "${bindir_native}"
When I bitbake the custom layer of my meta-rpikms (called 'qt5-kms-rpi-image'), it does compute. When I take a look at the 'image_initial_manifest' file, my custom application does show up, suggesting that it does compile and try to install the application:
# This file was generated automatically and contains the packages
# passed on to the package manager in order to create the rootfs.
# Format:
# <package_type>,<package_name>
# where:
# <package_type> can be:
# 'mip' = must install package
# 'aop' = attempt only package
# 'mlp' = multilib package
# 'lgp' = language package
mip,basicquick
mip,bluez5
mip,bridge-utils
mip,hostapd
mip, bla bla bla etc etc etc.
And if I take a look in: '~/builds/pyqt5_try1/poky/rpi64-build/tmp/work/cortexa72-poky-linux/basicquick/0.1-r0', the expected files do show up. Also suggesting that it does atleast build the application. This makes the think that the 'install' arguments in my .bb file are pointing to the wrong folder.
In my basicquick_*.bb file this is to make the directory and install (copy) the built files:
install -d ${D}${bindir_native}
install -m 0755 BasicQuick ${D}${bindir_native}
I used the 'bitbake -e' command to trace the variable D and bindir_native:
D="/home/mats/builds/pyqt5_try1/poky/rpi64-build/tmp/work/raspberrypi4_64-poky-linux/qt5-kms-rpi-image/1.0-r0/image"
bindir_native="/usr/bin"
This seems okay at first glance, but when I manually follow the destination of the variable 'D', there is no 'images' folder created. I also wonder why everybody installs their custom applications on ${D}/usr/bin? Should this not be written to the build/tmp/deploy directory? Or am I missing a step here.
So, in this 'qt5-kms-rpi-image/1.0-r0' folder, there is a folder called 'deploy-qt5-kms-rpi-image-image-complete', which contains a rootfs. But there also is a rootfs folder in the 'qt5-kms-rpi-image/1.0-r0' folder. Both of these rootfs's do not contain any mention of my basicquick application, or a BasicQuick folder being created in /usr/bin.
Also, the rootfs found in the "build/tmp/deploy/images/raspberrypi4-64/qt5-kms-rpi-image-raspberrypi4-64.tar.bz2" does not contain any mention of the basicquick application being present in the filesystem.
Does anybody have any clues on what I am missing? Am I just not copying my files to the correct location? Or does the final deploy image end up somewhere else from where I am expecting it?
Thanks in advance.
With kind regards,
Mats de Waard

VS Code: Include External OpenCV Install with CMake Tools

I am trying to set up an OpenCV C++ project using VS Code. I am able to compile the project just fine from the command line, by manually generating CMakeLists.txt:
# CMakeLists.txt
cmake_minimum_required(VERSION "3.17")
project(simple-demo)
# set OpenCV_DIR variable equal to the path to the cmake install
set(OpenCV_DIR /Users/tstoff/git/opencv/install/lib/cmake/opencv4)
# Tell compiler to use C++ 14 features
set(CMAKE_CXX_STANDARD 14)
# configure the necessary common CMake environment variables
# needed to include and link the OpenCV program into this
# demo project, namely OpenCV_INCLUDE_DIRS and OpenCV_LIBS
find_package( OpenCV REQUIRED )
# tell the build to include the headers from OpenCV
include_directories( ${OpenCV_INCLUDE_DIRS} )
# specify the executable target to be built
add_executable(simple-demo main.cpp)
# tell it to link the executable target against OpenCV
target_link_libraries(simple-demo ${OpenCV_LIBS} )
which I can build using make and cmake .. from a build directory. But I want to use the power of the VS Code CMake Tools library! How do I add external libraries to VS Code projects, preferably using CMake Tools? Many thanks!

How do I link a static lib to a yocto autotools project in Eclipse

I have created a Yocto autotools project in Eclipse (based on a Hello World project).
I wanted to separate my code into a number of libs and then link them in a form of static libs (.a) to my project.
Now I have one app and a number of static libs. However, no matter what I try I can't get my code to compile. Each separate lib compiles and produces a .a file, but my app doesn't.
After searching the web I have a possible solution - add a direct link to my static libs:
MyApp_CPPFLAGS="-I$LOCATION"
MyApp_LDADD="/home/xxx/workspace/MyApp/Encoding2/Debug/libEncoding2.a"
This is my Makefile.am file, where libEncoding2.a exist in that path.
The error I get is:
make[2]: *** No rule to make target `"/home/xxx/workspace/MyApp/Encoding2/Debug/libEncoding2.a"', needed by `MyApp'. Stop.
I already built the lib so I am not sure why a make try is even needed.
Any help will be appreciated.
Because you use static library in your recipes, you can make a soft link to the library in your project source folder, i.e., hello-world-0.1, using following command to link to your static library
ln -s /home/xxx/workspace/MyApp/Encoding2/Debug/libEncoding2.a
and then edit your bb file, hello-world_0.1.bb, adding the source path to your URL
SRC_URI = " \
file://libEncoding2.a \
file://hello-world.c \
"
and in the do_compile block, using follow command to compile your project
do_compile() {
${CC} hello-world.c libEncoding.a -o hello-world
}
do_install() {
install -d ${D}${bindir}/Hello
install -m 0755 enet ${D}${bindir}/Hello
}
After you bitbake your project
bitbake hello-world
and run mkefidisk.sh, you can find the hello-world in /usr/bin/Hello/hello-world. Hope this hint can help you.
BTW, I am not familiar with autotools, I just use make to bitbake the recipes. And your static library should also be created in Yocto not in Eclipse I think. So I think your path for the static library maybe not correct, it should locate in ~/yocto/build/tmp/... or some where like this. In my case, it was located in ln -s ~/yocto/build/tmp/sysroots/intel-corei7-64/usr/lib/libEncoding.a depends on your target environment.
Depending on whether you're using libtool or not, you should have either a noinst_LTLIBRARIES or noinst_LIBRARIES list of targets, respectively. This should only include the name of your library (libEncoding2.la or libEncoding2.a.)
You should never use a full path for this, and you should not quote Make variables, so what you were looking for is
MyApp_CPPFLAGS = -I$LOCATION
MyApp_LDADD = libEncoding2.la # or .a
And that would work.
But on the other hand it seems like you should take some time to understand how autotools work, as it might not be what you're looking for. With a grain of salt you can take my Autotools Mythbuster as a starting point.

cmake to eclipse project conversion issue

I am trying to create an eclipse project from a cmake project .
I used the following command
cmake -G "Eclipse CDT4 - Unix Makefiles" ./`
it gives the following error
CMake Error at CMakeLists.txt:119 (find_package):
By not providing "FindGlib.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Glib", but
CMake did not find one.
Could not find a package configuration file provided by "Glib" (requested
version 2.28) with any of the following names:
GlibConfig.cmake
glib-config.cmake
Add the installation prefix of "Glib" to CMAKE_PREFIX_PATH or set
"Glib_DIR" to a directory containing one of the above files. If "Glib"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
I have glib installed . actually it couldn't resolve the path i guess. wherever find is there in cmake file , it is giving the smiler errors. please i suggest a way out, i badly need to load this project in cmake. Thanks.
Here is line 119 where error message is pointing
find_package(Glib 2.28 REQUIRED)
include_directories(${Glib_INCLUDE_DIRS})
list(APPEND LIBS ${Glib_LIBRARIES})
add_definitions(${Glib_DEFINITIONS})
When you call find_package(MyPackage) in a CMake file, it tries to find a FindMyPackage.cmake configuration in its system path (/usr/share/cmake-2.8/Modules on my Ubuntu box), or in the directory you did specify as CMAKE_MODULE_PATH).
The solution to your problem is to create a directory for modules in your source tree (e.g. CMakeModules), put in it a FindGlib.cmake file that you can find using Google, and add
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
in your CMakeLists.txt before the actual call to find_package.
(your problem is not related to the Eclipse generator, you could remove that from the title of the question).