Rollback compatibility version of libraries on Mac OS X
Asked Answered
H

1

14

So, I love my Macbook, and she loves me. We have our ups and downs, but for the most part our relationship has been strong. Recently though we had a fight. it started out simply enough. I was asking her to do more, trying to be more experimental. We brought things like sse, fast math, and unrolling into the bedroom and compiled new versions of our libraries.

It started out well enough. We'd compile some code using the new libraries, test out the new waters. Over time our performance as a couple soared. She was working faster and I thought all was well and good. Then things took a turn for the worse. We brought another player into the mix. Her name is Matlab.

We started compiling for Matlab,

mex CC="gcc" CFLAGS="\$CFLAGS -msse -msse2 -msse3 -ffast-math -ftree-vectorize" LDFLAGS="\$LDFLAGS -msse2 -msse3 -ffast-math -ftree-vectorize" -I/usr/local/include -L/usr/local/lib -lsundials_cvode -lsundials_nvecserial -v -o kry_new.mexmaci64 mex_main.c

compiling and linking worked great. But then the trouble started:

kry_new(param,init,0:60:240,abstol,rtol,1)
??? Invalid MEX-file
'/Users/Andrew/Documents/MATLAB/het_optim/kry_new.mexmaci64':
dlopen(/Users/Andrew/Documents/MATLAB/het_optim/kry_new.mexmaci64, 1):
Library not loaded: /usr/local/lib/libsundials_cvode.1.dylib
  Referenced from: /Users/Andrew/Documents/MATLAB/het_optim/kry_new.mexmaci64
  Reason: Incompatible library version: kry_new.mexmaci64 requires version
  2.0.0 or later, but libsundials_cvode.1.dylib provides version 1.0.0.

Matlab felt that our experiments had gone to far. That they were totally different versions of the libraries. I don't know where she got this idea. I did some investigating:

$ otool -L kry_new.mexmaci64 
kry_new.mexmaci64:
    /usr/local/lib/libsundials_cvode.1.dylib (compatibility version 2.0.0, current version 2.0.0)
    @loader_path/libsundials_nvecserial.0.0.2.dylib (compatibility version 0.0.0, current version 0.0.2)
    @loader_path/libmx.dylib (compatibility version 0.0.0, current version 0.0.0)
    @loader_path/libmex.dylib (compatibility version 0.0.0, current version 0.0.0)
    @loader_path/libmat.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)

The problem was in libsundials_cvode. There was no version 2, there never was. To make matters worse, my Macbook took Matlab's side. I tried uninstalling, striping out all references to the new things, even deleted our make files and tried to start again. I tried to rebuild our libraries the old way. But they wouldn't let go of the elusive version 2. I didn't know how to give them what they wanted. I just wasn't man enough to meet their expectations of me.

The only thing I could guess was that at some point, version 2 made sense, but that I backed away from it somehow. I guess the link I had presented stayed in their minds even when I went back to the way it was. I guess I forgot the first rule of that birds and the bees talk given by my sys admin, "Every time you symbolink a dynamic library you give part of yourself away that you never get back."

In desperation to keep both my Macbook and Matlab in my life, I told a lie that I'm not proud of:

sudo mv libsundials_cvode.1.0.0.dylib libsundials_cvode.2.0.0.dylib 

I didn't think it would work, but it did. They compile my code now and they appear happy enough. But I have the lingering feeling that I'm just faking it, and that my lie will come back to bite me.

So, since Dan Savage just ignores me, I turn to you stackoverflow for relationship advice. I need to somehow tell my Macbook that, no, version 1.0.0 is enough for us. How can I get her to listen to me and fix the compatibility issues in my relationship without my horrible lie?

Highpressure answered 2/4, 2011 at 2:13 Comment(1)
I wish I knew... However, all StackOverflow questions should be re-written as relationship advice columns. I'm upvoting: I hope someone else can help.Stinger
B
2

Excuse me if I am barking up the wrong tree, but from what I can tell Sundials is at version 2.4 (with the individual libraries at 2.6)? https://computation.llnl.gov/casc/sundials/download/download.html. Have you tried compiling from the sources here?

I just compiled and installed on my Mac Pro running 10.6.7 with no problems! You need to configure using the following in order to install the .dylib otherwise it just generates .la and .a

./configure --enable-shared

I now have the following:

w125-244:sundials-2.4.0 stevemoss$ ls -al /usr/local/lib/libsundials_cvode*
-rwxr-xr-x  1 root  staff    4136 28 Apr 16:07 /usr/local/lib/libsundials_cvode.1.0.0.dylib
lrwxr-xr-x  1 root  staff      29 28 Apr 16:07 /usr/local/lib/libsundials_cvode.1.dylib -> libsundials_cvode.1.0.0.dylib
-rw-r--r--  1 root  staff  512704 28 Apr 16:07 /usr/local/lib/libsundials_cvode.a
lrwxr-xr-x  1 root  staff      29 28 Apr 16:07 /usr/local/lib/libsundials_cvode.dylib -> libsundials_cvode.1.0.0.dylib
-rwxr-xr-x  1 root  staff     878 28 Apr 16:07 /usr/local/lib/libsundials_cvode.la
-rwxr-xr-x  1 root  staff    4136 28 Apr 16:07 /usr/local/lib/libsundials_cvodes.2.0.0.dylib
lrwxr-xr-x  1 root  staff      30 28 Apr 16:07 /usr/local/lib/libsundials_cvodes.2.dylib -> libsundials_cvodes.2.0.0.dylib
-rw-r--r--  1 root  staff  926048 28 Apr 16:07 /usr/local/lib/libsundials_cvodes.a
lrwxr-xr-x  1 root  staff      30 28 Apr 16:07 /usr/local/lib/libsundials_cvodes.dylib -> libsundials_cvodes.2.0.0.dylib
-rwxr-xr-x  1 root  staff     885 28 Apr 16:07 /usr/local/lib/libsundials_cvodes.la

and

w125-244:sundials-2.4.0 stevemoss$ otool -L /usr/local/lib/libsundials_cvode.dylib
/usr/local/lib/libsundials_cvode.dylib:
    /usr/local/lib/libsundials_cvode.1.dylib (compatibility version 2.0.0, current version 2.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)

Also, perhaps a symlink might have been better than an mv in your example?

Bethink answered 28/4, 2011 at 14:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.