cmake ignoring include directory when cross compiling - linux

I am perplexed and would like your help.
I am cross compiling a project that requires ifaddrs.h, but no matter how I try to specify the location of the file, it never finds it. It is located at /usr/include/ifaddrs.h and I have used the code below to try to point to it. (Granted this is the host system's file, but that should not matter in this context. I have also put the file in the target systems include directory: /tmp/toolchain/include with no different results). And the message call does print /usr/include
If, however, I put the file in ${CMAKE_CURRENT_SOURCE_DIR}/../include
it is found. It is there, I can see it -- why not cmake?
FIND_FILE( IFADDRS ifaddrs.h PATH /usr/include )
get_filename_component(if_path ${IFADDRS} PATH)
message( "IFADDRS = " ${if_path} )
include_directories( ${if_path} )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../include )
Changing the code above to this:
include_directories( BEFORE SYSTEM /usr/include )
and running make VERBOSE=1 gives this:
[ 18%] Building C object CMakeFiles/cpcommon_lib.dir/eui48.c.o
/tmp/toolchain/arm-linux-uclibc/bin/gcc -DPJ_AUTOCONF=1 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I/home/bp/MySnapCam/projects/Communication/trunk/cpcommon/src/../include -I/home/bp/MySnapCam/projects/Communication/trunk/cpcommon/src/../../pjproject/pjlib-util/include -I/home/bp/MySnapCam/projects/Communication/trunk/cpcommon/src/../../pjproject/pjlib/include -I/home/bp/MySnapCam/projects/Communication/trunk/cpcommon/src/../../pjproject/pjnath/include -I/usr/include/w32api -I/usr/X11R6/include -I/usr/include/X11 -I/usr/pkg/include -I/opt/csw/include -I/opt/include -I/usr/openwin/include -I/home/bp/MySnapCam/projects/Communication/trunk/cpcommon/src/../../cjson -o CMakeFiles/cpcommon_lib.dir/eui48.c.o -c /home/bp/MySnapCam/projects/Communication/trunk/cpcommon/src/eui48.c
In file included from /home/bp/MySnapCam/projects/Communication/trunk/cpcommon/src/eui48.c:26:
/home/bp/MySnapCam/projects/Communication/trunk/cpcommon/src/impl/eui48_unix.c:14:21: ifaddrs.h: No such file or directory
There is no /usr/include/ in the include paths. It is also not in the flags.make files either.

Related

Shared Libraries not linking together after installation with CMake

I have run into a rather strange problem with Google Tests.
In my project, I am using externalProject_add in order to download google tests and add them into my project. In my function, I believe I am asking for the project to be built, and then installed into a specific directory:
ExternalProject_Add(gTest_download
URL ${GTEST_url}
URL_HASH ${GTEST_hash}
UPDATE_COMMAND ""
BUILD_COMMAND cmake --build . --target install
CMAKE_CACHE_ARGS
-DCMAKE_C_COMPILER:PATH=${Compiler_C}
-DCMAKE_CXX_COMPILER:PATH=${Compiler_CXX}
-DBUILD_SHARED_LIBS:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=<BINARY_DIR>/installation
)
I can then tell the program where all the source files are living with this:
ExternalProject_Get_Property(gTest_download BINARY_DIR)
set(gTest_LIBRARY_DIR ${BINARY_DIR}/installation/lib CACHE INTERNAL "Google Test Binary Dir")
set(gTest_INCLUDE_DIR ${BINARY_DIR}/installation/include CACHE INTERNAL "Google Test Include Dir")
However, when I try to run a cmake test with protobufs I get the run time error:
./Protobuf_test: error while loading shared libraries: libgmock.so.1.11.0: cannot open shared object file: No such file or directory
Which is super odd, because I know I specifically told the program where to find the libraries in the same externalProject_add file:
set(gTest_LIBRARIES
${gTest_LIBRARY_DIR}/${prefix}gmock${suffix}
${gTest_LIBRARY_DIR}/${prefix}gmock_main${suffix}
${gTest_LIBRARY_DIR}/${prefix}gtest${suffix}
${gTest_LIBRARY_DIR}/${prefix}gtest_main${suffix}
CACHE INTERNAL "Google Test Libraries"
)
Where ${prefix} is "lib" and ${suffix} is ".lib". And I make sure to link them in my CMakeLists.txt file properly by doing target_link_libraries(Protobuf_test ${gTest_LIBRARIES} ${protobuf_LIBRARIES}) ex:
CUSTOM_PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDS ${CMAKE_CURRENT_LIST_DIR} hello.proto)
include_directories(
${protoBuf_INCLUDE_DIR}
${gTest_INCLUDE_DIR}
${CMAKE_CURRENT_LIST_DIR}
)
add_executable(Protobuf_test protobuf_test.cc ${PROTO_SRCS} ${PROTO_HDS})
add_dependencies(Protobuf_test
gTest_download
protoBuf_download
)
target_link_libraries(Protobuf_test
${gTest_LIBRARIES}
${protoBuf_LIBRARIES}
)
add_test(NAME testing_protobuf COMMAND Protobuf_test)
So I went into the installation folder which is located in d/linuxBuild/lib/src/gTest_download-build/installation/lib and confirmed it exists there. I then ran ldd libgmock.so and got the following output:
libgtest.so.1.11.0 => not found
Which I thought was odd as well. gtest is in the same directory! How is that possible? So I ran ldd on gmock_main:
libgmock.so.1.11.0 => not found
libgtest.so.1.11.0 => not found
So now I have two libraries that are in the same directory however they cannot be found. Confused, I decide to go to where the libraries should have originally installed to and copied over from. So two folders up: d/linuxBuild/lib/src/gTest_download-build. I then go into that folders lib folder and verify the libraries are there. I then run the same ldd command on gmock:
libgtest.so.1.11.0 => /mnt/d/linuxBuild/lib/src/gTest_download-build/lib/libgtest.so.1.11.0 (0x00007fb651729000)
I'm confused by this and again, run it on gmock_main:
libgmock.so.1.11.0 => /mnt/d/linuxBuild/lib/src/gTest_download-build/lib/libgmock.so.1.11.0 (0x00007f58b0db3000)
libgtest.so.1.11.0 => /mnt/d/linuxBuild/lib/src/gTest_download-build/lib/libgtest.so.1.11.0 (0x00007f58b0c9c000)
I am sorry for the lengthy question, but I need to know what happened here? Why is it when I install the libraries the links break from each other and they don't know their locations compared to the ones in the original installation path? Did their symbolic links break? Did I do something incorrectly in the CMake build? I'm scratching my head on this problem since I have never encountered this before. Any advice would be greatly appreciated.
Forget about externalProject_add and use FetchContent / FetchContent_MakeAvailable, especially when dealing with CMake-ready projects:
See https://cmake.org/cmake/help/latest/module/FetchContent.html for details
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
)
FetchContent_MakeAvailable(googletest)
# ...
target_link_libraries(Protobuf_test
PRIVATE
gmock_main
${protoBuf_LIBRARIES}
)
This way, you are linking against the gmock_main target, which will set up your libraries, includes, and any indirect dependencies correctly like any cmake project added via add_subdirectory() or find_package().

Cmake vcpkg and Bullet

I am very much lost here and could really use some help.
I'm working on an Honours project for next year that involves a physics simulation using Bullet and Vulkan for rendering. After a few months of work I have most of the project functioning. It needs a lot of refactoring and cleaning which will be the next stage.
I have been using a makefile but wish to migrate to CMake for a few reasons. Mainly because it seems to be the standard and because I want to compile for different OS's in the future (I'm running Linux but may need to deploy on Windows or Mac). Finally, I was recompiling the whole project for even a small change, which was beginning to become a problem as I started Unit Testing more.
The old makefile is as follows :
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
OWN_INCLUDES = \
-I$(ROOT_DIR)/src/Domain \
-I$(ROOT_DIR)/src/Vk \
-I$(ROOT_DIR)/src/Ui \
-I$(ROOT_DIR)/src/Service
ADD_INCLUDES = \
-I/opt/bullet3-master/src \
-I/opt/vk_mem_alloc \
-I/opt/stb_image \
-I/opt/tiny_obj_loader/ \
-I/opt/imgui-vulkan/
BULLET_INCLUDE_PATHS_LIBS = -L/opt/bullet3-master/src/BulletCollision/ \
-L/opt/bullet3-master/src/BulletDynamics/ \
-L/opt/bullet3-master/src/LinearMath/ \
-lBulletDynamics -lBulletCollision -lLinearMath
VULKAN_SDK_PATH = /opt/Vulkan_SDK/1.2.162.1/x86_64
CFLAGS = -std=c++17 -I$(VULKAN_SDK_PATH)/include $(OWN_INCLUDES) $(ADD_INCLUDES)
LDFLAGS = -L$(VULKAN_SDK_PATH)/lib `pkg-config --static --libs glfw3` -lvulkan $(BULLET_INCLUDE_PATHS_LIBS)
IMGUI_CPP_PATHS = /opt/imgui-vulkan/*.cpp
OWN_CPP_PATHS = src/*.cpp src/Domain/*.cpp src/Vk/*.cpp src/Ui/*.cpp src/Service/*.cpp
###### Unit Testing Paths
UNIT_TEST_INCLUDE = -I/opt/catch-header/
UNIT_TESTS_PATH = $(ROOT_DIR)/unit_tests/*.cpp
VulkanRun: $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS)
g++ $(CFLAGS) -o VulkanRun $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS) $(LDFLAGS)
Unit_Test: $(UNIT_TESTS_PATH) src/Domain/*.cpp src/Vk/*.cpp src/Ui/*.cpp src/Service/*.cpp $(IMGUI_CPP_PATHS)
g++ $(UNIT_TEST_INCLUDE) $(CFLAGS) -o Unit_Test $(UNIT_TESTS_PATH) src/Domain/*.cpp src/Vk/*.cpp src/Ui/*.cpp src/Service/*.cpp $(IMGUI_CPP_PATHS) $(LDFLAGS)
VulkanDebug: $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS)
g++ $(CFLAGS) -g -o VulkanDebug $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS) $(LDFLAGS)
VulkanOpt: $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS)
g++ $(CFLAGS) -O3 -o VulkanOpt $(OWN_CPP_PATHS) $(IMGUI_CPP_PATHS) $(LDFLAGS)
.PHONY: test clean
run: VulkanRun
LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib
VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/vulkan/explicit_layer.d
./VulkanRun
test: Unit_Test
LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib
VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/vulkan/explicit_layer.d
./Unit_Test
debug: VulkanDebug
LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib
VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/vulkan/explicit_layer.d
optimise: VulkanOpt
LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib
VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/vulkan/explicit_layer.d
./VulkanOpt
7 clean:
rm -f VulkanRun
rm -f Unit_Test
rm -f VulkanDebug
rm -f VulkanOpt
I installed cmake using the latest install script for 3.21.0.
I created a CMakeLists.txt in the root of the project as follows :
cmake_minimum_required(VERSION 3.21.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
project(LanderSim)
file(GLOB_RECURSE SOURCES "src/**.cpp")
add_executable(main ${SOURCES})
find_package(Bullet CONFIG REQUIRED)
if (BULLET_FOUND)
include_directories(${BULLET_INCLUDE_DIRS})
target_link_libraries(main PRIVATE LinearMath Bullet3Common BulletDynamics BulletSoftBody)
endif (BULLET_FOUND)
After many hours of trying I decided to try vcpkg. Following the install instructions from bullet :
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install bullet3
This resulted in errors of
CMake Error at CMakeLists.txt:11 (find_package):
Could not find a package configuration file provided by "Bullet" with any
of the following names: BulletConfig.cmake bullet-config.cmake
Looking in CMakeCache.txt i see "Bullet_DIR:PATH=Bullet_DIR-NOTFOUND"
I found the BulletConfig.make file in "/home/ash/vcpkg/installed/x64-linux/share/bullet3" and in "/home/ash/vcpkg/packages/bullet3_x64-linux/share/bullet3" and set the MakeCache.txt var Bullet_DIR:PATH to these variables (tested one at a time).
Running again I get CMake set_and_check() function not recognised. Or something to that effect. Looking in the BulletConfig.make file I see these set_and_check() functions aren't recognised by the linter. I cant find any information about them being deprecated online but I assume this is the case. So I change to set() and CMake then succeeds and builds its files.
Running make I then get an error.
fatal error: btBulletDynamicsCommon.h: No such file or directory,
#include <btBulletDynamicsCommon.h>
I tried prepending bullet/ to the include path as others had this issue but it causes the same error.
So I must be doing something wrong and I'm obviously not understanding the process that CMake uses to add includes and link libraries. I'm sure, given the popularity of CMake, that there must be something obvious. But I've spent about 10 hours over a few days searching and trying different variations and I'm starting to get very frustrated.
I've bounced off CMake before (hence why I was working with a makefile for months), but I'm determined to do this properly. I just could really use some help if anyone knows how to get CMake to generate a makefile that can see a package installed with vcpkg.
Or indeed if the vcpkg of Bullet is out of date, then a way to link and include it with CMake alone would be great. I just thought vcpkg would be easier as it provides a cleaner file structure by default as well as a CMake config file.
Thanks.
EDIT1
I've used 'cmake .' and 'cmake . -DCMAKE_TOOLCHAIN_FILE=/home/ash/vcpkg/scripts/buildsystems/vcpkg.cmake' to build the makefile. Both result in the same missing headers errors when calling make.
EDIT2
All CMake files were removed from the project (except CMakeLists.txt) before each call to cmake to ensure no values were stored there.
EDIT3
Poked around a bit more. Here is the BulletConfig.cmake file :
#
# BulletConfig.cmake(.in)
#
# Use the following variables to compile and link against Bullet:
# BULLET_FOUND - True if Bullet was found on your system
# BULLET_USE_FILE - The file making Bullet usable
# BULLET_DEFINITIONS - Definitions needed to build with Bullet
# BULLET_INCLUDE_DIR - Directory where Bullet-C-Api.h can be found
# BULLET_INCLUDE_DIRS - List of directories of Bullet and it's dependencies
# BULLET_LIBRARIES - List of libraries to link against Bullet library
# BULLET_LIBRARY_DIRS - List of directories containing Bullet' libraries
# BULLET_ROOT_DIR - The base directory of Bullet
# BULLET_VERSION_STRING - A human-readable string containing the version
set(PACKAGE_PREFIX_DIR /home/ash/installed/x64-linux)
set ( BULLET_FOUND 1 )
set ( BULLET_USE_FILE "${PACKAGE_PREFIX_DIR}/share/bullet3/UseBullet.cmake" )
set ( BULLET_DEFINITIONS "" )
set ( BULLET_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include/bullet" )
set ( BULLET_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/bullet" )
set ( BULLET_LIBRARIES "LinearMath;Bullet3Common;BulletInverseDynamics;BulletCollision;BulletDynamics;BulletSoftBody" )
set ( BULLET_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib" )
set ( BULLET_ROOT_DIR "${PACKAGE_PREFIX_DIR}" )
set ( BULLET_VERSION_STRING "3.17" )
# Load targets
if(NOT TARGET Bullet3Common)
file(GLOB CONFIG_FILES "${PACKAGE_PREFIX_DIR}/share/bullet3/*Targets.cmake")
foreach(f ${CONFIG_FILES})
include(${f})
endforeach()
set(_DIR)
endif()
As stated before a few of the set functions were set_and_check(). So I changed to set() as apparently cmake 3.21 has no set_and_check() function. After a little testing by printing message(), i found that PACKAGE_PREFIX_DIR was not being set anywhere. So that is why I've set it explicitly in this file. The variables are now set correctly as reported by message() in the CMakeLists.txt file. But still it make cannot find the header files.
EDIT4
I created an empty project and ran through each library I wanted to include. Everything works except for Bullet3. However it does now see the header files. What changed between the two CMakeFiles? Nothing as far as I can tell. I'll need to find out because I have to port this project over but in the meantime this is another issue with the package.
from /home/ash/projects/C++/CMakeImportTests/src/main.cpp:22:
/home/ash/vcpkg/installed/x64-linux/include/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h:77:10:
fatal error: LinearMath/btVector3.h: No such file or directory
77 | #include "LinearMath/btVector3.h"
I think this is the same issue as described #7877
If i remove all includes of Bullet but leave the CMakeList.txt untouched, we get this error:
[ 50%] Building CXX object CMakeFiles/main.dir/src/main.cpp.o
[100%] Linking CXX executable main
/usr/bin/ld: cannot find -lLinearMath
/usr/bin/ld: cannot find -lBullet3Common
/usr/bin/ld: cannot find -lBulletDynamics
/usr/bin/ld: cannot find -lBulletSoftBody
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/main.dir/build.make:104: main] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/main.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Is this a clue that some environment variable is not set?
EDIT5
There seems to be an ordering dependency for the target_link_library call. The suggested usage is:
target_link_libraries(main PRIVATE LinearMath Bullet3Common BulletDynamics BulletSoftBody)
Checking bullet.pc in the libs/ directory i found
Libs: -L${libdir} -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath
So I tried rearranging and following the pattern:
target_link_libraries(main PRIVATE BulletSoftBody BulletDynamics BulletCollision Bullet3Common LinearMath)
Additionally there was also a need to manually link directories.
target_link_directories(main PRIVATE ${BULLET_LIBRARY_DIRS})
This now compiles without error in my test project. It seems LinearMath must be after most of the other libraries (although it can be before Bullet3Common it seems).
For some reason it's still not finding the header files when I copy the exact same CMake commands over to my main project. So I'm not free of this yet.
I should say that I was able to remove the change I made to BulletConfig.cmake of setting PACKAGE_PREFIX_DIR statically.
So just to recap my issue. A small test project works and I can use bullet and number of other libraries that I use in my main project. But if i copy this working CMakeLists.txt to my main project it can no longer find the headers and throws this error :
btBulletDynamicsCommon.h: No such file or directory
8 | #include <btBulletDynamicsCommon.h>
Bullet_DIR:PATH=/home/ash/vcpkg/installed/x64-linux/share/bullet3 is the same in both cases.
After all that.
The set_and_include() error is a known issue and mathisloge over at vcpkg git said the Bullet package needs to be updated. The workaround is to change the calls to set().
The ordering of the target libraries is important. The suggested way in the Bullet vcpkg package is :
target_link_libraries(main PRIVATE LinearMath Bullet3Common BulletDynamics BulletSoftBody)
But this fails to compile. It should be:
target_link_libraries(main PRIVATE BulletSoftBody BulletDynamics BulletCollision Bullet3Common LinearMath)
Also had to tell cmake the link directories using :
target_link_directories(main PRIVATE ${BULLET_LIBRARY_DIRS})
Then I still had header missing errors. But after a restart things just started working again. Hopefully there is enough here to help someone if they hit similar problems.

CMake not finding .so library

I've read several threads (and docs) on including .so libraries with CMake, but it doesn't appear to me that I've fallen into the errors that I've read about, namely:
supplying an incorrect library name
specifying an incorrect path
So what am I doing amiss? I'm working in Android Studio, and I have a cmake file in my app directory. It can find some things but not the .so file in question, whose path is:
app/src/main/cpp/libusb-android-open2/android/libs/armeabi/libusb1.0.so
Here's my cmake file:
# This succeeds
add_library( demo-libusb SHARED src/main/cpp/demo-libusb.cpp )
# This succeeds
find_library( log-lib log )
if (log-lib)
message(WARNING "HAS loglib") # This message gets printed
else(log-lib)
message(SEND_ERROR "NO loglib")
endif(log-lib)
# This fails
link_directories( src/main/cpp/libusb-android-open2/android/libs/armeabi )
find_library( usb-lib NAMES usb1.0 libusb1.0.so )
if ( usb-lib )
message(WARNING "HAS libusb")
else( usb-lib )
message(SEND_ERROR "NO libusb") # This message gets printed
endif( usb-lib )
I have also tried:
find_library( usb-lib NAMES libusb1.0.so usb1.0 PATHS
src/main/cpp/libusb-android-open2/android/libs/armeabi
src/main/cpp/libusb-android-open2/android/libs/armeabi-v7a
)
Command link_directories doesn't affect on find_library search paths.
You may use PATH or HINT options for find_library, or set variables which are explicitely noted in its search algorithm.

CMake QNX crosscompile find_path and find_library works on Linux but not on Windows

# Try to find IntelIPP
# Once done, this will define
#
# Ipp_FOUND - system has IntelIPP
# Ipp_INCLUDE_DIR - the IntelIPP include directories
# Ipp_LIBRARY - link these to use IntelIPP
include(LibFindMacros)
set(IPP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libs/intel/linux/intel_ipp)
# Include dir
find_path(Ipp_INCLUDE_DIR
NAMES ipp.h
PATHS ${IPP_ROOT_DIR}/include
)
find_library(Ipp_IRC_LIB
NAMES irc
PATHS ${IPP_ROOT_DIR}/lib/ia32
)
find_library(Ipp_MAT_LIB
NAMES ippm
PATHS ${IPP_ROOT_DIR}/lib/ia32
)
list(APPEND Ipp_LIBRARY ${Ipp_IRC_LIB} ${Ipp_MAT_LIB} )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set Ipp_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(Ipp DEFAULT_MSG
Ipp_LIBRARY Ipp_INCLUDE_DIR)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library
set(Ipp_INCLUDE_DIRS ${Ipp_INCLUDE_DIR})
set(Ipp_LIBRARIES ${Ipp_LIBRARY})
My FindIpp.cmake script is shown above. On windows, I get
-- Could NOT find IPP (missing: IPP_INCLUDE_DIR IPP_LIBRARY). I've tested this under Linux and it works without any issues. In both cases, I'm trying to cross-compile using the QNX Momentics toolchain.
The ${CMAKE_CURRENT_SOURCE_DIR} is the location of the 'root' script which does include(FindIpp).
I've looked at the output of ${CMAKE_CURRENT_SOURCE_DIR} and the output of the relative paths to make sure that the files and folders exist in the reported paths. ${CMAKE_CURRENT_SOURCE_DIR}/../libs/intel shows up as C:/../libs/intel.
I use CMake 3.5 on Linux and CMake 3.6.1 on Windows 7.
From a cmd prompt, I could type in 'cd c:/libs/intel' without any issues.
I tried hardcoding the IPP_ROOT_DIR path to set(IPP_ROOT_DIR C:/libs/intel/linux/intel_ipp), tried adding quotes around the path, appended CACHE PATH "Description" to the set call. None of these worked.
I tried -GNinja, -G "MinGW Makefiles" and -G "Unix Makefiles". Still came up with:
-- Could NOT find IPP (missing: IPP_INCLUDE_DIR IPP_LIBRARY)
-- Could NOT find Mkl (missing: Mkl_LIBRARY Mkl_INCLUDE_DIR)
-- Could NOT find Boost (missing: Boost_LIBRARY Boost_INCLUDE_DIR)
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_MAIN_LIBRARY)
Copying and pasting contents from individual files like FindIpp.cmake into the main CMakeLists.txt file finds the libraries, but not the path to includes. Now I've also added list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SRC_DIR}/CMake/Modules) to find my module files. If I remove that line, cmake throws an error at include(FindIpp).
Is there anything obvious that I'm doing wrong? Also, is this the way to write a find_library or find_path? Thanks
So the correct way to cross-compile to QNX from Windows and Linux:
cmake -DCMAKE_SYSTEM_NAME="QNX" -DCMAKE_SYSTEM_VERSION="660" -DCMAKE_SYSTEM_PROCESSOR="x86" -GNinja path_to_project
Where 660 is QNX version 6.6.0. I was using my own Toolchain file for QNX. This is not necessary. There is one already provided under share/cmake-/Modules/Platform. So as long as we define the above CMAKE variable somewhere, you should be good to go.

/lib/libc.so.0 error with buildroot

It is seen that sometimes if we select a package we get this strange error from buildroot saying cannot find /lib/libc.so.0 . Further probing it is defined in libc.so found in $(STAGING_DIR)/usr/lib ; if we change the absolute path
GROUP (/lib/libc.so.0 /usr/lib/uclibc_nonshared.a AS_NEEDED (/lib/ld-uClibc.so.0 ) )
to relative path meaning something like below :
GROUP ( ../../lib/libc.so.0 ../usr/lib/uclibc_nonshared.a AS_NEEDED (../../lib/ld-uClibc.so.0 ) )
compilation goes thro' fine. Q? is whether this is the right way to get around this problem ? or we need to do some change so that this file gets generated properly ?; Thanks for any solutions.
Are you using an External Toolchain? Does it happen with packages that don't use the autotools Makefile?
I think you may need to pass the TARGET_(CFLAGS|LDFLAGS) in the packages .mk files.
something like:
CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(PACKAGE_SRCDIR)

Resources