0

I am trying to build test.cpp with command: arm-none-linux-gnueabi-g++ test.cpp -o test and I put command readelf -d test in terminal, the output is like this:

0x0000001(NEEDED)    share library:[libm.so.6]
0x0000001(NEEDED)    share library:[libstdc++.so.6]
0x0000001(NEEDED)    share library:[libgcc_s.so.1]
0x0000001(NEEDED)    share library:[libc.so.6]

It's not what I expect, the expected result is:

0x0000001(NEEDED)    share library:[libm.so]
0x0000001(NEEDED)    share library:[libstdc++.so]
0x0000001(NEEDED)    share library:[libgcc_s.so]
0x0000001(NEEDED)    share library:[libc.so]

I found out that there are link files(libstdc++.so, libc.so) in arm-none-gnueabi lib, so I want to know if there is a parameter for g++ to link libstdc++.so, libc.so, libgcc_s.so,...?

I hope someone can solving this problem. Thank you very much!

test.cpp code as follows:

#include<iostream>
int main(void)
{
    std::cout << "Hello World" << std::endl;
    return 0;
}

gcc version is 4.8.3 20140320.

Jean-Baptiste Yunès
  • 34,548
  • 4
  • 48
  • 69
  • This seems to be an XY problem. Why would you want this? – user7860670 Jan 05 '21 at 13:04
  • @user7860670 not to be dependent on library version? – Jean-Baptiste Yunès Jan 05 '21 at 13:15
  • 1
    @Jean-BaptisteYunès The only way to not be dependent on library version i'm aware of is not to use library at all. – user7860670 Jan 05 '21 at 13:18
  • To track the version is the only way to pick up the best one if there are multiple versions in parallel which can be handled by the ld.so. We all know systems which can not deal with non compatible libs(dlls) :-) – Klaus Jan 05 '21 at 13:24
  • @user7860670 that is pretty rude, if not almost not practiable. If versions ensure backward compatibility, then not be dependent on version may be a goal. (Not really sure OP really want this). – Jean-Baptiste Yunès Jan 05 '21 at 13:26
  • @Jean-BaptisteYunès Well, in this case for instance libstdc++.so.6 explicitly breaks backward compatibility when DT_SONAME differs. So one should not expect generic libstdc++.so to be compatible. – user7860670 Jan 05 '21 at 13:41
  • 1
    @Jean-BaptisteYunès: This kind of versioning is for all practical purposes broken. "libc.so.6" is not version 6, but Glibc version 2.13-38+rpi2 or something like that. – MSalters Jan 05 '21 at 13:44
  • @Jean-BaptisteYunès Thank you for your answar, My goal is to let "test" depend on library without version, It seems there aren't good ways to do this. – JeffreyZhang Jan 06 '21 at 13:04

0 Answers0