Compilation failure on Mavericks

Post Reply
peadargrant
Posts: 8
Joined: Mon May 21, 2012 10:12 am

Compilation failure on Mavericks

Post by peadargrant »

Interesting issue here, I've compiled with the recommended compiler switches for clang, both with and without extra stuff like MPI and Python.

Code: Select all

./configure --prefix=/usr/local --exec-prefix=/usr/local --with-iv=/usr/local --with-pic CC='clang' CXX='clang++' CFLAGS='-O3 -Wno-return-type -Wno-implicit-function-declaration -Wno-implicit-int -fPIC' CXXFLAGS='-O3 -Wno-return-type -Wno-implicit-function-declaration -Wno-implicit-int -fPIC'
and I still get this failure here related to ivocrand.cpp

Code: Select all

ivocrand.cpp:191:26: error: addition of default argument on redeclaration
      makes this constructor a default constructor
Rand::Rand(unsigned long seed = 0, int size = 55, Object* obj = nil) {
                         ^      ~
./random1.h:11:3: note: previous declaration is here
  Rand(unsigned long seed, int size, Object*);
  ^

Any suggestions for how I should fix it? It's the same regardless of turning on or off other compilation options so it seems to be in the base part of neuron.
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Compilation failure on Mavericks

Post by hines »

I can't reproduce that error in my maverick environment so I can't experiment with work arounds. I'm using
OS X 10.9 (13A603)
$ clang --version
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

But if I had to guess, I would think that the 'Rand' token is already being used in your environment in some other way.. You might try
editing random1.h and ivocrand.h and change every occurrence of Rand to ivocRand. Or more easily try adding the line
#define Rand ivocRand
at the top of random1.h
and see what happens (not foolproof since files are include after #include random1.h
peadargrant
Posts: 8
Joined: Mon May 21, 2012 10:12 am

Re: Compilation failure on Mavericks

Post by peadargrant »

Thanks Michael, I'll give it a shot. My target environment seems to be slightly different to yours, which might explain the problem:

Code: Select all

Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.2
Thread model: posix
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Compilation failure on Mavericks

Post by hines »

My xcode command line tools are the latest available. I suppose I can only get to Target: x86_64-apple-darwin13.0.2
If I install the full xcode 5 ( I don't particularly relish doing that as it is 2gb and I only have 11 gb left on my mavericks partition)
and it is by no means certain that will allow me to see the problem.
I did move to the latest mavericks update 10.9.1 but no change.
btorb
Posts: 30
Joined: Fri Oct 21, 2005 8:14 am

Re: Compilation failure on Mavericks

Post by btorb »

Is there any solution to this problem? I get the same error:

Code: Select all

Rand::Rand(unsigned long seed = 0, int size = 55, Object* obj = nil) {
                         ^      ~
./random1.h:11:3: note: previous declaration is here
  Rand(unsigned long seed, int size, Object*);
  ^
ivocrand.cpp:202:3: warning: delete called on 'Random' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
  delete rand;
If I try the quickfix (adding #define... to /src/ivoc/random1.h) I get the following error

Code: Select all

ivocrand.cpp:191:26: error: addition of default argument on redeclaration makes this constructor a default constructor
Rand::Rand(unsigned long seed = 0, int size = 55, Object* obj = nil) {
                         ^      ~
./random1.h:12:3: note: previous declaration is here
  Rand(unsigned long seed, int size, Object*);
  ^
./random1.h:1:14: note: expanded from macro 'Rand'
#define Rand ivocRand
This should be on the same machine as Mike: "clang --version"

Code: Select all

Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Compilation failure on Mavericks

Post by hines »

That bug is fixed in
http://www.neuron.yale.edu/hg/neuron/nr ... 0f78755a30
But this last weekend I finished the updates for the clang compiler so that it is no longer necessary to use the special CFLAGS.
http://www.neuron.yale.edu/hg/neuron/nr ... 5605fc324a
In case it is not convenient for you to starf from the mercurial repository sources, there is a new tar.gz file at
http://www.neuron.yale.edu/ftp/neuron/v ... 026.tar.gz
btorb
Posts: 30
Joined: Fri Oct 21, 2005 8:14 am

Re: Compilation failure on Mavericks

Post by btorb »

Thanks for the prompt reply. Unfortunately, I still get the same error, and, I still need the compiler flags. (If not, compilation crashes even earlier)


So I unpack the latest tarball you linked above, run ./build.sh, then ./configure

Code: Select all

 ./configure --prefix=`pwd` --with-iv=/Users/btorb/local/neuron/iv  --with-nrnpython=dynamic --with-paranrn --with-readline=/usr/local/opt/readline
I get the following error during "make" which has to do with the compiler flags.

Code: Select all

io.c:73:4: warning: implicit declaration of function 'pop_file_stack' is invalid in C99 [-Wimplicit-function-declaration]
                        pop_file_stack();
                        ^
io.c:81:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
unGetc(c)
^~~~~~
io.c:85:3: error: non-void function 'unGetc' should return a value [-Wreturn-type]
                return;
If I use the old compiler flags (from here http://www.neuron.yale.edu/hg/neuron/nr ... 0f78755a30) during ./configure

Code: Select all

./configure --prefix=`pwd` --with-iv=/Users/btorb/local/neuron/iv  --with-nrnpython=dynamic --with-paranrn --with-readline=/usr/local/opt/readline CFLAGS='-O3 -Wno-return-type -Wno-implicit-function-declaration -Wno-implicit-int -fPIC' CXXFLAGS='-O3 -Wno-return-type -Wno-implicit-function-declaration -Wno-implicit-int -fPIC'
then during "make" I get the following error:

Code: Select all

ivocrand.cpp:191:26: error: addition of default argument on redeclaration makes this constructor a default constructor
Rand::Rand(unsigned long seed = 0, int size = 55, Object* obj = nil) {
                         ^      ~
./random1.h:11:3: note: previous declaration is here
  Rand(unsigned long seed, int size, Object*);
btorb
Posts: 30
Joined: Fri Oct 21, 2005 8:14 am

Re: Compilation failure on Mavericks

Post by btorb »

I was too quick! The tarball linked above does not work. Pulling the latest code from mercurial does.

So start with

Code: Select all

 hg clone http://www.neuron.yale.edu/hg/neuron/nrn
I still have one more error because afterwards, if I start python and run "import neuron", the readline library cannot be found.

I configured with:

Code: Select all

./configure --prefix=`pwd` --with-iv=/Users/btorb/local/neuron/iv  --with-nrnpython=dynamic --with-paranrn CFLAGS='-O3 -Wno-return-type -Wno-implicit-function-declaration -Wno-implicit-int -fPIC -I/usr/local/opt/readline/include' LDFLAGS='-L/usr/local/opt/readline/lib' CXXFLAGS='-O3 -Wno-return-type -Wno-implicit-function-declaration -Wno-implicit-int -fPIC -I/usr/local/opt/readline/include'
(Note that all the other compiler flags are indeed not required anymore) I include the linker LDFLAGS and add the flags to the compiler to specify where to find the libraries for readline.

Also, setting

Code: Select all

export LD_LIBRARY_PATH=/usr/local/opt/readline/lib:$LD_LIBRARY_PATH
does not alleviated the problem. I vaguely remember having this issue once before but cannot remember how it was solved.
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Compilation failure on Mavericks

Post by hines »

Oops. Sorry. I pulled but apparently failed to update. Anyway, try
http://www.neuron.yale.edu/ftp/neuron/v ... 028.tar.gz
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Compilation failure on Mavericks

Post by hines »

Generally speaking, these days it is best to use the system readline instead of the one that is distributed with the sources. The former is supposed to happen automatically unless the latter is specfically requested during
configure. Verify that you are not getting the latter by listing the src/readline folder and verifying that you have no compiled files there.
btorb
Posts: 30
Joined: Fri Oct 21, 2005 8:14 am

Re: Compilation failure on Mavericks

Post by btorb »

Hi Mike, No compiled files in that directory.

I found my previous post about this here: viewtopic.php?f=4&t=2957&p=12112&hilit= ... ine#p12112

The current status is that I can run "import neuron" only if I'm calling python in the directory that contains the readline library.

setting LD_LIBRARY_PATH does not help.

I'm out of clues. Any idea?
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Compilation failure on Mavericks

Post by hines »

LD_LIBRARY_PATH not helping is a puzzle. I'm not having this problem on my mavericks system but that is using canopy.
What is the full name of the library? What happens if you copy the readline library into the /Applications/NEURON-7.3/nrn/x86_64/lib folder?
btorb
Posts: 30
Joined: Fri Oct 21, 2005 8:14 am

Re: Compilation failure on Mavericks

Post by btorb »

Unfortunately, copying that library also doesn't help.

The complete error reads:

Code: Select all

btorb:~> python
Python 2.7.5 |Anaconda 1.7.0 (x86_64)| (default, Jun 28 2013, 22:20:13) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import neuron
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/btorb/local/lib/python2.7/site-packages/neuron/__init__.py", line 106, in <module>
    import neuron.hoc
ImportError: dlopen(/Users/btorb/local/lib/python2.7/site-packages/neuron/hoc.so, 2): Library not loaded: libreadline.6.2.dylib
  Referenced from: /Users/btorb/local/lib/python2.7/site-packages/neuron/hoc.so
  Reason: image not found
>>> 
The complete name of the library is

Code: Select all

Users/btorb/anaconda/lib/libreadline.6.2.dylib
My latest build was agnostic with respect to which readline to use:

Code: Select all

./configure --prefix=`pwd` --with-iv=/Users/btorb/local/neuron/iv  --with-nrnpython=/Users/btorb/anaconda/bin/python --with-paranrn
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Compilation failure on Mavericks

Post by hines »

I wonder if tow incompatible readline libraries are on your syste, ie. one from anaconda and a system standard one. The trick then, would be to
get NEURON built with the anaconda version of readline. Take a look at your nrn/config.status file and see what you have for
S["BUILD_READLINE_FALSE"]=""
S["BUILD_READLINE_TRUE"]="#"
...
S["NRN_READLINE_DEP"]=""
S["NRN_READLINE_LIBS"]="-lreadline -lncurses"
S["READLINE_LIBS"]="-lreadline -lncurses"

You might try
... = "-L/Users/btorb/anaconda/lib -lreadline -lncurses" for the NRN_READLINE_LIBS and READLINE_LIBS above (then execute "sh config.status" ; make install"
It is also possible to specify the readline on the configure line. ie.
-with-readline=dir Specify the location of the readline library. You
must specify this option if readline is not located
in a standard place. The configure script looks for
the library in the subdirectory lib underneath the
directory you specify.
So if the the instructions are not mistaken, I presume it would be
--with-readline=/Users/btorb/anaconda
although it seems strange not to have the /lib at the end of that. (I just looked at nrn/m4/readline.m4 and it adds the trailing lib itself.)
else # Location of readline specified?
READLINE_LIBS="-L$with_readline/lib -lreadline $TERMCAP_LIB"
fi
Post Reply