Why do SDK libraries and rootfs ones should match?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why do SDK libraries and rootfs ones should match?

Jump to solution
1,085 Views
yibhan
Contributor III

Hello guys,

I am curious about the above subject, and I couldn't easily understand that.

when I build my app with SDK and make executable file, this file means a just binary and can executable in target machine. but, someone recommends SDK and rootfs libraries and include files should be matched, otherwise, it may occure some problem in apps. Until now, I don't understand that.

Could you please explain for me so that I can move forward it?

Thank you in advance.

Labels (3)
0 Kudos
1 Solution
991 Views
BiyongSUN
NXP Employee
NXP Employee

Before answer you question, I should guess the "binary" you mentioned is ELF Executables. 

If it is really a binary(static link for example), it could run anywhere. 

1. the rootfs is created by toolchain library. If you have skills to manually create a rootfs, you will know that very clear.

2. the dynamic link program needs dynamic linker. 

     ld.so(8) - Linux manual page 

The dynamic linker is the program that manages shared dynamic libraries on behalf of an executable. It works to load libraries into memory and modify the program at runtime to call the functions in the library.

ELF allows executables to specify an interpreter, which is a program that should be used to run the executable. The compiler and static linker set the interpreter of executables that rely on dynamic libraries to be the dynamic linker.

That is why, if you dynamically link a program with glibc, could not run in the rootfs created by uclibc, or android.   

If you run it, it will get very interesting error report, "file not found".

But if you statically link a program, you can run it in rootfs created by uclibc or android. 

To speakly frankly, you should not raise this very basic question here. Here is the community  not for the basic knowledge. 

And If you are an software engineer. You have very long road ahead for you.

Show you here  of the my host pc X64  the program(cat)

  [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

/lib64/ld-linux-x86-64.so.2 is the dynamic linker.

It is needed for running the dynamic linked program here is "/bin/cat"

readelf --headers /bin/cat

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
                 0x00000000000001f8 0x00000000000001f8  R E    0x8
  INTERP         0x0000000000000238 0x0000000000000238 0x0000000000000238
                 0x000000000000001c 0x000000000000001c  R      0x1
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x00000000000079d0 0x00000000000079d0  R E    0x200000
  LOAD           0x0000000000007a70 0x0000000000207a70 0x0000000000207a70
                 0x0000000000000650 0x00000000000007f0  RW     0x200000
  DYNAMIC        0x0000000000007c18 0x0000000000207c18 0x0000000000207c18
                 0x00000000000001f0 0x00000000000001f0  RW     0x8

View solution in original post

0 Kudos
4 Replies
991 Views
yibhan
Contributor III

Hello guys,

Thank you for your explanation. I am understanding, but I am still wondering about build.

After full build with imx-image-full and sdk, I have compared with sdk usr/include and rootfs usr/include,

but it was different.

Is it okay to be different with sdk usr/include and rootfs usr/include?

Thanks,

Best Regards,

0 Kudos
991 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello Yibeom Han,

    I don't understand why you compare it.

    It seems that you want to export cross-compile tool chain and build u-boot / kernal in standalone mode. if you want to do it. the operation is clearly descibed in these 2 documents:

----i.MX_Linux_User's_Guide.pdf  (4.19.35)

4.5.12 How to build U-Boot and Kernel in standalone environment

----i.MX_Porting_Guide.pdf (4.19.35)

2.1.1 How to build and load Kernel in standalone environment

    You only need to follow steps in these 2 documents, and tool chain will be installed to your ubuntu Host.

Have a nice day!

B.R

Weidong

0 Kudos
992 Views
BiyongSUN
NXP Employee
NXP Employee

Before answer you question, I should guess the "binary" you mentioned is ELF Executables. 

If it is really a binary(static link for example), it could run anywhere. 

1. the rootfs is created by toolchain library. If you have skills to manually create a rootfs, you will know that very clear.

2. the dynamic link program needs dynamic linker. 

     ld.so(8) - Linux manual page 

The dynamic linker is the program that manages shared dynamic libraries on behalf of an executable. It works to load libraries into memory and modify the program at runtime to call the functions in the library.

ELF allows executables to specify an interpreter, which is a program that should be used to run the executable. The compiler and static linker set the interpreter of executables that rely on dynamic libraries to be the dynamic linker.

That is why, if you dynamically link a program with glibc, could not run in the rootfs created by uclibc, or android.   

If you run it, it will get very interesting error report, "file not found".

But if you statically link a program, you can run it in rootfs created by uclibc or android. 

To speakly frankly, you should not raise this very basic question here. Here is the community  not for the basic knowledge. 

And If you are an software engineer. You have very long road ahead for you.

Show you here  of the my host pc X64  the program(cat)

  [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

/lib64/ld-linux-x86-64.so.2 is the dynamic linker.

It is needed for running the dynamic linked program here is "/bin/cat"

readelf --headers /bin/cat

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
                 0x00000000000001f8 0x00000000000001f8  R E    0x8
  INTERP         0x0000000000000238 0x0000000000000238 0x0000000000000238
                 0x000000000000001c 0x000000000000001c  R      0x1
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x00000000000079d0 0x00000000000079d0  R E    0x200000
  LOAD           0x0000000000007a70 0x0000000000207a70 0x0000000000207a70
                 0x0000000000000650 0x00000000000007f0  RW     0x200000
  DYNAMIC        0x0000000000007c18 0x0000000000207c18 0x0000000000207c18
                 0x00000000000001f0 0x00000000000001f0  RW     0x8

0 Kudos
991 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Good!

0 Kudos