linux c++ rabbitMq Demo

1. Implement remote debugging of Linux c++ programs on vs: https://www.jianshu.com/p/8b51a795cb92 .

2. Debugging requires c++11, upgrade the gcc version on redhat, virtual machine gcc version 4.4.7, using yum can only upgrade to 4.4.7, so it needs to be done manually: 

[gcc upgrade steps]

1. Download the compressed package of gcc 4.8.5
Download address 
: http://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.bz2



2. Find a directory to store and unzip it

#tar -jxvf gcc- 4.8 . 5 .tar.bz2



3. Enter the directory and execute the command

This magical script file will help us download, configure, and install dependent libraries, which can save us a lot of time and energy.

# cd  gcc-4.8.5 
# ./contrib/download_prerequisites


4. Create a directory for the compiled files to store

# mkdir gcc-build-4.8.5
# cd gcc-build-4.8.5


5. Generate Makefile
# ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib


6. Execute make, which takes about 1 hour here. It is not recommended to use make- j4 mentioned in the literature [ 2 ], it may report an error

# yum groupinstall "Development Tools"

# make



7. Execute the installation

# make install



8. When done, test

# reboot // Please reboot first, remember! 
# 
gcc -v

#g ++- v



【Library upgrade】

Don't think that the gcc upgrade is successful, you can directly program c ++ 11 programs. A library upgrade is also required. Source code compilation and upgrade After installing gcc, when compiling programs or running other programs, sometimes something like:



/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found



The problem. This is because when upgrading gcc, the generated dynamic library does not replace the dynamic library of the old version of gcc. It can be solved by replacing the dynamic library of the latest version of gcc with the dynamic library of the old version in the system. [ 3 ]



1. Check

# strings /usr/lib64/libstdc++.so.6 | grep GLIBC



2. Find the latest library files for gcc 4.8.5

# find / -name "libstdc++.so*"



/usr/lib64/libstdc++.so.6.0.13
/usr/lib64/libstdc++.so.6
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libstdc++.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libstdc++.so
/usr/lib/vmware-tools/lib64/libstdc++.so.6
/usr/lib/vmware-tools/lib64/libstdc++.so.6/libstdc++.so.6
/usr/lib/vmware-tools/lib32/libstdc++.so.6
/usr/lib/vmware-tools/lib32/libstdc++.so.6/libstdc++.so.6
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyo
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyc
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyo
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.py
/usr/local/lib64/libstdc++.so.6.0.19
/usr/local/lib64/libstdc++.so.6
/usr/local/lib64/libstdc++.so
/usr/local/lib64/libstdc++.so.6.0.19-gdb.py
/opt/gcc-4.8.5/gcc-build-4.8.5/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.19
/opt/gcc-4.8.5/gcc-build-4.8.5/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/opt/gcc-4.8.5/gcc-build-4.8.5/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
/opt/gcc-4.8.5/gcc-build-4.8.5/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.19
/opt/gcc-4.8.5/gcc-build-4.8.5/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/opt/gcc-4.8.5/gcc-build-4.8.5/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
/opt/gcc-4.8.5/gcc-build-4.8.5/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.19
/opt/gcc-4.8.5/gcc-build-4.8.5/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/opt/gcc-4.8.5/gcc-build-4.8.5/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so




The 
bolded and blacked libstdc ++.so.6.0.19 is the new library file of 4.8.5 .



3. Copy the library file to the specified directory and modify the soft link

# cp /opt/gcc-4.8.5/gcc-build-4.8.5/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.19  /usr/lib64

# cd /usr/lib64

# rm libstdc++.so.6

# ln -s libstdc++.so.6.0.19 libstdc++.so.6



4. Check it out

# strings /usr/lib64/libstdc++.so.6 | grep GLIBC



GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19

...



(Finish)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324842492&siteId=291194637