开发者

running binary on different machine causes segfault

I'm not well versed in how linking happens in c++

I have a binary that i compiled on one machine and i'd like to copy it and run it on another machine.

I would expect this to work, because the libraries are the same on both machines (i think!) and the version of linux is the same (same kernel, etc.) However,开发者_C百科 when i copy it over... it appears to segfault in one of the libraries i am dynamically linking when i run it.

It runs like butter on the machine that i compiled it on. But on the machine that i scp'd it over to, when i run the binary, it instantly segfaults on a std::string::compare in a call stack with some functions in one of the libraries i am dynamically linking.

i tried installing the libraries again on both machines and doing ldconfig, but same results.

any ideas on how to debug these kind of weird segfaults caused by dynamic linking issues?


Well, it might help narrow down the problem if you run the program in a debugger. When compiling, add the -g -ggdb arguments to the g++ command, then when running the program, use the command gdb ./executable (you may need to install gdb first.) At the gdb prompt, type run and your program will run until it segfaults. Then you can try to figure out what went wrong.

There are plenty of tutorials for using gdb (the GNU debugger) online.


Sounds like a binary compatibility issue. This SO link might shed some light: Creating a generic binary in linux for all x86 machines

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜