This service is available only in Japanese-language.

sdkでCMakeエラー

とあるBSP(yocto)でsdkを構築し、サンプルソフト(helloworld)をクロスコンパイルしようとしたところ、CMakeエラーが出ました。

・HostPCの再起動
・/opt/poky/2.5.2/の削除と再度shの実行
・helloworldのbuildフォルダ削除

を繰り返しましたが、改善されませんでした。

本件に関して、何か知見がございましたらご教授いただけないでしょうか?

############################################################
■構築手順
local.confにSDKMACHINE ?= "x86_64"を追記
bitbake core-image-weston-sdk -c populate_sdk
sh ./poky-glibc-x86_64-core-image-weston-sdk-aarch64-toolchain-*.sh
HostPC再起動

■hello world
sdk
|- helloworld
|- CMakeLists.txt
|- hello.cpp
|- hello.hpp
|- main.cpp

---------------------------------------------------------------------

CMakeLists.txt
# CMake Version
cmake_minimum_required(VERSION 2.8)
# Project name & Language
project(helloworld CXX)
# source file & generated file
add_executable(a.out main.cpp hello.cpp)

hello.cpp
#include <iostream>
#include "hello.hpp"

void hello() {
std::cout << "Hello!" << std::endl;
}

hello.hpp
#ifndef HELLO_H
#define HELLO_H

void hello();

#endif

main.cpp
#include "hello.hpp"

int main() {
hello();
}

■helloworldのbuild
source /opt/poky/2.5.2/environment-setup-aarch64-poky-linux
export LDFLAGS=””

cd sdk/helloworld
mkdir build
cd build
cmake ..
make # cmakeでエラーのため実施無

■CMakeエラー内容
$ cmake ..
-- The CXX compiler identification is GNU 7.3.0
-- Check for working CXX compiler: /opt/poky/2.5.2/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++
-- Check for working CXX compiler: /opt/poky/2.5.2/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ -- broken
CMake Error at /opt/poky/2.5.2/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message):
The C++ compiler

"/opt/poky/2.5.2/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/tcu/yocto-sample/sdk/helloworld/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_fcfa6/fast"
/usr/bin/make -f CMakeFiles/cmTC_fcfa6.dir/build.make CMakeFiles/cmTC_fcfa6.dir/build
make[1]: Entering directory '/home/tcu/yocto-sample/sdk/helloworld/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_fcfa6.dir/testCXXCompiler.cxx.o
/opt/poky/2.5.2/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ -march=armv8-a -mtune=cortex-a57.cortex-a53 --sysroot=/opt/poky/2.5.2/sysroots/aarch64-poky-linux -O2 -pipe -g -feliminate-unused-debug-types -o CMakeFiles/cmTC_fcfa6.dir/testCXXCompiler.cxx.o -c /home/tcu/yocto-sample/sdk/helloworld/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_fcfa6
/opt/poky/2.5.2/sysroots/x86_64-pokysdk-linux/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_fcfa6.dir/link.txt --verbose=1
/opt/poky/2.5.2/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ -march=armv8-a -mtune=cortex-a57.cortex-a53 --sysroot=/opt/poky/2.5.2/sysroots/aarch64-poky-linux -O2 -pipe -g -feliminate-unused-debug-types ”” -rdynamic CMakeFiles/cmTC_fcfa6.dir/testCXXCompiler.cxx.o -o cmTC_fcfa6
aarch64-poky-linux-g++: error: ””: No such file or directory
CMakeFiles/cmTC_fcfa6.dir/build.make:97: recipe for target 'cmTC_fcfa6' failed
make[1]: *** [cmTC_fcfa6] Error 1
make[1]: Leaving directory '/home/tcu/yocto-sample/sdk/helloworld/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_fcfa6/fast' failed
make: *** [cmTC_fcfa6/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:4 (project)

-- Configuring incomplete, errors occurred!
See also "/home/tcu/yocto-sample/sdk/helloworld/build/CMakeFiles/CMakeOutput.log".
See also "/home/tcu/yocto-sample/sdk/helloworld/build/CMakeFiles/CMakeErr

SDKを使用してカーネル及びカーネルモジュールを構築する場合する際 export LDFLAGS=”” を実行しますが、
通常のユーザランドで動作するプログラムを構築する場合は、SDK実行環境設定時に読み込まれた環境変数を変更しないことをお勧めします。
 

export LDFLAGS=””  を実施せずにやるとうまくいきました。ありがとうございます。