[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xmlblaster] Compiling cpp client in mac osx
if have added a
struct hostent hostbuf, *hostP = 0;
hostP = gethostbyname_re(serverHostName, &hostbuf, &tmphstbuf,
printf("Hello '%s'\n", hostP->h_name);
to msgUtil.c, please check it out from svn and compile it with
gcc -g -Wall -o msgUtil msgUtil.c helper.c -I.. -DMSG_UTIL_MAIN=1
and now edit the settings in msgUtil.c and play with the different variants:
#ifndef _WINDOWS /* Windows does not support the reentrant ..._r()
# if defined(__sun)
# define HAVE_FUNC_GETHOSTBYNAME_R_5 /* SUN */
# elif defined(__alpha)
# define HAVE_FUNC_GETHOSTBYNAME_R_3 /* OSF1 V5.1 1885 alpha */
# elif defined(__FreeBSD__)
# define LOCAL_GETHOSTBYNAME_R /* FreeBSD */
/* this should actually work for other platforms... so long as they
support pthreads */
# elif defined(__hpux) /* with gcc 2.8 - 3.4.3 */
# define HAVE_FUNC_GETHOSTBYNAME_R_6 /* Linux */
... throw away everything and try the different defines directly.
(I know this is the most ugly code ever seen).
Please report which setting works for you and which __xyz??__ is defined
implicitely for MAC OS.
Ricardo Jorge Jota wrote:
What was the change you made?The problems is in the #include<malloc.h>
Did the C client compile well without changes (build c), where the
problems in C++ only?
Now, in Mac - using Fink - you have two include locations : /sw/lib
and /usr/lib. The sw is the Fink one, the usr is the os x system one.
The include malloc.h is in /usr/lib/malloc/malloc.h. In linux the
right path is: /usr/lib/malloc.h. In order to solve this I changed the
source code, but i'm not sure the best way to do this.
we should add an include directive into build.xml, for now you
could try in build.properties:
or on command line
build -verbose -DCFLAGS=-I/usr/lib/malloc c-delete c-lib
I think the problem lies within the -prebind flag. From what I could
gather this allows you to remove the gcc -L and -l flags. Although i'm
not sure about this it seams that the /sw/lib path -the fink path -
isn't prebound (OSX prebind all their dylib.). I'm not sure if you can
disable -prebind in the cpp-tasks when the MAC OSX system is found.
After this problem was solved the following command (the ./build
-verbose cpp showed me the command)
gcc -g -prebind -dynamiclib -o libxmlBlasterClientCD.dylib
../build.tmp/objCD/xmlBlasterZlib.old: warning prebinding disabled
because of undefined symbols
This is the C shared lib linking output on my Linux box:
gcc -g -shared -o libxmlBlasterClientCD.so
../build.tmp/objCD/xmlBlasterZlib.o -L/opt/sqlite-bin/lib -lsqlite
I wonder why cpptasks leaves away the sqlite and zlib in your case
(pthread is not needed explicitly on Linux).
This is just the thread safe variant of gethostbyname().
Unfortunately _gethostbyname_r doesn't get solved and after
"googling" it seems that this symbols doesn't exist in OS X.
Please add your own gethostbyname_r() variant in your code and
implement it using
I'd love to implement a new one. But I have some questions about you
code. First and foremost i'd like to test the ones already coded. Now
if I read you code correctly you use #defines to select the correct
one. As the darwin - the osx "kernel"- is mostly bsd maybe the bsd
implementation works. But I don't know how to find the correct #define
value for osx. Can you shed some light on this ?
Thank in advance,