listserver-v2 --no-mysql try to compile CMySQL.cpp (gmake)

[paul@localhost build]$ ./premake4 –no-mysql gmake

[paul@localhost build]$ make
==== Building serverlist2 (debug) ====
Creating obj/Debug
codec.cpp
CMySQL.cpp
TServer.cpp

Linking serverlist2
obj/Debug/CMySQL.o: In function ~CMySQL': /home/paul/graal_reborn/serverlist-v2/trunk/build/projects/../../[B]server/src/CMySQL.cpp:24: undefined reference tomysql_close’[/B]
obj/Debug/CMySQL.o: In function CMySQL::connect()': /home/paul/graal_reborn/serverlist-v2/trunk/build/projects/../../[B]server/src/CMySQL.cpp:31: undefined reference tomysql_init’[/B]

are warnings considered bugs?

I think it was an error.
Now I remember: it was an error.
The code is calling functions that are not given at link time. Looks like a good reason to stop linking without making an exec.

Cannot easily retry it here, because I am now on Windows and get the well known snprintf error with mingw32-make:

C:\graal_reborn\serverlist-v2\trunk\build>mingw32-make
“==== Building serverlist2 (debug) ====”
Creating obj/Debug
CFileSystem.cpp
CLog.cpp
CMySQL.cpp
codec.cpp
CSettings.cpp
CSocket.cpp
In file included from …/…/server/include/CString.h:6:0,
from …/…/server/include/CLog.h:7,
from …/…/server/src/CSocket.cpp:81:
c:\mingw\bin\…/lib/gcc/mingw32/4.6.2/include/c++/cstdio:166:11: erreur: ‘::snpr
intf’ has not been declared
c:\mingw\bin\…/lib/gcc/mingw32/4.6.2/include/c++/cstdio:176:22: erreur: ‘_gnu
cxx::snprintf’ has not been declared
…/…/server/src/CSocket.cpp: In function ‘const char* errorMessage(int)’:
…/…/server/src/CSocket.cpp:788:33: erreur: ‘snprintf’ was not declared in this
scope
mingw32-make[1]: *** [obj/Debug/CSocket.o] Error 1
mingw32-make: *** [serverlist2] Error 2

Which is cool because I had log on this forum to find back this error!
To ask about it on MinGW-user mailing list.

The problem seems to be that under Linux (64 bits), the …/premake4 --no-mysql gmake seems to give as Makefile:

... OBJDIR = obj/Debug TARGETDIR = ../../bin TARGET = $(TARGETDIR)/serverlist2_d DEFINES += -DDEBUG INCLUDES += -I../../server/include -I../../dependencies/include -I../../dependencies/zlib -I../../dependencies/bzip2 CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES) CFLAGS += $(CPPFLAGS) $(ARCH) -g CXXFLAGS += $(CFLAGS) LDFLAGS += -L../../dependencies LIBS += RESFLAGS += $(DEFINES) $(INCLUDES) LDDEPS += LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS) define PREBUILDCMDS ...
See that DEFINES -DNO_MYSQL is not there … it is not before either.
Because of the --no-mysql option, LIBS does not have -Lmysqlclient … which cause Linking bugs because SQL functions were compiled (and should not).
I looked at the premake4.lua but I don’t find why.
Seems to work fine under MinGW however.

Note that without the --no-mysql option, it does compile and links fine.

Edit: Found the bug!
Because the defines no-mysql was tested after configuration “windows”, it was not tested under Linux.
Moving it just before --Libraries line fix it.
So basically, the indentation for configuration is not used I think… guess it applies until next configuration.
Will commit a fix for it.

Premake on linux shouldn’t use those dependencies. Only for minupnp if it’s not available on the OS. It should use the system include directories to make sure you use a up to date version of zlib, bzlip etc.

I just committed a fix that goes in that direction. It use zlib (libz) on your system if it is found.
But bzip2 does not seems to be on my default developer Linux Mageia system, and I think it is not so common to have it by default. But guess the way I made it with zlib, that should apply well to bzip2 too.

I just copy the patch I commited here for a fast look:
Patch uncommitted, it was foolish! Using our header, with system lib. Looks quite a bit harder, I will probably nerver to do it right.

[CODE]Index: trunk/build/premake4.lua

— trunk/build/premake4.lua (revision 1155)
+++ trunk/build/premake4.lua (working copy)
@@ -35,14 +35,21 @@
if _OPTIONS[“no-boost”] then
defines { “NO_BOOST” }
end

  •   -- Dependencies.
    
  •   files { "../dependencies/zlib/**" }
    
  •   -- miniupnpc for every os since it is uncommon to have them on Linux distro (I think!)
    
  •   files { "../dependencies/miniupnpc/**" }
    
  •   files { "../dependencies/bzip2/**" }
    
  •   files { "../dependencies/miniupnpc/**" }
      includedirs { "../dependencies" }
    
  •   includedirs { "../dependencies/zlib" }
      includedirs { "../dependencies/bzip2" }
    
  •   if os.findlib("z") then
    
  •   	printf("found zlib on the system, using it")
    
  •   	links {"z"}
    
  •   else
    
  •   	printf("zlib not found on the system, we'll use the one in the project")
    
  •   	files { "../dependencies/zlib/**" }
    
  •   	includedirs { "../dependencies/zlib" }
    
  •   end
      
      -- Libraries.
      configuration "windows"
    

@@ -62,6 +69,7 @@
configuration { “windows”, “x64” }
defines { “WIN64”, “_WIN64” }
end

  •   -- Dependencies (Windows only, we expect others to have those)
    
      -- Linux defines.
      configuration "Linux"[/CODE]