Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ Compiling the server ➜ compiling smuag with MYSQL under cygwin

compiling smuag with MYSQL under cygwin

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Pyromanci   (7 posts)  Bio
Date Mon 23 Feb 2009 02:12 AM (UTC)
Message
Ok i am trying to compile smuagfuss with a mysql option under cygwin. this is the top part of my make file.

CC = g++
#PROF = -p

#Uncomment to compile in Cygwin
CYGWIN = -DCYGWIN

#repoint these to your mysql directories
MYSQL = -L/usr/local/lib/mysql -I/usr/local/include/mysql/

#Uncomment the line below if you are getting undefined references to dlsym, dlopen, and dlclose.
#Comment it out if you get errors about ldl not being found.
NEED_DL = -ldl

#Some systems need this for dynamic linking to work.
EXPORT_SYMBOLS = -export-dynamic

# Uncomment the two lines below if compiling on a Solaris box
#SOLARIS_FLAG = -Dsun -DSYSV
#SOLARIS_LINK = -lnsl -lsocket

#IMC2 - Comment out to disable IMC2 support
#IMC = 1

W_FLAGS = -Wall -Werror -Wshadow -Wformat-security -Wpointer-arith -Wcast-align -Wredundant-decls

C_FLAGS = -g2 $(W_FLAGS) $(SOLARIS_FLAG) $(PROF) $(EXPORT_SYMBOLS)
L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) $(MYSQL)
#D_FLAGS : For the DNS Slave process. No need in linking all the extra libs for this.
D_FLAGS = -g2 -O $(PROF) $(SOLARIS_LINK)

C_FILES = act_comm.c act_info.c act_move.c act_obj.c act_wiz.c ban.c boards.c \
build.c calendar.c chess.c clans.c color.c comm.c comments.c const.c db.c deity.c \
dns.c fight.c handler.c hashstr.c hint.c hotboot.c imm_host.c interp.c \
liquids.c magic.c makeobjs.c mapout.c mapper.c mccp.c \
misc.c mpxset.c mud_comm.c mud_prog.c news.c planes.c player.c polymorph.c \
renumber.c reset.c save.c services.c sha256.c shops.c skills.c special.c tables.c \
track.c update.c variables.c weather.c mysql.c

As you can see i am pointing to the mysql folders, when i compile the mud i get

Compiling o/mysql.o....
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: warning: auto-importing has been activated without --enable-auto-import specified on th
command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.o/mysql.o: In function `_Z7open_dbv':
/home/smaugfuss/src/mysql.c:22: undefined reference to `_mysql_init'
/home/smaugfuss/src/mysql.c:27: undefined reference to `_mysql_real_connect'
/home/smaugfuss/src/mysql.c:30: undefined reference to `_mysql_close'
o/mysql.o: In function `_Z8close_dbv':
/home/smaugfuss/src/mysql.c:38: undefined reference to `_mysql_close'
Info: resolving __timezone by linking to __imp___timezone (auto-import)
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make: *** [all] Error 2

Any clues to what could be wrong?

I configured mySQL correctly when i built it or atleast i beleve so.
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 23 Feb 2009 02:33 AM (UTC)
Message
I seem to recall a recent similar problem. This is a linking issue if I read the post correctly.

You need to be cautious where the reference to mysql is in the line that does the linking.

Libraries you are offering to link against need to be specified *before* the files that need them. Putting them at the end of the line won't necessarily work.

eg. Change from:


$(CC) -o smaug.exe $(O_FILES) smaug.exp $(L_FLAGS)


to:


$(CC) -o smaug.exe $(L_FLAGS) $(O_FILES) smaug.exp


(If I am right). Worth trying.



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Pyromanci   (7 posts)  Bio
Date Reply #2 on Mon 23 Feb 2009 02:41 AM (UTC)

Amended on Mon 23 Feb 2009 03:00 AM (UTC) by Pyromanci

Message
I made the changes and get the same error. I also through it up on my hosting server just to see (with the proper corrections to the mysql folders) and i get the same errors.

I remember a few years ago i was doing something similar to what i am wanting to do now and had this issue, but i can't remember what i did to fix it.

--Edit

I was doing some more digging around and found i made a mistake.

#repoint these to your mysql directories
MYSQL = -L/usr/lib/mysql -I/usr/include/mysql/

#Uncomment the line below if you are getting undefined references to dlsym, dlopen, and dlclose.
#Comment it out if you get errors about ldl not being found.
NEED_DL = -ldl -lmysqlclient

forgot the mysqlclient call, but now i have a new error which i think is related to my mysql build.

mpress.c:(.text+0x66): undefined reference to `_compress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o):my_compress.c:(.text+0x11e): undefined reference to `_compress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o):my_compress.c:(.text+0x1e7): undefined reference to `_uncompress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o):my_compress.c:(.text+0x318): undefined reference to `_compress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o):my_compress.c:(.text+0x441): undefined reference to `_uncompress'
Info: resolving __timezone by linking to __imp___timezone (auto-import)
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make: *** [all] Error 2
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 23 Feb 2009 03:01 AM (UTC)
Message
Can you post your entire corrected Makefile please?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #4 on Mon 23 Feb 2009 03:09 AM (UTC)
Message
Where did you get your MySQL libraries from? If you want to compile anything in Cygwin using MySQL you need to build MySQL yourself (using Cygwin).

~Nick Cash
http://www.nick-cash.com
Top

Posted by Pyromanci   (7 posts)  Bio
Date Reply #5 on Mon 23 Feb 2009 03:10 AM (UTC)
Message
Yes it is in the mySQL build I ran the corrected makefile on the host (with the correct directories and no cygwin) and it compiled just fine. Though here is the make file like you asked for.

CC = g++
#PROF = -p

#Uncomment to compile in Cygwin
CYGWIN = -DCYGWIN

#repoint these to your mysql directories
MYSQL = -L/usr/lib/mysql -I/usr/include/mysql/

#Uncomment the line below if you are getting undefined references to dlsym, dlopen, and dlclose.
#Comment it out if you get errors about ldl not being found.
NEED_DL = -ldl -lmysqlclient

#Some systems need this for dynamic linking to work.
EXPORT_SYMBOLS = -export-dynamic

# Uncomment the two lines below if compiling on a Solaris box
#SOLARIS_FLAG = -Dsun -DSYSV
#SOLARIS_LINK = -lnsl -lsocket

#IMC2 - Comment out to disable IMC2 support
#IMC = 1

W_FLAGS = -Wall -Werror -Wshadow -Wformat-security -Wpointer-arith -Wcast-align -Wredundant-decls

C_FLAGS = -g2 $(W_FLAGS) $(SOLARIS_FLAG) $(PROF) $(EXPORT_SYMBOLS)
L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) $(MYSQL)
#D_FLAGS : For the DNS Slave process. No need in linking all the extra libs for this.
D_FLAGS = -g2 -O $(PROF) $(SOLARIS_LINK)

C_FILES = act_comm.c act_info.c act_move.c act_obj.c act_wiz.c ban.c boards.c \
build.c calendar.c chess.c clans.c color.c comm.c comments.c const.c db.c deity.c \
dns.c fight.c handler.c hashstr.c hint.c hotboot.c imm_host.c interp.c \
liquids.c magic.c makeobjs.c mapout.c mapper.c mccp.c \
misc.c mpxset.c mud_comm.c mud_prog.c news.c planes.c player.c polymorph.c \
renumber.c reset.c save.c services.c sha256.c shops.c skills.c special.c tables.c \
track.c update.c variables.c weather.c mysql.c

ifdef IMC
C_FILES := imc.c $(C_FILES)
C_FLAGS := $(C_FLAGS) -DIMC -DIMCSMAUG
endif

O_FILES := $(patsubst %.c,o/%.o,$(C_FILES))

H_FILES = $(wildcard *.h)

all:
$(MAKE) -s smaug
$(MAKE) -s dns

# pull in dependency info for *existing* .o files
-include dependencies.d

ifdef CYGWIN
smaug: $(O_FILES)
rm -f smaug.exe
dlltool --export-all --output-def smaug.def $(O_FILES)
dlltool --dllname smaug.exe --output-exp smaug.exp --def smaug.def
$(CC) -o smaug.exe $(O_FILES) smaug.exp $(L_FLAGS)
@echo "Generating dependency file ...";
@$(CC) -MM $(C_FLAGS) $(C_FILES) > dependencies.d
@perl -pi -e 's.^([a-z]).o/$$1.g' dependencies.d
@echo "Done compiling mud.";
chmod g+w smaug.exe
chmod a+x smaug.exe
chmod g+w $(O_FILES)

clean:
@rm -f o/*.o smaug.exe dependencies.d resolver.exe resolver.o *~

else
smaug: $(O_FILES)
rm -f smaug
$(CC) -export-dynamic -o smaug $(O_FILES) $(L_FLAGS)
@echo "Generating dependency file ...";
@$(CC) -MM $(C_FLAGS) $(C_FILES) > dependencies.d
@perl -pi -e 's.^([a-z]).o/$$1.g' dependencies.d
@echo "Done compiling mud.";
chmod g+w smaug
chmod a+x smaug
chmod g+w $(O_FILES)

clean:
@rm -f o/*.o smaug dependencies.d resolver resolver.o *~
endif

dns: resolver.o
rm -f resolver
$(CC) $(D_FLAGS) -o resolver resolver.o
@echo "Done compiling DNS resolver.";
chmod g+w resolver
chmod a+x resolver
chmod g+w resolver.o

indent:
indent -ts3 -nut -nsaf -nsai -nsaw -npcs -npsl -ncs -nbc -bls -prs -bap -cbi0 -cli3 -bli0 -l125 -lp -i3 -cdb -c1 -cd1 -sc -pmt $(C_FILES)
indent -ts3 -nut -nsaf -nsai -nsaw -npcs -npsl -ncs -nbc -bls -prs -bap -cbi0 -cli3 -bli0 -l125 -lp -i3 -cdb -c1 -cd1 -sc -pmt $(H_FILES)

indentclean:
rm *.c~ *.h~

o/%.o: %.c
echo " Compiling $@....";
$(CC) -c $(C_FLAGS) $< -o $@

.c.o: mud.h
$(CC) -c $(C_FLAGS) $<
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #6 on Mon 23 Feb 2009 03:13 AM (UTC)
Message
You missed this bit:


ifdef CYGWIN

...

$(CC) -o smaug.exe $(O_FILES) smaug.exp $(L_FLAGS)


Hence it didn't work under Cygwin.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Pyromanci   (7 posts)  Bio
Date Reply #7 on Mon 23 Feb 2009 04:41 AM (UTC)
Message
ok when i change
$(CC) -o smaug.exe $(O_FILES) smaug.exp $(L_FLAGS)
to this
$(CC) -o smaug.exe $(L_FLAGS) $(O_FILES) smaug.exp

I get this set of errors.
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: warning: auto-importing has been activated without --enable-auto-import specified on the
command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.o/comm.o: In function `_Z19write_to_descriptorP15des
criptor_dataPKci':
/home/Glenn/smaugfuss/src/comm.c:1664: undefined reference to `_deflate'
o/mccp.o: In function `_Z13compressStartP15descriptor_data':
/home/Glenn/smaugfuss/src/mccp.c:125: undefined reference to `_deflateInit_'
o/mccp.o: In function `_Z11compressEndP15descriptor_data':
/home/Glenn/smaugfuss/src/mccp.c:150: undefined reference to `_deflate'
/home/Glenn/smaugfuss/src/mccp.c:156: undefined reference to `_deflateEnd'
o/mysql.o: In function `_Z7open_dbv':
/home/Glenn/smaugfuss/src/mysql.c:22: undefined reference to `_mysql_init'
/home/Glenn/smaugfuss/src/mysql.c:27: undefined reference to `_mysql_real_connect'
/home/Glenn/smaugfuss/src/mysql.c:30: undefined reference to `_mysql_close'
o/mysql.o: In function `_Z8close_dbv':
/home/Glenn/smaugfuss/src/mysql.c:38: undefined reference to `_mysql_close'
Info: resolving __timezone by linking to __imp___timezone (auto-import)
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make: *** [all] Error 2
Top

Posted by Pyromanci   (7 posts)  Bio
Date Reply #8 on Mon 23 Feb 2009 04:50 AM (UTC)
Message
Got it. Did some more reading on mysql's site and found this can happen. ran the

mysql_config --libs

and it returned
-L/usr/local/lib/mysql -lmysqlclient -lz -lcrypt -lm

So i added -lz -lcrypt -lm into the mysql part of my make file and it compiled just fine.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


24,438 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.