Start a new topic
Answered

How can I use the C++ SDK on Red Hat Enterprise Linux using the default GCC 4.8.5?

When I try to compile my program on RHEL using GCC 4.8.5, I get lots of undefined reference errors due to standard library types.  


Best Answer

This answer applies to both CentOS 7.6 and RHEL.


The default version of GCC which can be installed on these operating systems using the command 

yum -y install gcc

is version 4.8.5. This version of GCC is too old to compile a program which uses the Trueface SDK.


In order to compile your program, you must upgrade your version of GCC.

You may have noticed that you can install a newer version of the GCC packaged using the following commands:

sudo yum install centos-release-scl
sudo yum install devtoolset-7
scl enable devtoolset-7 bash


However, this will not work. Basically, this installs a devtoolset version of GCC which maintains compatibility with the old GCC ABI, which is not what you want.

Instead, you will need to compile and install a new version of GCC from source. I advise version 7 or newer. 

Just note, compiling GCC from source can take quite a while.


Here is a good tutorial on how to compile and install GCC from source:  https://linuxhostsupport.com/blog/how-to-install-gcc-on-centos-7/


Once you have installed the new version, you should be able to compile your program (just ensure that you are using the new version of GCC).

At this point, you will also need to ensure that the compiled application is linking against the new version of libstdc++.so.6

You can check which version of this library is being used by running "ls -la /lib64/ | grep libstdc++.so.6" and seeing what version the symbolic link is pointing to. 

If the symbolic link is pointing to libstdc++.so.6.0.19, then you will need to update the symbolic link to point to the new version of libstdc++ by running the following commands (in my case, I am using libstdc++.20.6.0.24 which came with GCC 7.3.0, but you should use the version which came with the new version of GCC you just compiled).


rm /lib64/libstdc++.so.6
ln -s /usr/local/lib64/libstdc++.so.6.0.24 /lib64/libstdc++.so.6


At this point, you should be able to run your program. 

1 Comment

Answer

This answer applies to both CentOS 7.6 and RHEL.


The default version of GCC which can be installed on these operating systems using the command 

yum -y install gcc

is version 4.8.5. This version of GCC is too old to compile a program which uses the Trueface SDK.


In order to compile your program, you must upgrade your version of GCC.

You may have noticed that you can install a newer version of the GCC packaged using the following commands:

sudo yum install centos-release-scl
sudo yum install devtoolset-7
scl enable devtoolset-7 bash


However, this will not work. Basically, this installs a devtoolset version of GCC which maintains compatibility with the old GCC ABI, which is not what you want.

Instead, you will need to compile and install a new version of GCC from source. I advise version 7 or newer. 

Just note, compiling GCC from source can take quite a while.


Here is a good tutorial on how to compile and install GCC from source:  https://linuxhostsupport.com/blog/how-to-install-gcc-on-centos-7/


Once you have installed the new version, you should be able to compile your program (just ensure that you are using the new version of GCC).

At this point, you will also need to ensure that the compiled application is linking against the new version of libstdc++.so.6

You can check which version of this library is being used by running "ls -la /lib64/ | grep libstdc++.so.6" and seeing what version the symbolic link is pointing to. 

If the symbolic link is pointing to libstdc++.so.6.0.19, then you will need to update the symbolic link to point to the new version of libstdc++ by running the following commands (in my case, I am using libstdc++.20.6.0.24 which came with GCC 7.3.0, but you should use the version which came with the new version of GCC you just compiled).


rm /lib64/libstdc++.so.6
ln -s /usr/local/lib64/libstdc++.so.6.0.24 /lib64/libstdc++.so.6


At this point, you should be able to run your program. 

Login or Signup to post a comment