not foundってなんですの?(SDx続き)

ELFファイルのステータスを見てみましょう。

% readelf -a OpenCV_Sample03.elf
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x11484
  Start of program headers:          52 (bytes into file)
  Start of section headers:          226824 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           40 (bytes)
  Number of section headers:         39
  Section header string table index: 36

特に問題ないですね。

と、いうかエラーはnot foundなのでELFファイル以前の問題か?

試しにHello Worldを作成した。

#include <stdio.h>

int main(int argc, char *args[])
{
    printf("Hello, world!\n");
    return 0;
}

コンパイルはいたって簡単に・・・

% ${CC} -o hello hello.c

そして、実行すると・・・

root@zturn:~# ./hello
Hello, world!

問題なく、実機で動作する。

そこでreadelfしてみると・・・

% readelf -a ./hello
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x102f4
  Start of program headers:          52 (bytes into file)
  Start of section headers:          7988 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           40 (bytes)
  Number of section headers:         38
  Section header string table index: 35

特に問題ないですね。

なにが原因で、not foundなんでしょうか?

いいところまで来ていると思うのですが・・・

単純なコンパイル用ソースコードにprintfを追加してみました。

/*
 * OpenCV フィルタサンプル - ラプラシアン
g++ -o sobel_sample01 sobel_sample01.cpp -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_im
gproc
 */
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>

int main( int argc, char** argv )
{
  printf("exec: OpenCV_Sample01\n");

  // Read lena-chan with Grayscale
  printf("read: lena.png\n");
  cv::Mat src = cv::imread("lena.png", 0);

  printf("exec: laplacian\n");
  cv::Mat laplacian, tmp;
  cv::Laplacian(src, tmp, CV_32F, 3);
  cv::convertScaleAbs(tmp, laplacian, 1, 0);

  // Write for laplacian not kuracian
  printf("write: lena_laplacian.png\n");
  cv::imwrite("lena_laplacian.png", laplacian);

  printf("finish: OpenCV_Sample01\n");

  return 0;
}

それとSDカードにOpenCVライブラリが入っていなかったのでSDカードのrootfsをちゃんとコピーしてみた。

そうしたら、今度は"No such file or directory"になった。

root@zturn:~# ./OpenCV_Sample01.elf
-sh: ./OpenCV_Sample01.elf: No such file or directory

printfが出る前に、弾かれているのですがどうしたことなのでしょうか?

ELFファイルを直接、確認したところSDxで生成したELFファイルはld-linuxがld-linux.so.3に向いていることが判った。

本当はld-linux-armhf.so.3に向いていて欲しいのだが、コンパイルがうまく言っていないことが判った。

試しに実機でld-linux.so.3をld-linux-armhd.so.3にリンクすると次のようにエラーが変化した。

root@zturn:~# ln -s /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3
root@zturn:~# ./OpenCV_Sample01.elf
cf_context_init()
ERROR: unable to open xlnk

なんですと!

xlnxが開けませんって?

write: 2017/01/16/ 22:20:39