I'm running CentOS 6.4 and need a later version of the C++ compiler to build my development tools (Qt Creator in this case).

I'm unclear on the implications of using devtools and I'm hoping someone can explain.

  1. If I compile programs using devtools, does that means the executable will run on other Centos 6.4 installations without change?
  2. Or..do I know have to ship libraries or other files with my compiled programs?
  3. If so...do I have to modify my C++ code to reference the later libraries? or is this something done by the person installing my compiled program
有帮助吗?

解决方案

I hope this somewhat late answer can still help you. What I found is that compiling my project with devtoolset (1.1 in my case, but that should not matter too much) on RHEL 6.4 produces binaries which can almost run on a standard RedHat EL 6.4 (should be similar for Centos 6.4).

The only trouble I ran into was compiling my project with -std=c++11, which produced some problems due to incompatible symbols. The reason is that the GCC folks considered these parts of the standard library to be experimental in GCC 4.4, so they broke ABI compatibility in some places.

Turns out, there's an easy fix: Link your programs with the additional command-line-argument -static-libstdc++. That way, the binary becomes a bit larger but is runs on an unmodified RHEL 6.4 without installing additional libraries/updates for the devtoolset.

To answer your questions explicitly:

  1. Yes, almost.
  2. No.
  3. Don't change the code, just add -static-libstdc++ when linking.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top