Quantcast
Channel: Planet PostgreSQL
Viewing all articles
Browse latest Browse all 9645

Dinesh Kumar: 32-bit PostgreSQL Compilation On 64-bit CentOS 6.x

$
0
0
I am sure that, most of you aware of this. But, for me it's the first time, i accomplished it.

As one of my assigned tasks to build a 32-bit instance of postgresql on 64-bit machine, i have followed the below approach. I hope, it will be helpful to others as well, if you got any problems.

As a initial step on this task, i have tried to build a sample "c" program using "gcc -m32". Once, i resolved this, i moved to compile the PostgreSQL 9.0.

[root@localhost Desktop]# gcc -m32 -o test test.c
In file included from /usr/include/features.h:385,
                 from /usr/include/stdio.h:28,
                 from test.c:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
To resolve the above issue, i have installed the 32-bit glibc-devel package through yum.

yum -y install glibc-devel.i686 glibc-devel
Again, i have tried to run the same command.

[root@localhost Desktop]# gcc -m32 -o test test.c
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
Now, i got a different error message, and tried to install the 32-bit libgcc.

[root@localhost Desktop]# yum install libgcc-*.i686
--> Running transaction check
---> Package libgcc.i686 0:4.4.7-4.el6 will be installed
--> Finished Dependency Resolution
Error: Protected multilib versions: libgcc-4.4.7-4.el6.i686 != libgcc-4.4.6-3.el6.x86_64
As it's complaining, we have the old version of x86_64, when compared the new one. Hence, i have tried to update the existing x86_64.

[root@localhost Desktop]# yum update libgcc-4.4.6-3.el6.x86_64
---> Package libgcc.x86_64 0:4.4.6-3.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-4.el6 will be an update
--> Finished Dependency Resolution
Once, it's updated the given library, i have again tried to install the libgcc-*.i686.

[root@localhost Desktop]# yum install libgcc-*.i686
Resolving Dependencies
--> Running transaction check
---> Package libgcc.i686 0:4.4.7-4.el6 will be installed
--> Finished Dependency Resolution
Now, i am trying to run the same "gcc -m32" command to check for any further issues.

[root@localhost Desktop]# gcc -m32 -o test test.c
[root@localhost Desktop]# ./test
Hello World
It looks, the sample "c program" is working fine, as a 32-bit application. Now, i am moving to PostgreSQL 9.0. As per my observation i have updated, installed the below components for the PostgreSQL.

yum update readline-6.0-3.el6.x86_64
yum install *readline*i686
yum update zlib-1.2.3-27.el6.x86_64
yum install *zlib*i686
Once, i got the all required 32-bit libraries, i have tried to compile the postgresql as below.

[root@localhost build]# CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix=/opt/PostgreSQL/build
[root@localhost build]# make -j 4; make install;
....
make[1]: Leaving directory `/root/Downloads/postgresql-9.0.17/config'
PostgreSQL installation complete.
It seems, postgresql has built successfully on 64-bit machine as a 32-bit application. Check for the confirmation from OS, PG.

postgres=# SELECT version();
                                                      version                                                      
-------------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.0.17 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3), 32-bit
(1 row)

[root@localhost build]# file /sbin/init
/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
And, at the end, i have the postgresql as 32-bit application in 64-bit machine.

Thank you for reading, and please comment on this, if you have any questions.


--Dinesh Kumar

Viewing all articles
Browse latest Browse all 9645

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>