Bug 1251 - OSX: test.py reports dyld: Library not loaded:
OSX: test.py reports dyld: Library not loaded:
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: build system
pre-release
Mac Intel Mac OS
: P5 blocker
Assigned To: Gustavo J. A. M. Carneiro
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-24 15:43 UTC by John Abraham
Modified: 2011-08-26 14:29 UTC (History)
2 users (show)

See Also:


Attachments
Config.log (28.83 KB, application/octet-stream)
2011-08-24 15:43 UTC, John Abraham
Details
test logs (83.63 KB, text/plain)
2011-08-24 15:44 UTC, John Abraham
Details
output of ./waf -d debug configure --enable-examples -v (18.76 KB, text/plain)
2011-08-25 14:22 UTC, John Abraham
Details
output of ./waf -v (694.54 KB, text/plain)
2011-08-25 14:22 UTC, John Abraham
Details
output of ./waf --run "hello-simulator" (694 bytes, text/plain)
2011-08-25 14:23 UTC, John Abraham
Details
output of ls -l build/debug (8.61 KB, text/plain)
2011-08-25 14:24 UTC, John Abraham
Details
patch (650 bytes, patch)
2011-08-25 15:12 UTC, Gustavo J. A. M. Carneiro
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Abraham 2011-08-24 15:43:19 UTC
Created attachment 1224 [details]
Config.log

Seen on Snow Leopard and OSX Lion . Ubuntu seems ok with it

steps: 


   14  wget http://www.nsnam.org/release/ns-allinone-3.12-RC1.tar.bz2
   15  tar -xvjpf ns-allinone-3.12-RC1.tar.bz2 
   16  cd ns-allinone-3.12-RC1
   17  ls
   18  ./build.py --enable-tests --enable-examples 
   20  cd ns-3.12-RC1/
   21  ./test.py 


config.log and test output are attached.
Comment 1 John Abraham 2011-08-24 15:44:15 UTC
Created attachment 1225 [details]
test logs

output of test.py -v
Comment 2 John Abraham 2011-08-24 15:45:11 UTC
Forgot to mention: this is what test.py reports


---------- begin standard out ----------

---------- begin standard err ----------
Traceback (most recent call last):
  File "/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/src/flow-monitor/examples/wifi-olsr-flowmon.py", line 21, in <module>
    import ns.applications
ImportError: dlopen(/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/bindings/python/ns/applications.so, 2): Library not loaded: /usr/local/lib/libns3-core.3.12-RC1.dylib
  Referenced from: /Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/bindings/python/ns/applications.so
  Reason: image not found
Comment 3 Gustavo J. A. M. Carneiro 2011-08-25 13:59:37 UTC
From your log file I see that:

os.environ["DYLD_LIBRARY_PATH"] == :/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug
Synchronously execute /Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/utils/test-runner --print-test-name-list
Return code =  -5
stderr =  dyld: Library not loaded: /usr/local/lib/libns3-core.3.12-RC1.dylib
  Referenced from: /Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/utils/test-runner
  Reason: image not found

So, if DYLD_LIBRARY_PATH is being set correctly, why doesn't the dynamic linker find the library in /Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug ?  Can you check what files have been created inside?

Another useful input would be the output of "./waf -v", to see all the low level build commands that are being issued (after a waf clean, of course).

I am surprised Snow Leopard also has problems, did ns-3.11 not work in Snow Leopard, or is something new been broken?
Comment 4 John Abraham 2011-08-25 14:22:25 UTC
Created attachment 1227 [details]
output of ./waf -d debug configure --enable-examples -v

./waf -d debug configure --enable-examples -v
Comment 5 John Abraham 2011-08-25 14:22:52 UTC
Created attachment 1228 [details]
output of ./waf -v

./waf -v
Comment 6 John Abraham 2011-08-25 14:23:26 UTC
Created attachment 1229 [details]
output of ./waf --run "hello-simulator"

./waf --run "hello-simulator"
Comment 7 John Abraham 2011-08-25 14:24:03 UTC
Created attachment 1230 [details]
output of ls -l build/debug

ls -l build/debug
Comment 8 Gustavo J. A. M. Carneiro 2011-08-25 14:42:15 UTC
14:17:36 runner system command -> ['/usr/bin/g++', [...bunch of objects...], '-o', '/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/libns3-core.dylib', '-dynamiclib', '-install_name', '/usr/local/lib/libns3-core.3.12-RC1.dylib']

14:17:48 runner system command -> ['/usr/bin/g++', 'debug/examples/tutorial/hello-simulator_1.o', '-o', '/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/examples/tutorial/hello-simulator', '-Ldebug', '-lns3-core']

I guess the linker finds the libns3-core.dylib alright, but the dynamic loader (at runtime) tries to look for /usr/local/lib/libns3-core.3.12-RC1.dylib, which of course doesn't exist yet.  The reason is the -install_name parameter that waf gives to the linker.

My theory (maybe you could check that) is that after "waf install" the ns-3 examples will run fine.  The next question then is how to fix it, and this is where I have no good idea.

Apparently, if we tell waf the library will be installed, then it will supply the parameters '-install_name /usr/local/lib/libns3-core.3.12-RC1.dylib', wheres if install_path is missing, then the parameters will be '-install_name libns3-core.3.12-RC1.dylib'.  The second form is what we had in ns-3.11 and it worked for uninstalled ns-3.  So, for now, I guess we have to choose what we want OSX build to work, either ns-3 needs to be  installed or it cannot be installed at all, choose one *sigh*
Comment 9 John Abraham 2011-08-25 14:54:00 UTC
yes "./waf install" allowed the executable to run.
ns-3.11 does not have this issue on Snow leopard

ns-3.11 won't build on my OSX lion

(In reply to comment #8)
> 14:17:36 runner system command -> ['/usr/bin/g++', [...bunch of objects...],
> '-o',
> '/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/libns3-core.dylib',
> '-dynamiclib', '-install_name', '/usr/local/lib/libns3-core.3.12-RC1.dylib']
> 
> 14:17:48 runner system command -> ['/usr/bin/g++',
> 'debug/examples/tutorial/hello-simulator_1.o', '-o',
> '/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/examples/tutorial/hello-simulator',
> '-Ldebug', '-lns3-core']
> 
> I guess the linker finds the libns3-core.dylib alright, but the dynamic loader
> (at runtime) tries to look for /usr/local/lib/libns3-core.3.12-RC1.dylib, which
> of course doesn't exist yet.  The reason is the -install_name parameter that
> waf gives to the linker.
> 
> My theory (maybe you could check that) is that after "waf install" the ns-3
> examples will run fine.  The next question then is how to fix it, and this is
> where I have no good idea.
> 
> Apparently, if we tell waf the library will be installed, then it will supply
> the parameters '-install_name /usr/local/lib/libns3-core.3.12-RC1.dylib',
> wheres if install_path is missing, then the parameters will be '-install_name
> libns3-core.3.12-RC1.dylib'.  The second form is what we had in ns-3.11 and it
> worked for uninstalled ns-3.  So, for now, I guess we have to choose what we
> want OSX build to work, either ns-3 needs to be  installed or it cannot be
> installed at all, choose one *sigh*
Comment 10 Gustavo J. A. M. Carneiro 2011-08-25 15:12:39 UTC
Created attachment 1231 [details]
patch

Maybe this patch helps?...
Comment 11 John Abraham 2011-08-25 15:35:41 UTC
I get the same results with the patch

   82  ./waf distclean
   83  cd ..
   84  ls
   85  ./build.py --enable-tests --enable-examples
   86  ./waf --run "hello-simulator"
   87  cd ns-3.12-RC1/
   88  ./waf --run "hello-simulator"


Waf: Entering directory `/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build'
Waf: Leaving directory `/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build'
'build' finished successfully (1.226s)
dyld: Library not loaded: /usr/local/lib/libns3-core.3.12-RC1.dylib
  Referenced from: /Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/examples/tutorial/hello-simulator
  Reason: image not found
Command ['/Users/john/ns-3.12-rc1/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug/examples/tutorial/hello-simulator'] terminated with signal SIGTRAP. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").


(In reply to comment #10)
> Created attachment 1231 [details]
> patch
> 
> Maybe this patch helps?...
Comment 12 Mathieu Lacage 2011-08-26 03:25:18 UTC
man dyld says that you should use DYLD_FALLBACK_LIBRARY_PATH in this case but it does not work: 

bash-3.2$ DYLD_FALLBACK_LIBRARY_PATH=/Users/mathieu/code/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug ./build/debug/scratch/scratch-simulator
dyld: Library not loaded: /usr/local/lib/libns3-core.3.12-RC1.dylib
  Referenced from: /Users/mathieu/code/ns-allinone-3.12-RC1/ns-3.12-RC1/./build/debug/scratch/scratch-simulator
  Reason: image not found
Trace/BPT trap

DYLD_FALLBACK_LIBRARY_PATH=/Users/mathieu/code/ns-allinone-3.12-RC1/ns-3.12-RC1/build/debug dtrace -o out ./build/debug/scratch/scratch-simulator
dtrace: failed to initialize dtrace: DTrace requires additional privileges

tom: can you give my account proper privs ?
Comment 13 Gustavo J. A. M. Carneiro 2011-08-26 07:32:32 UTC
It seems that OSX library version numbers trigger this problem, so I disabled them altogether (in OSX only).  Should be fixed now.


changeset:   7463:53b784adf3f4
tag:         tip
user:        Gustavo J. A. M. Carneiro  <gjc@inescporto.pt>
date:        Fri Aug 26 12:31:04 2011 +0100
summary:     Bug 1251 - OSX: test.py reports dyld: Library not loaded
Comment 14 John Abraham 2011-08-26 14:29:53 UTC
works on RC2 image after the fix

(In reply to comment #13)
> It seems that OSX library version numbers trigger this problem, so I disabled
> them altogether (in OSX only).  Should be fixed now.
> 
> 
> changeset:   7463:53b784adf3f4
> tag:         tip
> user:        Gustavo J. A. M. Carneiro  <gjc@inescporto.pt>
> date:        Fri Aug 26 12:31:04 2011 +0100
> summary:     Bug 1251 - OSX: test.py reports dyld: Library not loaded