MOD Files Compile But Fail To Load

Anything that doesn't fit elsewhere.
Post Reply
agmccrei
Posts: 23
Joined: Thu Sep 10, 2015 1:34 pm

MOD Files Compile But Fail To Load

Post by agmccrei » Thu Sep 26, 2019 9:12 pm

Hello,

I'm running into some strange errors in loading my channel mechanisms with my Python/NEURON installation. I have tried re-installing NEURON and XQuartz but the error report persists. Here are my system details:

macOS Mojave (10.14.6)
NEURON VERSION 7.7.2
Python 3.7.3
XQuartz 2.7.11
Xcode version 11.0

All pretty freshly installed.

The strange part about the error report is that I only started receiving it today, and for the past few days everything seemed to work fine and I ran several simulations without any problems. Here is what started happening today:

When I run "nrnivmodl" or drag the MOD files to the mknrndll icon, the files appear to compile properly in an x86_64 folder (i.e. containing .c, .lo, and .mod files, as well as a .libs/libnrnmech.0.so, etc.). However when I try to run NEURON following this (i.e. nrngui, nrniv, or nrniv -python) I get the following error:

Code: Select all

NEURON -- VERSION 7.7.2 7.7 (2b7985ba) 2019-06-20
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2018
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from x86_64/.libs/libnrnmech.so
dlopen failed - 
dlopen(x86_64/.libs/libnrnmech.so, 2): Library not loaded: @rpath/libncursesw.6.dylib
  Referenced from: /Users/agmccrei/Downloads/PurkReductionOnLine/x86_64/.libs/libnrnmech.0.so
  Reason: image not found
Without the _x86_64 folder, no error is generated. Also, running "neurondemo" does not generate any errors and runs fine. From the error it seems as though something in Library/ is not in the right place(?). When looking for "libncursesw.6.dylib", that file appears to be in anaconda3/lib and not Library/ (though anaconda3 should be added to the $PATH from what I see in .bash_profile).

Any help would be greatly appreciated,

Alex GM

ted
Site Admin
Posts: 5621
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: MOD Files Compile But Fail To Load

Post by ted » Fri Sep 27, 2019 10:55 am

Some questions.
First, did this machine ever have a previous version of NEURON installed, and if so, did mechanisms load properly then?
Second, what happens when you execute the command
neurondemo
from the command line?

agmccrei
Posts: 23
Joined: Thu Sep 10, 2015 1:34 pm

Re: MOD Files Compile But Fail To Load

Post by agmccrei » Fri Sep 27, 2019 12:08 pm

Thanks.
1. It's a new laptop (about a week old now). No previous installations of NEURON. When I first installed everything it worked fine. Seemingly out of the blue yesterday, I started getting that error message when I tried to load a model from modeldb (at first I thought it was just that model but then I found that the error was happening across all of my older folders wherever I had to re-compile the mod files before running).
2. Here is the response when running neurondemo:

Code: Select all

NEURON -- VERSION 7.7.2 7.7 (2b7985ba) 2019-06-20
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2018
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from /Applications/NEURON-7.7/nrn/share/nrn/demo/release/x86_64/.libs/libnrnmech.so
Additional mechanisms from files
 cabpump.mod cachan1.mod camchan.mod capump.mod invlfire.mod khhchan.mod mcna.mod nacaex.mod nachan.mod release.mod
Thanks,

Alex GM

agmccrei
Posts: 23
Joined: Thu Sep 10, 2015 1:34 pm

Re: MOD Files Compile But Fail To Load

Post by agmccrei » Fri Sep 27, 2019 4:37 pm

Update:
I can fix the problem in a very manual way. From the directory:

Code: Select all

nrnivmodl
cd x86_64/.libs/
-L libnrnmech.0.so
This outputs the following:

Code: Select all

libnrnmech.0.so:
	/Applications/NEURON-7.7/nrn/x86_64/lib/libnrnoc.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/liboc.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/X11/lib/libX11.6.dylib (compatibility version 10.0.0, current version 10.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libmemacs.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libscopmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libsparse13.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libreadline.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	@rpath/libncursesw.6.dylib (compatibility version 6.0.0, current version 6.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libnrniv.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libivoc.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libneuron_gnu.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libmeschach.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libsundials.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	//anaconda3/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
The problem being the

Code: Select all

@rpath/libncursesw.6.dylib (compatibility version 6.0.0, current version 6.0.0)
.

I fix it with the following:

Code: Select all

install_name_tool -change @rpath/libncursesw.6.dylib //anaconda3/lib/libncursesw.6.dylib libnrnmech.0.so
i.e. I replace it with the actual path of libncursesw.6.dylib such that:

Code: Select all

otool -L libnrnmech.0.so
outputs:

Code: Select all

libnrnmech.0.so:
	/Applications/NEURON-7.7/nrn/x86_64/lib/libnrnoc.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/liboc.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/X11/lib/libX11.6.dylib (compatibility version 10.0.0, current version 10.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libmemacs.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libscopmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libsparse13.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libreadline.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	//anaconda3/lib/libncursesw.6.dylib (compatibility version 6.0.0, current version 6.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libnrniv.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libivoc.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libneuron_gnu.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libmeschach.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Applications/NEURON-7.7/nrn/x86_64/lib/libsundials.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	//anaconda3/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
And then:

Code: Select all

cd ..
cd ..
nrniv
New output:

Code: Select all

NEURON -- VERSION 7.7.2 7.7 (2b7985ba) 2019-06-20
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2018
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from x86_64/.libs/libnrnmech.so
Additional mechanisms from files
 CaE.mod CaP.mod CaP2.mod CaT.mod CalciumP.mod K2.mod K22.mod K23.mod KA.mod KC.mod KC2.mod KC3.mod KD.mod KM.mod Kdr.mod Kh.mod Khh.mod Leak.mod NaF.mod NaP.mod pj.mod
Now I just need to find a more permanent fix.

AGM

ted
Site Admin
Posts: 5621
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: MOD Files Compile But Fail To Load

Post by ted » Sat Sep 28, 2019 8:53 pm

Here is the response when running neurondemo:
That's all that happened? No GUI tools appeared on screen? Clicking on the "Release" radio button did what? After clicking on "Release", clicking on the Init & Run button did what?

With regard to your own source code, where are you putting it before you compile the mod files?

hines
Site Admin
Posts: 1580
Joined: Wed May 18, 2005 3:32 pm

Re: MOD Files Compile But Fail To Load

Post by hines » Sun Sep 29, 2019 3:56 am

On my machine (macOS Catalina Version10.15 Beta (19A573a)) (my most recent build in /Applications/NEURON-7.7 is
NEURON -- VERSION 7.7.1-38-g1f3d46d9+ master (1f3d46d9+) 2019-09-13 ) I'm seeing for a typical libnrnmech.so created by nrnivmodl

Code: Select all

$ otool -L x86_64/.libs/libnrnmech.so
...
	/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
...
In /usr/lib do you have any ncurses. If not, it might be worth a try to copy your anaconda ncurses there just to see if it fixes the issue. On my machine

Code: Select all

michaels-macbook-pro:ringtest michaelhines$ ls -l /usr/lib/libncurses*
-rwxr-xr-x  1 root  wheel  268736 Sep 20 08:08 /usr/lib/libncurses.5.4.dylib
lrwxr-xr-x  1 root  wheel      20 Jul 26 18:08 /usr/lib/libncurses.5.dylib -> libncurses.5.4.dylib
lrwxr-xr-x  1 root  wheel      20 Jul 26 18:08 /usr/lib/libncurses.dylib -> libncurses.5.4.dylib
I believe, but am not sure, that all this comes from installing Xcode command line tools.

agmccrei
Posts: 23
Joined: Thu Sep 10, 2015 1:34 pm

Re: MOD Files Compile But Fail To Load

Post by agmccrei » Sun Sep 29, 2019 7:52 pm

When I run neurondemo, the gui pops up fine and all the demos appear to run fine with no errors. I don't see a "Release" button in any of the GUI windows, but clicking on "Init & Run" in any of the demos does not generate any errors and the simulations run to completion.

My mod files and x86_64 folder are in the same directory as where I have my simulation code.

As for "/usr/lib/libncurses.5.4.dylib", this also exists in my system:

Code: Select all

(base) Alexandres-MacBook-Pro:/ agmccrei$ ls -l /usr/lib/libncurses*
-rwxr-xr-x  1 root  wheel  518896 15 Jul 00:56 /usr/lib/libncurses.5.4.dylib
lrwxr-xr-x  1 root  wheel      20 15 Jul 04:18 /usr/lib/libncurses.5.dylib -> libncurses.5.4.dylib
lrwxr-xr-x  1 root  wheel      20 15 Jul 04:18 /usr/lib/libncurses.dylib -> libncurses.5.4.dylib
However it is not listed when I run

Code: Select all

otool -L x86_64/.libs/libnrnmech.so
However, when I compile my mod files and then run

Code: Select all

install_name_tool -change @rpath/libncursesw.6.dylib /usr/lib/libncurses.5.4.dylib x86_64/.libs/libnrnmech.so
I can then successfully load the mechanisms without error when I run nrniv as well.

So it seems that if I replace

Code: Select all

@rpath/libncursesw.6.dylib (compatibility version 6.0.0, current version 6.0.0)
with either

Code: Select all

/usr/lib/libncurses.5.4.dylib (compatibility version 6.0.0, current version 6.0.0)
or

Code: Select all

//anaconda3/lib/libncursesw.6.dylib (compatibility version 6.0.0, current version 6.0.0)
This seems to fix it temporarily. I made a quick bash script to run this fix every time I recompile mod files (below), but of course, it would be better if I could compile mod files without having to run a fix every time - just not sure where/how I would apply such a solution.

Code: Select all

install_name_tool -change @rpath/libncursesw.6.dylib //anaconda3/lib/libncursesw.6.dylib x86_64/.libs/libnrnmech.0.so
or

Code: Select all

install_name_tool -change @rpath/libncursesw.6.dylib /usr/lib/libncurses.5.4.dylib x86_64/.libs/libnrnmech.0.so
Thank you,

AGM

agmccrei
Posts: 23
Joined: Thu Sep 10, 2015 1:34 pm

Re: MOD Files Compile But Fail To Load

Post by agmccrei » Sun Sep 29, 2019 8:19 pm

I'm also curious why it's not finding and linking ncurses through "@rpath/libncursesw.6.dylib". When I run a search, only 1 libncursesw.6.dylib pops up:

Code: Select all

(base) Alexandres-MacBook-Pro:.libs agmccrei$ mdfind libncursesw.6.dylib
/anaconda3/lib/libncursesw.6.dylib
/Users/agmccrei/Downloads/PurkReductionOnLine/FixRPath.sh
/Users/agmccrei/Google Drive/SkinnerLab/Usages2/HighCondRepTests/SuppressionTests/AllInputs_N1/BothCells_N1/FixRPath.sh
/anaconda3/pkgs/ncurses-6.1-h0a44026_1/info/files
Also when I check the rpath headers of libncursesw.6.dylib, the rpath appears right(?). Admittedly, I really don't know much about how rpath and XCode work.

Code: Select all

(base) Alexandres-MacBook-Pro:/ agmccrei$ objdump -x //anaconda3/lib/libncursesw.6.dylib | grep -i path
         name @rpath/libncursesw.6.dylib (offset 24)
         name @rpath/libtinfow.6.dylib (offset 24)
          cmd LC_RPATH
         path @loader_path/ (offset 12)
          cmd LC_RPATH
         path //anaconda3/lib/libncursesw.6.dylib (offset 12)
Thanks,

Alex GM

agmccrei
Posts: 23
Joined: Thu Sep 10, 2015 1:34 pm

Re: MOD Files Compile But Fail To Load

Post by agmccrei » Wed Oct 09, 2019 4:20 pm

Just an update to this. I recently updated to macOS Catalina vs10.15, and had a lot of problems with my anaconda installation as a result. In getting fed up with it and just deleting anaconda (I only had it installed to test it out - was never really dependent on it) and then re-installing all the python modules that I use using pip, everything seems to work fine (i.e. compiling and loading mod files when opening neuron alone or in python3). Of note, the mod files still fail to load when running python2.7 but for a different reason:

Code: Select all

Python 2.7.16 (default, Aug 24 2019, 18:37:03) 
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import neuron
dlopen failed - 
dlopen(x86_64/.libs/libnrnmech.so, 2): no suitable image found.  Did find:
	file system relative paths not allowed in hardened programs
I haven't really been able to figure out why the compiled mechanisms are not loading when running python2.7, but I was moving to python3 anyway, so not a huge problem for me, in any case.

Alex GM

Post Reply