[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster] Compiling cpp client in mac osx

Ricardo Jorge Jota wrote:

Regarding the compilation:

Neither the build.properties CFLAGS or the command line worked. I shouldn't worry about this, using a include directive should work.
Here it works, i have tried:

 build -verbose -DCFLAGS=-I/usr/lib/malloc c-delete c-lib

and this created:

 gcc -I/usr/lib/malloc -Wall ...

But what i have seen is that multiple settings in CFLAGS are not correctly passed to gcc (they are quoted if passed in build.properties).

I'm a bit stuck in this case as i have no MacOSX at hand.

To summarize:

- The C and C++ code works fine on MacOSX (compiled manually)
- The build process with ant needs currently three workarounds for simple compilation


Regarding the msgUtil.c and gethostbyname_r:

From what I could gather __MacOSX__ should be implicitly defined. I made the following change on msgUtil:

#ifndef _WINDOWS /* Windows does not support the reentrant ..._r() functions */
# if defined(__sun)
# elif defined(__alpha)
# define HAVE_FUNC_GETHOSTBYNAME_R_3 /* OSF1 V5.1 1885 alpha */
# elif defined(__FreeBSD__)
/* this should actually work for other platforms... so long as they support pthreads
Jota -> it Does! I used it on MacOSX */
# elif defined(__MacOSX__)
# elif defined(__hpux) /* with gcc 2.8 - 3.4.3 */
# else
//!!!Jota - OSX is a BSD-like system, thus defining LOCAL_GETHOSTBYNAME_R also works on OSX.
//!!!It should be react to __MacOSX__ but my system didn't acknowlegde the define.
# define HAVE_FUNC_GETHOSTBYNAME_R_6 /* Linux */
# endif

It compiled and worked! Thus the code for BSD also works on Mac. - results below -

cesar:~/src/xmlBlaster/src/c/util jota$ gcc -g -Wall -o msgUtil msgUtil.c helper.c -I.. -DMSG_UTIL_MAIN=1 -D__MacOSX__
cesar:~/src/xmlBlaster/src/c/util jota$ ./msgUtil
Hello 'localhost'

But xmlBlaster still has problems in the ./build process. It seems that the __MacOSX__ isn't defined. In order to compile I changed the

#  elif defined(__hpux) /* with gcc 2.8 - 3.4.3 */
#  else
#    define HAVE_FUNC_GETHOSTBYNAME_R_6 /* Linux */
#  endif


#  elif defined(__hpux) /* with gcc 2.8 - 3.4.3 */
#  else
#    define LOCAL_GETHOSTBYNAME_R /* Linux */
#  endif

Also, the prebind problem still exists. Unfortunately I don't have experience with the cppTasks. Can we change options in cppTasks so that the prebind doesn't get used?

In short:

- The malloc.h is in the wrong place. XmlBlaster need an include directive
- Even though the BSD code works, the __MacOSX__ doesn't seem to be defined.
- In binding phase , MacOSX uses prebind (as do the cppTasks). We need a workabout on this, maybe turn it off and using the old fashion -L/usr/lib -L/sw/lib -lsqlite -lz

Thanks, Ricardo Jota