Bug #40812 Unable to Complie C program in Solaris 10
Submitted: 18 Nov 2008 4:32 Modified: 19 Nov 2008 9:30
Reporter: priya bs Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:6.3.17 OS:Solaris
Assigned to: CPU Architecture:Any
Tags: C, gcc, MySQL, solaris 10

[18 Nov 2008 4:32] priya bs
Description:
Hi,

I am unable to compile C program which connects to Database (Mysql) on Solaris 10 server with gcc.

I'm getting the following error. Please help me in this regard.

How to repeat:

$/usr/sfw/bin/gcc -o /export/home/programs/DB-Connect.out -I/usr/local/mysql/include  -g -mt -D_FORTEC_ -xarch=v9 -DHAVE_RWLOCK_T -DUNIV_SOLARIS /export/home/programs/DB-Connect.c -xarch=v9  -L/usr/local/mysql/lib -lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm

gcc: language arch=v9 not recognized
ld: fatal: file /export/home/programs/DB-Connect.c: unknown file type
ld: fatal: File processing errors. No output written to /export/home/programs/DB-Connect.out
collect2: ld returned 1 exit status
[18 Nov 2008 10:36] Valeriy Kravchuk
Thank you for a problem report. Do you use MySQL Cluster? Please, send the results of:

/usr/sfw/bin/gcc --version
uname -a

Try also to compile with

/usr/sfw/bin/gcc -o /export/home/programs/DB-Connect.out -I/usr/local/mysql/include  -g -mt -DHAVE_RWLOCK_T -DUNIV_SOLARIS /export/home/programs/DB-Connect.c -L/usr/local/mysql/lib -lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm

and inform about the results.
[18 Nov 2008 10:43] priya bs
Hi,

Yes, i have installed MySql Cluster.

Here are the details you requested:

1) $/usr/sfw/bin/gcc -o /export/home/programs/DB-Connect.out -I/usr/local/mysql/include  -g -mt -DHAVE_RWLOCK_T -DUNIV_SOLARIS /export/home/programs/DB-Connect.c -L/usr/local/mysql/lib -lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm

cc1: error: invalid option `t'

2) $uname -a

SunOS ruhr1 5.10 Generic_137111-08 sun4u sparc SUNW,Sun-Fire

3) $/usr/sfw/bin/gcc -v
Reading specs from /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/specs
Configured with: /sfw10/builds/build/sfw10-patch/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/ccs/bin/as --without-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++ --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
[18 Nov 2008 16:01] Valeriy Kravchuk
Sorry, missed that options. Please, check if

/usr/sfw/bin/gcc -o /export/home/programs/DB-Connect.out -I/usr/local/mysql/include -DHAVE_RWLOCK_T -DUNIV_SOLARIS /export/home/programs/DB-Connect.c -L/usr/local/mysql/lib -lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm

will work.
[19 Nov 2008 5:17] priya bs
Hi, 

I am still unable to run the program. Check below for the result

$/usr/sfw/bin/gcc -o /export/home/programs/DB-Connect.out -I/usr/local/mysql/include -DHAVE_RWLOCK_T -DUNIV_SOLARIS /export/home/programs/DB-Connect.c -L/usr/local/mysql/lib -lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm

ld: warning: file /usr/local/mysql/lib/libz.a(compress.o): wrong ELF class: ELFCLASS64

However *.out file is created and its 32-bit executable.

$file DB-Connect.out 

DB-Connect.out: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped, no debugging information available
[19 Nov 2008 5:27] Valeriy Kravchuk
OK, so you have 64-bit MySQL. Try this:

/usr/sfw/bin/gcc -m64 -o /export/home/programs/DB-Connect.out -I/usr/local/mysql/include -DHAVE_RWLOCK_T -DUNIV_SOLARIS /export/home/programs/DB-Connect.c -L/usr/local/mysql/lib -lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm
[19 Nov 2008 8:31] priya bs
Hey Thanks !!!

Its working.
[19 Nov 2008 9:30] Valeriy Kravchuk
Not a bug. Just improper gcc command line options usage.