Bug #5494 Compilation of MySQL 4.0.20 fails with OpenSSL in alternate location
Submitted: 9 Sep 2004 15:18 Modified: 16 Feb 2005 11:07
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:4.0.20 OS:Linux (SuSE Linux Enterprise 9)
Assigned to: CPU Architecture:Any

[9 Sep 2004 15:18] [ name withheld ]
Description:
When trying to compile MySQL with OpenSSL support in an alternate directory (project requirement), the compiler fails with the following message:

gcc -DDEFAULT_CHARSET_HOME=\"/data/MySQL\"
 -DDATADIR=\"/data/MySQL/var\"
 -DSHAREDIR=\"/data/MySQL/share/mysql\"
 -DDONT_USE_RAID
 -I. -I. -I.. -I./../include -I../include -I./..
 -I.. -I.. /data/OpenSSL/include/openssl -O3 -DDBUG_OFF
 -MT libmysql.lo -MD -MP -MF .deps/libmysql.Tpo -c
 libmysql.c -o libmysql.o
 gcc: cannot specify -o with -c or -S and multiple
 compilations
 make[2]: *** [libmysql.lo] Error 1
 make[2]: Leaving directory
 `/data/software/tars/mysql-4.0.20/libmysql_r'
 make[1]: *** [all-recursive] Error 1
 make[1]: Leaving directory
 `/data/software/tars/mysql-4.0.20'
 make: *** [all] Error 2

My config options are as follows:

./configure --prefix=/data/MySQL
 --exec-prefix=/data/MySQL \
 --enable-thread-safe-client --enable-assembler \
 --enable-local-infile --with-extra-charsets=complex \
 --disable-shared --with-openssl=/data/OpenSSL \
 --without-docs --with-vio \
--with-openssl-includes=/data/OpenSSL/include/openssl \
 --with-openssl-libs=/data/OpenSSL/lib

Notice that the -I ../data/OpenSSL/include/openssl has an extra space 
between the -I and the ..

Also, notice that it tries to use ../data/OpenSSL as if it is at the same level
as the directory that I am using to compile, but it is not; it is a static
directory 3 levels under.

The directory I am using to compile is /software/tars/MySQL4.0.20 and the
OpenSSL directory is /data/OpenSSL

Beforehand, I appreciate your help in this matter.

Should you have any questions or concerns, please don't hesitate to
contact me.

How to repeat:
Compile MySQL with OpenSSL in al alternate directory (described in detail above).
[10 Sep 2004 13:04] Hartmut Holzgraefe
Problem #1: --with-openssl is just a boolean option, it doesn't take an argument

Problem #2: '/openssl' is appended to the argument of --with-openssl-includes

so --with-openssl-includes=/data/OpenSSL/include/openssl should have been just 
--with-openssl-includes=/data/OpenSSL/include here and --with-openssl=/data/OpenSSL
just --with-openssl

the real problem is that configure doesn't give any feedback or test for errors
and that $openssl_includes and $openssl_libs are not reset if with_openssl != yes
[10 Sep 2004 15:29] [ name withheld ]
Mr. Holzgraefe,

I tried compiling with the same options changing 

--with-openssl=/data/OpenSSL to --with-openssl

and

--with-openssl-includes=/data/OpenSSL/include/openssl to --with-openssl-includes=/data/OpenSSL/include

Configure ran without a problem; however, make came up with the following error messages:

In File included from bfill.c:32:
../include/my_global.h:1129:30: openssl/opensslv.h: No such file or directory
make[2]: ***[bfill.o] Error 1
make[2]: Leaving directory `/data/software/mysql-4.0.20/strings'
make[1]: Leaving directory /data/software/mysql-4.0.20
make: ***[all] Error 2

The file is in the correct directory ( /data/OpenSSL/include/openssl )

Thank you for your help!
[10 Sep 2004 17:51] Hartmut Holzgraefe
Which OpenSSL version are you using?
[10 Sep 2004 17:52] Hartmut Holzgraefe
Which OpenSSL version are you using?

I just tried 0.9.7d with your directory layout without problem
[10 Sep 2004 18:35] [ name withheld ]
Mr. Holzgraefe,

I am using OpenSSL 9.7d compiled in a SuSE Enterprise 9 minimum 
install + gcc 3.3.3.

My config for OpenSSL is:

./config --prefix=/data/OpenSSL --openssldir=/data/OpenSSL

The file it complains about ( /data/OpenSSL/include/openssl/opensslv.h ) is
located in that directory with permissions 644.

Thank you for your help!
[16 Sep 2004 16:13] [ name withheld ]
Mr.  Holzgraefe,

Is there an update on this bug?  Should I try MySQL 4.0.21?

Please let me know.

Thank you for your help!
[24 Sep 2004 17:34] Hartmut Holzgraefe
I can compile 4.0.20 just fine with

  ./configure --with-openssl --with-openssl-includes=/data/OpenSSL/include --with-openssl-libs=/data/OpenSSL/lib

I verified that it actually includes /data/OpenSSL/include/openssl/opensslv.h 
and that it doesn't pick it up elsewhere

I'm keeping this bug open as configure should be more foregiving
when openssl options are not used as expected but if used right
all should just work well
[24 Sep 2004 17:43] [ name withheld ]
Mr. Holzgraefe,

I have found out that if I do the following changes it works:

1. Add the following environment variables:

CFLAGS="-O2 -mcpu=pentiumpro" CXX=gcc CXXFLAGS="-O2 \
-mcpu=pentiumpro -felide-constructors"

export LD_LIBRARY_PATH=/usr/local/lib

export LDFLAGS='-R/usr/local/lib'

2. Execute the following commands:

make clean
rm -f sql/lex_hash.h

And then, configure:

./configure --prefix=/data/MySQL --exec-prefix=/data/MySQL  \
--enable-thread-safe-client \
--enable-assembler  \
--enable-local-infile \
--with-extra-charsets=complex  \
--disable-shared \
--with-vio --with-openssl \
--without-docs \
--with-openssl-libs=/data/OpenSSL/lib \
--with-openssl-includes=/data/OpenSSL/include

After this, I can do make and it works...

Without setting the environment variables, it fails...

Also, sql/lex_hash.h does not seem to be removed after a failed compilation
and make clean.

Thank you for your help!
[26 Sep 2004 14:30] Hartmut Holzgraefe
fixed with: bk commit into 4.0 tree (hartmut:1.2034)
[16 Feb 2005 11:07] Alexander Barkov
This bugs seems to be fixed long time ago,
Hartmut just forgot to close it.