开发者

shared object error when using binary on different machine

开发者 https://www.devze.com 2023-03-27 16:31 出处:网络
How can I avoid this? I have a pretty simple c++ program compiled on a ubuntu box. When I move it over to red hat and try to execute it I get an error something like:

How can I avoid this? I have a pretty simple c++ program compiled on a ubuntu box. When I move it over to red hat and try to execute it I get an error something like:

cannot find shared object stdlibc++5.so

How does commercial software get around this, the stdlib installed开发者_StackOverflow on users machines is going to vary a lot. Is there some flag I need to be using when I compile?


I think you need to recompile it again because:

  1. OS is different [Ubuntu and Red Hat]
  2. The location of libraries might be different. Also there are chances (though very minute) that stdc++ library is not present at all.
  3. In commercial software employing compiled languages like C/C++ , the applications are deployed on the same OS (both development and production..as far as I know) and usually , the library locations are also consistent

So, please check if you are able to compile your C++ code (may be hello world) and compile your code again.


There could be any number of reasons for this; for all you know, the target machine may not have installed g++ and its libraries. The only real solution is to statically link the standard C++ library, using the -static-libstdc++ option.

0

精彩评论

暂无评论...
验证码 换一张
取 消