views:

218

answers:

1

I'm attempting to build GreenSQL 1.2.2 on Mac OS X 10.5.8 Leopard Server, but I get the following errors (which appear to be an ld error?):

cc -g -Wall -I/usr/local/include/ -I/usr/include/mysql/ -I/usr/local/include/mysql/ -DHAVE_MYSQL_CLIENT -fPIC -c -Wall sql_api.c
cc -g -Wall -I/usr/local/include/ -L/usr/lib64/mysql -L/usr/local/lib/mysql -L/usr/lib/mysql -lmysqlclient -shared -Wl,-soname,libgsql-mysql.so.1  -DHAVE_MYSQL_CLIENT -o libgsql-mysql.so.1 sql_api.o
ld: unknown option: -soname
collect2: ld returned 1 exit status
make[2]: *** [api] Error 1
make[1]: *** [greensql-fw] Error 2
cp: greensql-fw: No such file or directory
make: *** [greensql-fw] Error 1

I have already built and installed (into /usr/local) the following prerequisites: pcre 8.01, libevent 1.4.13-stable, as well as the MySQL client binaries & headers (per http://support.apple.com/kb/TA25017, although I installed MySQL-45.binaries.tar.gz as I'm on Mac OS X 10.5.8).

I'm pretty familiar with building open source software on Mac OS X, but I have to admit there are definitely a lot of ins and outs of command line compiling I do not know. I have not run into ld errors before (and didn't see anything in the Makefile that jumped out at me). I could not find mention of a -soname option in the man page for ld.

Any suggestions would be greatly appreciated.

Update #1: I found the occurrence of -soname in src/lib/Makefile, replaced it with -install_name and got a little further. Now I get the following:

cc -g -Wall -I/usr/local/include/ -I/usr/include/mysql/ -I/usr/local/include/mysql/ -DHAVE_MYSQL_CLIENT -fPIC -c -Wall sql_api.c
cc -g -Wall -I/usr/local/include/ -L/usr/lib64/mysql -L/usr/local/lib/mysql -L/usr/lib/mysql -lmysqlclient -shared -Wl,-install_name,libgsql-mysql.so.1  -DHAVE_MYSQL_CLIENT -o libgsql-mysql.so.1 sql_api.o
Undefined symbols:
  "_compress", referenced from:
      _my_compress_alloc in libmysqlclient.a(my_compress.o)
      _my_compress in libmysqlclient.a(my_compress.o)
  "_main", referenced from:
      start in crt1.10.5.o
  "_uncompress", referenced from:
      _my_uncompress in libmysqlclient.a(my_compress.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [api] Error 1
make[1]: *** [greensql-fw] Error 2
cp: greensql-fw: No such file or directory
make: *** [greensql-fw] Error 1

Update #2: Further edits to src/lib/Makefile, this time adding -lz to the end of CXXFLAGS gets past the compression errors. The errors are now as follows:

cc -g -Wall -I/usr/local/include/ -lz -I/usr/include/mysql/ -I/usr/local/include/mysql/ -DHAVE_MYSQL_CLIENT -fPIC -c -Wall sql_api.c
i686-apple-darwin9-gcc-4.0.1: -lz: linker input file unused because linking not done
cc -g -Wall -I/usr/local/include/ -lz -L/usr/lib64/mysql -L/usr/local/lib/mysql -L/usr/lib/mysql -lmysqlclient -shared -Wl,-install_name,libgsql-mysql.so.1  -DHAVE_MYSQL_CLIENT -o libgsql-mysql.so.1 sql_api.o
Undefined symbols:
  "_main", referenced from:
      start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [api] Error 1
make[1]: *** [greensql-fw] Error 2
cp: greensql-fw: No such file or directory
make: *** [greensql-fw] Error 1
A: 

Edited: answered a little too fast... so removed original answer.

Try with -dylib_install_name instead of -so_name (and have dylib as extension instead of .so).

ChristopheD
Thanks for the suggestions. Unfortunately, there is no `libgsql-mysql.so.1` in any subdirectory of my build directory. I was assuming that since it occurred immediately after the `-soname` option that that's what they're trying to name the library (and 'gsql' probably referring to 'greensql').Also, I don't see any call to `ld` in any of the Makefiles in the source. Maybe I missed one?
morgant
Hmm, you're probably correct about the lib name. Could you try replacing `-soname` the following flag `-dylib_install_name` (somewhere in LD_FLAGS probably) ? Don't forget to `make clean`
ChristopheD
Hmm, I'm not sure where in LD_FLAGS that should go. There are no LD_FLAGS set (or other references to 'ld' in any of the four make files: `Makefile`, `src/Makefile`, `src/parser/Makefile`, or `src/lib/Makefile`.
morgant
Actually, I take it back, I did find the occurrence of `-soname` in `src/lib/Makefile` and got a little further (see updated question). Still more errors, but a good start.
morgant
For compress / uncompress I think (sorry I don't have a lot of time for elaborate answers now) you just need zlib. On my snow leopard install it is present in /usr/lib (libz...dylib). You could try adding the -lz flag?
ChristopheD
No worries about non-elaborate answers. It's been too long since I had to this level of troubleshooting, so I appreciate the reminders and tips. Yeah, zlib is there, and adding `-lz` to the end of CXXFLAGS in `src/lib/Makefile` does get past that particular error. Still more though (see updated question).
morgant
Not really sure about that error (I'm a Linux user gone Mac for 3 months now) but the following approach I found on google may be worth a try: http://software.intel.com/en-us/forums/showthread.php?t=63435 You may need to change the path to match yours...
ChristopheD