plans for macosx build?

198 views
Skip to first unread message

Karl Yerkes

unread,
Jul 8, 2012, 9:37:14 PM7/8/12
to lib...@googlegroups.com
i noticed that there's no osx binary or build process.  are there plans for this?  i've tried to get libxbee built on osx, but i'm stuck on linking.  if anyone has information on this, please post it or let me know.

-- karl

Attie

unread,
Jul 9, 2012, 2:43:32 PM7/9/12
to lib...@googlegroups.com
Hi Karl,

I've asked to borrow a colleague's mac during lunch tomorrow. I'll try to get everything sorted, but will only be able to do a minimal amount of testing.

I'll keep you posted!

Attie

unread,
Jul 10, 2012, 10:01:22 AM7/10/12
to lib...@googlegroups.com
Hi Karl,

I just spent some time with a mac.

I got to the linking stage, and it complained about the -soname option. I just removed that, and then it complained about missing symbols.
This could be caused because I'm using '-fvisibility=hidden' (link). You could try removing this, or changing it to '=default' instead, to see what happens.
Unfortunately my colleague needed his computer back at that point.

If you get it going, I'd really appreciate a patch or even an tarball of your libxbee directory! Then I'll try to get it in the repository.

Attie

Karl Yerkes

unread,
Jul 13, 2012, 3:45:47 AM7/13/12
to lib...@googlegroups.com
Attie --

I read that 'soname' is called 'install_name' on osx.

Removing the '-fvisibility=hidden' flag fixed the linking errors, except for one:

gcc -shared -Wl,-install_name,libxbee.so.3.0.7 -fPIC  -g lib/libxbee.o -o lib/libxbee.so.3.0.7
Undefined symbols for architecture x86_64:
  "_sem_timedwait", referenced from:
      _xbee_conCallbackHandler in libxbee.o
      _xbee_frameWait in libxbee.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [lib/libxbee.so.3.0.7] Error 1

It seems that osx does not have sem_timedwait(), so I grabbed this guy's solution and got stuff to compile and link, but it's not pretty yet and I have not tested the examples with xbees--I'll post on that as soon as I can.

Also, I don't know if libxbee's license is congruent with the sem_timedwait solution I used:

 *  Copyright (c) Australian Astronomical Observatory.
 *  Commercial use requires permission.
 *  This code comes with absolutely no warranty of any kind.

Thoughts?

-- karl

Attie Grande

unread,
Jul 22, 2012, 5:41:43 AM7/22/12
to Karl Yerkes, lib...@googlegroups.com
Hi Karl,

Sorry for the delayed response!

Did you manage to get it compiled and working for OSX?

Thanks for the link! I think I'll not bring it in as a solution just yet due to licensing.
Perhaps if there is more demand for OSX I will look into it.

    Attie

--
You received this message because you are subscribed to the Google Groups "libxbee" group.
To view this discussion on the web visit https://groups.google.com/d/msg/libxbee/-/H55RGoq52-kJ.

To post to this group, send email to lib...@googlegroups.com.
To unsubscribe from this group, send email to libxbee+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/libxbee?hl=en.

Karl Yerkes

unread,
Jul 24, 2012, 5:06:07 PM7/24/12
to Attie Grande, lib...@googlegroups.com
i got it compiled and linked on Mac OSX 10.6 and 10.7, but my friend could not get it working with his series 1 xbees.  this might be his lack of hacking savvy;  i didn't test it myself.  in any case, we're going with AT mode for our project until we run into some problem that would demand API mode.

-- karl

Attie Grande

unread,
Jul 24, 2012, 6:01:10 PM7/24/12
to Karl Yerkes, lib...@googlegroups.com
Hi Karl,

Thanks for the info!
Would you mind sharing your process, and I'll see if I can get anything going with a Mac when I can get my hands on one.

Good luck with your project!
    Attie

attie.co.uk  |  at...@attie.co.uk

Jan Rüth

unread,
Mar 11, 2013, 10:54:19 AM3/11/13
to lib...@googlegroups.com, Karl Yerkes
I just compiled it for OS X, however there are a couple of things that are complicated.

At first, there is no clock_gettime() on os x, I added an alternative function (stackoverflow gives hints) and added
#ifdef __MACH__  macros to switch for the implementation on os x.

Another problem is, os x does not implement sem_timedwait(), I added a dirty implementation (just to see if it compiles) along these lines:

#ifdef __MACH__

        struct timespec to;

        current_utc_time(&to);

        while (sem_trywait(&con->callbackSem) != 0) {

            if (sem_trywait(&con->callbackSem) == EINVAL) {

                ret = XBEE_ESEMAPHORE; // semaphone is invalid

            }

            sleep(1);

            current_utc_time(&to);

            if (to.tv_sec > timeout->tv_sec && to.tv_nsec > timeout->tv_nsec) { // timeout break local while

                ret = XBEE_ETIMEOUT;

                break;

            }

        }

        

#else

        

if (xsys_sem_timedwait(&frame->sem, timeout)) {

if (errno == ETIMEDOUT) {

ret = XBEE_ETIMEOUT;

} else {

ret = XBEE_ESEMAPHORE;

}

}

#endif


Then, actually the code should compile however, as noted before the -fvisibility=hidden somehow makes os x lose symbols during linking.

I added a os.darwin.mk file (a copy from os.unix.mk) where I commented that line out.

I also changed there build and install rules to use a *.darwin.mk which are again copies from the *.unix.mk just with all occuranes of .so replaced by .dylib

In the build.darwin.mk (cat make/build.unix.mk | sed -e 's/\.so/\.dylib/g' > make/build.darwin.mk) I commented out the OBJCOPY lines as OS X does not have OBJCOPY (one can possibly simulate that behavior with dsymutil, strip, nm), furthermore I changed the -soname to -install_name.

 To make it use this I also added to make/os_detect.mk:


ifeq ($(shell uname),Linux)

include make/os.linux.mk


# detect freebsd

else ifeq ($(shell uname),FreeBSD)

include make/os.freebsd.mk


# detect windows

else ifeq ($(OS),Windows_NT)

include make/os.windows.mk


# detect os x (darwin)

else ifeq ($(shell uname),Darwin)

include make/os.darwin.mk


This then builds successfully the C part, however the C++ makes problems, it seems to be unable to automatically find all required dependencies which have already been compiled, this might be due to the missing -fvisibility=hidden, I don't know, I was able to get it compile by manually giving all dependent objects to ld:

$(DESTDIR)/$(LIBNAME)p.o: .$(DESTDIR).dir $(BUILDDIR)/__corep.o $(BUILDDIR)/conn.o $(BUILDDIR)/ll.o $(BUILDDIR)/log.o $(BUILDDIR)/thread.o $(BUILDDIR)/ostime.o $(BUILDDIR)/frame.o $(BUILDDIR)/mode.o  $(BUILDDIR)/mutex.o $(BUILDDIR)/pkt.o $(BUILDDIR)/tx.o $(BUILDDIR)/rx.o $(BUILDDIR)/xbee.o $(BUILDDIR)/error.o $(BUILDDIR)/__mode.o $(BUILDDIR)/__mode_debug.o $(BUILDDIR)/__mode_net.o $(BUILDDIR)/__mode_xbee1.o $(BUILDDIR)/__mode_xbee2.o $(BUILDDIR)/__mode_xbee5.o $(BUILDDIR)/__mode_xbeeZB.o $(BUILDDIR)/ver.o $(BUILDDIR)/net_io.o $(BUILDDIR)/net_handlers.o $(BUILDDIR)/net_callbacks.o $(BUILDDIR)/net.o $(BUILDDIR)/xsys.o

$(LD) -r -o $@ $(filter %.o,$^)


This then compiles :) (*note the ostime.o is generated by the own implementation of the time function)


This is far from beautiful, but it works.

Attie Grande

unread,
Mar 11, 2013, 10:59:51 AM3/11/13
to Jan Rüth, libxbee, Karl Yerkes
Hi Jan,

Thanks very much for your efforts!
Would you be able to provide me with a patch, or perhaps an archive of your working directory?
I'll take a look, maybe tidy it up a bit and try to get it in the repo.

Attie
To unsubscribe from this group and stop receiving emails from it, send an email to libxbee+u...@googlegroups.com.
To post to this group, send an email to lib...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msg/libxbee/-/r9L8IsrqdTIJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jan Rüth

unread,
Mar 11, 2013, 11:20:06 AM3/11/13
to lib...@googlegroups.com, Jan Rüth, Karl Yerkes
Hi Attie,

sure I can do that, I also forgot to mention that I had to add a

#ifdef __MACH__

#define MSG_NOSIGNAL SO_NOSIGPIPE

#endif

to net_io.c as MSG_NOSIGNAL is not available on os x, however SO_NOSIGPIPE has similar behavior on os x.


Attached you find a patch which adds what I just described, however I haven't tested anything, I started looking at the project some hours ago.
I create the patch against the following commit: git diff ef897911c54c0d1dfb9454bdffbf10d1bc7fcf70 > os_x.patch 


However, as I haven't tested anything (I don't have the xbee1 I have with me right now) I would mark the os x compatability still as broken, mostly because of the workaround to semaphore wait timeout which isn't available on os x...


Have a nice day

 Jan

os_x.patch

Attie Grande

unread,
Mar 11, 2013, 11:30:35 AM3/11/13
to Jan Rüth, libxbee, Karl Yerkes
Awesome, thanks Jan.

It would be good to have an update from you when you have an XBee to hand - I don't normally get much (any) time with a Mac.
I'll hopefully take a look this evening, and probably pop it on my OSX branch (http://git.attie.co.uk/?p=libxbee/libxbee3;a=shortlog;h=refs/heads/osx) until further notice.

Attie
To view this discussion on the web, visit https://groups.google.com/d/msg/libxbee/-/s-cFDm1qkDcJ.

Jan Rüth

unread,
Mar 11, 2013, 11:33:04 AM3/11/13
to lib...@googlegroups.com, Jan Rüth, Karl Yerkes
Well, I will actually work with linux and the xbee, however I tend to work with a mac, and I thought, when I develop something it could be useful to test it directly on my mac without VM or another device...

It could take some more days until I'll actually do something with the xbee

Attie Grande

unread,
Mar 11, 2013, 11:35:36 AM3/11/13
to Jan Rüth, libxbee, Karl Yerkes
Ok, no problem. Thanks for your effort so far, if you do get confirmation that would be a bonus!
Obviously performance would be poor due to that sleep in your sem_timedwait implementation, but slow is better than not supported :-)
To view this discussion on the web, visit https://groups.google.com/d/msg/libxbee/-/ImZ-SmvpxE4J.

Jan Rüth

unread,
Mar 14, 2013, 9:40:02 AM3/14/13
to lib...@googlegroups.com, Jan Rüth, Karl Yerkes
Hi,

I changed some stuff. I use the xsys system now to get the time and implement the semaphores on os x. I used the semaphone timedwait implementation  you can find here http://www.aao.gov.au/local/www/ks/uploads/sem_timedwait.c I don't know if the license fits this project...

The included patch is a diff on the last one I uploaded!

Greetings
 Jan
osx_patch2.diff

Attie Grande

unread,
Mar 14, 2013, 12:52:55 PM3/14/13
to Jan Rüth, libxbee, Karl Yerkes
Fantastic! Thanks Jan.

I have a Mac right next to me now, but I've been a bit busy.... I'll check this out when I can.

I'll also contact the author of the sem_timedwait() implementation that you found and ask for permission to use it.

Attie
To view this discussion on the web, visit https://groups.google.com/d/msg/libxbee/-/8yITRXDuMBsJ.
Reply all
Reply to author
Forward
0 new messages