MySQL won't compile. Something wrong with my ld?

I started trying to compile MySQL from source yesterday and I keep hitting the same problem. I’ve never had a problem compiling it in the past (although I don’t think I’ve tried doing it for about 18 months now). I tried compiling using my usual configure command, but I got an error after make had been running for about 20 minutes. So then I tried just using the basic command that the MySQL manual recommends to use just to see if I’d get the same error again, and I did.

Has Suse had its development tools restructured or something? It looks like a tool can’t be found to finish building the binaries. Here’s the last chunk of output before it gives up.

libtool: link: gcc -O3 -felide-constructors -fno-exceptions -fno-rtti -fno-implicit-templates -fno-exceptions -fno-rtti -rdynamic -o mysqld sql_lex.o sql_handler.o sql_partition.o item.o item_sum.o item_buff.o item_func.o item_cmpfunc.o item_strfunc.o item_timefunc.o thr_malloc.o item_create.o item_subselect.o item_row.o item_geofunc.o item_xmlfunc.o field.o strfunc.o key.o sql_class.o sql_list.o net_serv.o protocol.o sql_state.o lock.o my_lock.o sql_string.o sql_manager.o sql_map.o mysqld.o password.o hash_filo.o hostname.o sql_connect.o scheduler.o sql_parse.o set_var.o sql_yacc.o sql_base.o table.o sql_select.o sql_insert.o sql_profile.o sql_prepare.o sql_error.o sql_locale.o sql_update.o sql_delete.o uniques.o sql_do.o procedure.o sql_test.o log.o init.o derror.o sql_acl.o unireg.o des_key_file.o log_event.o rpl_record.o log_event_old.o rpl_record_old.o discover.o time.o opt_range.o opt_sum.o records.o filesort.o handler.o ha_partition.o debug_sync.o sql_db.o sql_table.o sql_rename.o sql_crypt.o sql_load.o mf_iocache.o field_conv.o sql_show.o sql_udf.o sql_analyse.o sql_cache.o slave.o sql_repl.o rpl_filter.o rpl_tblmap.o rpl_utility.o rpl_injector.o rpl_rli.o rpl_mi.o rpl_reporting.o sql_union.o sql_derived.o sql_client.o repl_failsafe.o sql_olap.o sql_view.o gstream.o spatial.o sql_help.o sql_cursor.o tztime.o my_decimal.o sp_head.o sp_pcontext.o sp_rcontext.o sp.o sp_cache.o parse_file.o sql_trigger.o event_scheduler.o event_data_objects.o event_queue.o event_db_repository.o events.o sql_plugin.o sql_binlog.o sql_builtin.o sql_tablespace.o partition_info.o sql_servers.o event_parse_data.o mini_client_errors.o pack.o client.o my_time.o my_user.o -static  ./.libs/libndb.a -lpthread -lpthread -lpthread -lpthread ../storage/csv/libcsv.a ../storage/heap/libheap.a ../storage/myisam/libmyisam.a ../storage/myisammrg/libmyisammrg.a ../vio/libvio.a ../mysys/libmysys.a ../dbug/libdbug.a ../regex/libregex.a ../strings/libmystrings.a -lz -lpthread -lcrypt -lnsl -lm -lpthread
**/usr/lib64/gcc/x86_64-suse-linux/4.4/../../../../x86_64-suse-linux/bin/ld: cannot find -lz**
collect2: ld returned 1 exit status
make[3]: *** [mysqld] Error 1
make[3]: Leaving directory `/mysql-5.1.46/sql'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/mysql-5.1.46/sql'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/mysql-5.1.46/sql'
make: *** [all-recursive] Error 1
home:/mysql-5.1.46 #

It says that ld can’t find “-lz”, but “-lz” looks like a command option rather than some sort of file.

I tried building the same source code on my Debian web host and it built without a hitch. Does anyone know why my Suse can’t seem to do it?

When ld looks for -lfoo, the library required is or libfoo.a. So the library required is libz.

Sorry, don’t see how old this post is.

The “-lz” is probably referring to a library since something like “-lmylib” used on the linking phase would refer to “libmyli.[a/so]”

Oh right. Well I have the zlib package installed which gives /lib64/ and /lib64/ so I don’t know why it won’t compile.

Oh and I just realized I forgot to say what the actual configure command was that I’m using. Just in case it makes any difference, I’m configuring with

CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static

before running make.

When building against a library called foo, usually the package foo-devel is required to provide the link information, whereas running only requires So did you install zlib-devel?

Yeah. I’m used to making sure I have devel packages. I found the package I needed now. I went looking for other packages that contained files with “libz” in the name and found the package zlib-devel-static which wasn’t installed along with the other libz related files.

As soon as I saw it I thought it might be what I needed because of the “–with-mysqld-ldflags=-all-static” option used in my configure command. So I installed it (which then provided me with /usr/lib64/libz.a) and tried compiling again. After installing the static package everything went perfectly. :smiley:

Thanks for everyone’s help. Especially clarifying what file was needed from the “cannot find -lz” output.