Re: LANDIS-II on Mac?

329 views
Skip to first unread message

Xi, Weimin

unread,
Jul 11, 2011, 11:22:03 AM7/11/11
to landis-...@googlegroups.com
Hi Rob, Jim and all,

Is there a version of LANDIS-II for Mac users or will have one in future?

Thanks,
Weimin

James Domingo

unread,
Jul 19, 2011, 6:25:25 PM7/19/11
to landis-...@googlegroups.com
Hi Weimin,

L-II 5.1 is cross-platform so if you have it installed on a Windows
machine, you can just copy the C:\Program Files\LANDIS-II\5.1\ folder
over to an OS X machine, install the Mono runtime (URL), and run L-II
with Mono.

L-II 6.0 contains some binary components that are Windows-specific so
the steps above won't work. Although some binary pieces of 6.0 are
platform-specific, the source code for all the components is cross-
platform. So it is possible for someone with the proper developer
tools on an OS X machine to build binary versions of the platform-
specific components for OS X. One developer has reported doing this
successfully with 6.0 b3 and OS X 10.6 (snow leopard).

Jimm
--
James Domingo
Green Code LLC

Robert Scheller

unread,
Jul 20, 2011, 11:40:49 AM7/20/11
to landis-...@googlegroups.com
Weimin,

Ben Sulman at UW-Madison compiled for the Mac.  His 'recipe' can be found below.  I haven't tried it myself.

Good luck!

Rob

Setting up GDAL C# components on Mac OS X for LANDIS-II

Software I have:
Mac OS X version 10.6.7, with developer tools installed
2.4 GHz Intel Core 2 Duo
Mono version 2.6.7, architecture x86
LANDIS-II version 6.0 (b3)
gdal 1.8.0 source (http://download.osgeo.org/gdal/gdal-1.8.0.tar.gz)


LANDIS-II version 6 requires a gdal_wrap dynamic library that is compatible with mono.  Some of the dll files included with the LANDIS distribution are C# files that mono can read, but others are Windows-compiled libraries that need to be replaced with libraries compiled for Mac.  There were two major issues I had to solve to make the GDAL C# components work with mono on my machine:
A.  Mac OS X compiles programs with 64-bit architecture by default, which makes the files incompatible with 32-bit Mono program
B.  The GDAL distribution does not produce a shared library version of gdal_wrap


Here is the basic procedure I used to compile the gdal_wrap library:
1.  Download and unpack the source code for gdal
2.  cd gdal-1.8.0/
3.  Run ./configure
4.  Add this line to gdal-1.8.0/GDALmake.opt (I did this at line 74):
USER_DEFS       =  -arch i386 -arch x86_64

and at line 78:
LDFLAGS     = -arch i386 -arch x86_64

This makes the compiler produce a "fat" file including both 32-bit (i386) and 64-bit (x86_64) architectures.  You can also include just the i386 part, which should produce smaller files and compile faster, but may be less ideal if you plan on using the gdal libraries with other programs that might be 64-bit.
IMPORTANT: You need to be consistent with the architectures you include throughout the compilation process or you will probably get errors, so if you are just doing i386, omit the "-arch x86_64" part of the argument for all the subsequent steps.

5.  make

Before moving on, you can test the output files using the lipo utility:
lipo -info .libs/libgdal.dylib

This should produce output like:
Architectures in the fat file: ../../.libs/libgdal.dylib are: i386 x86_64
or:
Non-fat file: .libs/libgdal.dylib is architecture: i386

If the i386 architecture is not included, there was a problem and things will not work down the line.
6.  sudo make install
This should install the libraries in /usr/local/lib, and mono and further compiling steps should be able to find them.
7.  cd swig
8.  make
Note: this produces files necessary for gdal bindings to several languages including sharp, ruby, python, and java.  If some of those fail or all you want is csharp, you can go into the GNUmakefile in the swig directory and edit the ALL_BINDINGS line to include just the languages you want.
9.  cd csharp
10.  make
11.  make test
All the tests might not work if you are missing some other libraries that gdal uses.  if you get an error:

Error occurred: dlopen(libproj.dylib, 1): image not found

I don't this is a problem for LANDIS, since LANDIS does not use libproj

The library should be working correctly with mono if you get this far:
LC_ALL=C mono createdata.exe Data pointlayer

Layer name: pointlayer
Feature Count: 1
Extent: 47,47,19.2,19.2
Layer SRS WKT: (unknown)
Field definition:
Name: String (32.0)
IntField: Integer (0.0)
DbleField: Real (0.0)
DateField: Date (0.0)

…

If it failed, you will get a message that a library was not found.  A way to test further is to run mono with lots of extra output:
MONO_LOG_LEVEL=debug mono createdata.exe Data pointlayer

This produces a lot of lines like:
Mono-INFO: DllImport error loading library: 'dlopen(libogrcsharp.dylib, 9): image not found'.

If one of the lines looks like this:

Mono-INFO: DllImport error loading library: 'dlopen(libgdal_wrap.dylib, 9): no suitable image found.  Did find:
    libgdal_wrap.dylib: mach-o, but wrong architecture'.

then it found a library but the library did not have the correct 32-bit architecture.  Otherwise, if it fails then the files themselves are not in a place that mono can find them.  Check if there are the correct libraries in gdal-1.8.0/swig/csharp/.libs, and use lipo to make sure they include the i386 architecture.

12.  You need to produce a libgdal_wrap.dylib file:
g++ -Wl,-single_module -dynamiclib -arch i386 -o libgdal_wrap.dylib gdal_wrap.o /usr/local/lib/libgdal.dylib

13.  Move the file to a place where mono will find it:
sudo cp libgdal_wrap.dylib /usr/local/lib


With luck, LANDIS-II version 6 should now be able to find the GDAL libraries and run.  Apologies if I skipped any steps by accident.  I wrote this up while retracing my steps a couple days after staying up late figuring this out.

--Ben Sulman

Xi, Weimin

unread,
Jul 20, 2011, 11:47:19 AM7/20/11
to landis-...@googlegroups.com
Thanks! Rob, Jim and Ben. This is helpful. Some of the students in
Beijing LANDIS-II workshop may bring their own Mac, and I will ask them
try before the workshop...

Weimin

> --
> You received this message because you are subscribed to the Google
> Groups "LANDIS-II Users" group.
>
> To see the discussion, visit this group at
> http://groups.google.com/group/landis-ii-users
>
> To unsubscribe from this group, send email to
> landis-ii-use...@googlegroups.com

Inga

unread,
Jul 21, 2011, 9:56:21 AM7/21/11
to LANDIS-II Users
Running LANDIS-II on Parrallels Desktop for Mac (80USD) or Bootcamp
(included with Snow Leopard) are the easy outs, but only if they have
access to a Windows license.

Inga
> > …

Adam Erickson

unread,
Dec 10, 2012, 2:57:56 PM12/10/12
to landis-...@googlegroups.com
Hi Everyone,

I used the Sulman Mac OS X recipe and did not have much success. If anyone can offer any insight, I'm running Mac OS X 10.8.2 Mountain Lion and tried to install the LANDIS-II v6.0 RC3 64-bit Windows executable. The gdal source code I downloaded and compiled is version 1.9.2 and I also installed the latest version of Mono runtime, which is 2.10.10.

I tried to compile the dynamic gdal_wrap library as mentioned, first in x86_64 format only, and second, as 'fat' files with both Intel 32-bit and 64-bit compatibility. Neither worked. With just the x86_64 format, the lipo utility worked. With 'fat' files, the lipo utility failed to produce results. I never did get the pointlayer example to work. There were many errors throughout the process.

I've learned that Mono VM itself seems to run in 32-bit. From this Mono webpage (http://www.mono-project.com/Mono:OSX#32_and_64_bit_support), it looks like I can compile my own Mono source code to make a 64-bit installation Mono VM and get around the whole 32-bit Intel 386/80386 issue. I hope to try this method this evening. I'm a long-time Windows user turned Mac user, so we'll see how it goes.

Cheers,

Adam Erickson, PhD Student
Integrated Remote Sensing Studio
Department of Forest Resources Management
University of British Columbia

Hardware:
MacBook Pro 15"
2.3 GHz Intel Core i7 (quad-core)
16 GB 1600 MHz DDR3
250 GB SSD
NVIDIA GeForce GT 650M 1024 MB

Adam Erickson

unread,
Dec 31, 2012, 4:48:47 PM12/31/12
to landis-...@googlegroups.com
Update: I am switching to a dual-boot system using Boot Camp, as I will need to run a few other native-Windows programs as well.

Adam

James Domingo

unread,
Jan 9, 2013, 8:18:05 PM1/9/13
to landis-...@googlegroups.com
Adam and other MAC users,

There are several virtualization alternatives to Boot Camp which allow
you to run Windows programs alongside Mac programs. In other words,
instead of booting up one operating system (OS X or Windows), you have
both running at the same time.

VirtualBox (https://www.virtualbox.org/) is a free, open-source project.
I've not used it on OS X; I used it to run a Windows VM (Virtual Machine)
on Windows.

I've used the commercial product VMware Fusion for over 5 years, and have
been very pleased with it.

http://www.vmware.com/products/fusion/overview.html

Another commercial offering is Parallels Desktop:

http://www.parallels.com/products/desktop/

I believe both VMware and Parallels have student/academic versions with
substantial discounts.

Best regards,
Jimm
--
James Domingo
Green Code LLC


Reply all
Reply to author
Forward
0 new messages