0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

M5UnitV2でクロスコンパイルすると"no version information available"

Last updated at Posted at 2024-06-27

概要

M5UnitV2でクロスコンパイル環境を構築し、生成されたバイナリーを実行すると、
" /usr/lib/libstdc++.so.6: no version information available"エラーが表示されます。これの対応の仕方を説明します。

現象

M5UnitV2のクロスコンパイル環境で、以下のソースコードをビルドします。

main.cpp
#include <iostream>
using namespace std;
int main() {
    cout<<"Hello UnitV2 World"<<endl;
    return 0;
}

UnitV2Frameworkで書かれている、
クロスコンパイル環境でgcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihfでクロスコンパイルを行います。

$ /opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ main.cpp -o main_0

このバイナリーをM5UnitV2で実行すると、"/usr/lib/libstdc++.so.6: no version information available"という表示がでてきました。

unitv2% ./main_0
./main_0: /usr/lib/libstdc++.so.6: no version information available (required by                            ./main_0)
./main_0: /usr/lib/libstdc++.so.6: no version information available (required by                            ./main_0)
Hello UnitV2 World

このエラーメッセージ「/lib/libstdc++.so.6: no version information available (required by ./hello-world)」は、実行しようとしているプログラム ./main_0 が依存している libstdc++.so.6 ライブラリのバージョンが、プログラムがコンパイルされたときに使用されたものと異なるか、またはUnitV2の中でバージョン情報が見つからないことを示しています。

対策:静的リンクの使用

プログラムを再コンパイルして libstdc++ を静的にリンクすることで、異なるシステム間でのライブラリのバージョン違いによる問題を避けることができます。 -static-libstdc++というオプションをつけます。

 /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ main.cpp -o main -static-libstdc++

このバイナリーをM5UnitV2で実行して、エラー表示が出なくなることを確認しました。

unitv2% ./main
Hello UnitV2 World

デメリットとして、ファイルサイズが大きくなる弊害が発生します。

Name Type ファイルサイズ
main_0 -static-libstdc++なし 0.013MB
main -static-libstdc++あり  6.449MB

参考

M5UnitV2のクロスコンパイル環境を構築する手順
https://qiita.com/nnn112358/items/9e15450265b689300216

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?