Centos 7 constructs the GCC 4.8.2 32-bit compiling environment

Source: Internet
Author: User

Construct a GCC 32-bit compiling environment using centos 7


1 Introduction

1.1 Background
Learn New C ++ 2011 and C11 standards.

1.2 use software
Centos 7 (Linux version 3.10.0-123. el7.x86 _ 64)
GCC version 4.8.2 20140120 (Red Hat 4.8.2-16)

1.3 this configuration
32-bit GCC development environment.
Because RHEL 7 (Red Hat Enterprise Linux 7) no longer provides the 32-bit version, centos 7 does not provide the 32-bit version in the short term, so to consider upgrading and researching available operating systems, configure the open environment.
64-bit centos 7 currently only provides GCC 4.8.2 64-bit version. glibc (version 2.17) 32-bit version is not installed by default.

1.4 Purpose
Build a 64-bit centos version of GCC 4.8.2 that supports compiling and running 32-bit programs and a new standard compiling environment.

2 Installation Steps
2.1 install glibc (32-bit)
Install glibc 32-bit.
Yum -- disablerepo = * -- enablerepo = c6-media install glibc-2.17-55.el7.i686

2.2 install GCC 4.8.2
Install the complete GCC 4.8.2.
2.3 copy the Runtime Library libgcc_s.so
Assuming GCC 4.8.2 is installed to/usr/local/gcc-4.8.2. Copy the 32-bit version libgcc_s.so to the 32-bit library.
/Lib.
CP/usr/local/gcc-4.8.2/lib/libgcc */lib

2.4 verify installation (C11)
[[Email protected] SRC] # Cat AA. c

# Include <stdio. h>
# Include <pthread. h>

// Gcc-M32-g-STD = C11 AA. C-o AA-lpthread;./AA

Void * F (void * Data)
{
// Char buff [10];
// Char * p = 0;
// Memcpy (buff, "ddddddddddddddd", 20 );
// Memcpy (P, "Sss", 10 );
// P [0] = 'D ';
Printf ("centos 7, GCC 4.8.2 C11 test OK. \ n ");
Return 0;
}

Int main (INT argc, char * argv [])
{
Pthread_t T;
Pthread_create (& T, 0, F, 0 );
Pthread_join (T, 0 );
Return 0;
}

Gcc-M32-g-STD = C11 AA. C-o AA-lpthread;./AA; LDD AA
Centos 7, GCC 4.8.2 C11 test OK.
Linux-gate.so.1 => (0xf77bb000)
Libpthread. so.0 =>/lib/libpthread. so.0 (0xf7799000)
Libc. so.6 =>/lib/libc. so.6 (0xf75db000)
/Lib/ld-linux.so.2 (0xf77bc000)
2.5 verify installation (C ++ 2011)
[[Email protected] SRC] # Cat AA. cpp

# Include <stdio. h>
# Include <thread>
# Include <functional>
# Include <algorithm>
Using namespace STD: placeholders;
Using namespace STD;

// G ++-STD = C ++ 11-g AA. cpp-o aa-lpthread;./AA

Void * F (void * Data)
{
Printf ("centos 7, GCC 4.8.2 C ++ 2011 test OK. \ n ");
Return 0;
}

Int main (INT argc, char * argv [])
{
Void * P;
// STD: function <void * (void *)> pF = STD: BIND (F, nullptr );
Auto pF = STD: BIND (F, nullptr );
STD: thread t (PF );
// T. Start ();
T. Join ();
Return 0;
}

[[Email protected] SRC] # G ++-STD = C ++ 11-g AA. cpp-o aa-lpthread;./AA; LDD AA
Centos 7, GCC 4.8.2 C ++ 2011 TEST OK.
Linux-vdso.so.1 => (0x00007fffe7d6c000)
Libpthread. so.0 =>/lib64/libpthread. so.0 (0x00007fd40dd34000)
Libstdc ++. so.6 =>/lib64/libstdc ++. so.6 (0x00007fd40da2d000)
Libm. so.6 =>/lib64/libm. so.6 (0x00007fd40d72a000)
Libgcc_s.so.1 =>/lib64/libgcc_s.so.1 (0x00007fd40d514000)
Libc. so.6 =>/lib64/libc. so.6 (0x00007fd40d153000)

/Lib64/ld-linux-x86-64.so.2 (0x00007fd40df58000)




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.