Compilation error: neuron python module (e_editor)

Post Reply
blloyd
Posts: 11
Joined: Tue Aug 16, 2011 4:33 am

Compilation error: neuron python module (e_editor)

Post by blloyd » Thu Aug 25, 2011 7:19 am

Hi

I have been trying to compile neuron as a python module for quite some time now.

My system setup is the following:
Windows 7, 64-bit
CYGWIN_NT-6.1-WOW64 dock 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin
gcc-3 (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Python from Enthought (EPD-7.2.1, python 2.7, 32-bit version)
nrn from mercurial repository

Thanks to Uri Cohen the configuration seems to work.


However during compilation I get an error:

make[3]: Entering directory `/home/Bryn/nrnepd/src/e_editor'
gcc-3.exe -mno-cygwin -DHAVE_CONFIG_H -I. -I../../../nrn/src/e_editor -I../.. -I../../src/nrnoc -I../../src/oc -I../../src/parallel -I../../src/nrnjava -I../../src/nrncvode -I../../src/ivos -I../../src/sundials -I../../src/nrnpython -I../../../nrn/src/oc -DPROGVERSION=\"ed-1.5\" -MT regex.o -MD -MP -MF .deps/regex.Tpo -c -o regex.o ../../../nrn/src/e_editor/regex.c
../../../nrn/src/e_editor/regex.c:23:19 regex.h: No such file or directory
... (more errors below)


Does anybody know how I can get past this error? I have looked if the regex.h is somewhere inside nrn, but it is not.
In the cygwin path I found several header files called regex.h:
/lib/ruby/1.8/i386-cygwin/regex.h
/usr/include/boost/regex.h
/usr/include/boost/tr1/tr1/bcc32/regex.h
/usr/include/postgresql/server/regex/regex.h
/usr/include/regex.h
/usr/include/unicode/regex.h
/usr/lib/ruby/1.8/i386-cygwin/regex.h


I tried placing regex.h from /usr/include into the nrn directory, however this does not work either (missing header include in /usr/include/regex.h).

Can somebody help?

Thanks a lot

Bryn

blloyd
Posts: 11
Joined: Tue Aug 16, 2011 4:33 am

Re: Compilation error: neuron python module (e_editor)

Post by blloyd » Thu Aug 25, 2011 7:27 am

Now I tried using the alpha version of neuron (nrn-7.2.alpha-524)

Again I get an error while compiling the directory e_editor:

../../../nrn-7.2.alpha-524/src/e_editor/hoc_e.c:260: error: 'SIGQUIT' undeclared (first use this function)
... (more errors in hoc_e.c, related to SIGQUIT, SIGHUP)


I am using following settings (also for post above):
export CXX="g++-3.exe -mno-cygwin"
export CC="gcc-3.exe -mno-cygwin"

I configure and build from a cygwin terminal, i.e. gcc-3 is the gcc supplied by cygwin.

blloyd
Posts: 11
Joined: Tue Aug 16, 2011 4:33 am

Re: Compilation error: neuron python module (e_editor)

Post by blloyd » Thu Aug 25, 2011 9:17 am

(For the alpha release of Neuron) I did some more digging and found that hoc_e.c includes "signal.h".

The header file "signal.h" defines e.g. SIGQUIT or SIGHUP, but only if _POSIX is defined.
This means hoc_e.c can only be compiled for POSIX systems.

Is there any alternative to using signal in hoc_e.c? Is this code needed even for the Neuron python module?
It would be great if there were an option to configure and build the bare minum for a python module.

Any help would be appreciated

Bryn

blloyd
Posts: 11
Joined: Tue Aug 16, 2011 4:33 am

Re: Compilation error: neuron python module (e_editor)

Post by blloyd » Fri Aug 26, 2011 8:15 am

Hi

OK. Now I managed to compile neuron for a 32-bit Enthought python, with cygwin-gcc-3. I followed the approach as described in the document by Uri Cohen. It worked fine, except for the environment variables:
export PYLIB="-L/cygdrive/c/Users/Bryn/Python/win32/Python26 -lpython26"
export PYLIBDIR="/cygdrive/c/Users/Bryn/Python/win32/Python26"
export PYLIBLINK="-L/cygdrive/c/Users/Bryn/Python/win32/Python26 -lpython26"
export PYINCDIR="/cygdrive/c/Users/Bryn/Python/win32/Python26/include"
(not the difference is the directory libs inside Python26, which I needed to remove)

The main problem I was having previously (see previous posts) was that I was using a 64-bit version of python. Because that did not work, I tried using the mingw compiler supplied with Enthought. But that was causing all sorts of other problems (POSIX, etc.). Now it works for 32-bit, with the cygwin gcc-3 compiler.


Regarding the 64-bit version:
I tried using gcc-3 with “–m64” but this option is not available. The default compiler in cygwin, gcc-4, however, does not allow the option –mno-cygwin.
Do you know if there is a way to compile for x64 python on windows?

Thanks
Bryn


Here is a bash script to run configuration and build from the cygwin terminal:

Code: Select all

#!/usr/bin/env bash

export WINPYHOME='/cygdrive/c/Users/Bryn/Python/win32/Python26'
export NRN_SRC_DIR=nrn
export NRN_BUILD_DIR=nrnbuild_mash_python_win32

# Build directory
mkdir $NRN_BUILD_DIR
cd $NRN_BUILD_DIR

export CXX="g++-3.exe"
export  CC="gcc-3.exe"
export PYLIB="-L/cygdrive/c/Users/Bryn/Python/win32/Python26 -lpython26"
export PYLIBDIR="/cygdrive/c/Users/Bryn/Python/win32/Python26"
export PYLIBLINK="-L/cygdrive/c/Users/Bryn/Python/win32/Python26 -lpython26"
export PYINCDIR="/cygdrive/c/Users/Bryn/Python/win32/Python26/include"

../$NRN_SRC_DIR/configure --prefix=`pwd` --with-nrnpython=$WINPYHOME/python.exe \
use_pthread=no --disable-cygwin --without-iv --without-memacs

make
make mswin

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

Re: Compilation error: neuron python module (e_editor)

Post by hines » Fri Aug 26, 2011 8:22 am

../../../nrn/src/e_editor/regex.c:23:19 regex.h: No such file or directory
e_editor and some other things need to be executed under cygwin and so need to be built
as cygwin programs. This means that an enthought build takes place in two stages,
First as a cygwin build with --with-nmodl-only, and then the rest as a non-cygwin build using
--without-nmodl and a bunch of other args as well.

My script for building a NEURON extension that can be imported by a pure mswin enthought
python distribution is:

Code: Select all

$ cat howto_nrnepd
#!/bin/bash
#sources in $HOME/neuron/nrn
# first build a cygwin version in a separate build directory through
# 'make mswin' so that a full installation appears in c:/marshalnrn/nrn
# or else install the most recent nrnsetup.exe

# The reason for gcc-3 is so that -mno-cygwin works. Otherwise need to
# use MinGW.


cd $HOME/neuron
mkdir nrnepd
cd nrnepd

../nrn/configure --prefix=`pwd` --without-iv --with-nmodl-only
make

 ../nrn/configure --prefix=`pwd` --without-iv --with-nrnpython \
  --disable-cygwin --without-readline --without-memacs --without-nmodl \
  PYINCDIR=/cygdrive/c/Python26/include \
  PYLIBDIR=/cygdrive/c/Python26/libs \
  PYLIB='-L/cygdrive/c/Python26/libs -lpython26' \
  PYLIBLINK='-L/cygdrive/c/Python26/libs -lpython26' \
  CC=/bin/gcc-3 CXX=/bin/g++-3
make

# following assumes 'make mswin' was used for cygwin build so that
# a full version is in c:/marshalnrn/bin. Otherwise install a recent
# version of NEURON and use c:/nrn72 in place of c:/marshalnrn/bin, etc.

cd src/mswin
cp nrniv.dll c:/marshalnrn/nrn/bin
cp hocmodule.dll c:/marshalnrn/nrn/bin/hoc.pyd

if false ; then

in command prompt window
set PYTHONPATH=c:/marshalnrn/nrn/lib/python
set NEURONHOME=c:/marshalnrn/nrn
set PATH=%PATH%;c:\marshalnrn\nrn\bin

or in PyLab
import sys
sys.append('c:\\marshalnrn\\nrn\\lib\\python')
sys.append('c:\\marshalnrn\\nrn\\bin')

fi
I believe Uri Cohen has been able to replace gcc-3 with a MinGW compiler. This is particularly useful since I also believe there is now
a 64 bit version of that.

uri.cohen
Posts: 24
Joined: Wed Jul 20, 2011 9:14 am

Re: Compilation error: neuron python module (e_editor)

Post by uri.cohen » Fri Aug 26, 2011 9:40 am

Actually, I also used gcc-3 to compile NEURON with Python (ActiveState, though) using the option -mno-cygwin which was indeed removed in gcc-4. I'll update the guidelines to include the feedback above.
Also I hope I'll be able to look at compiling NEURON on x64 machines in a few days.

blloyd
Posts: 11
Joined: Tue Aug 16, 2011 4:33 am

Re: Compilation error: neuron python module (e_editor)

Post by blloyd » Fri Aug 26, 2011 9:45 am

Hi Uri and Hines,

Thanks for you replies.

Uri sent me a document describing the installation process. According to this it does not need two passes (see also my script above).
The two pass configure and installation does not seem to work for me at all.

I have tried two different mingw compilers (the one installed with enthought) and also one from cygwin (x86_64-w64-mingw32-gcc).
Both failed early during compilation (again, missing regex.h, missing termios.h in e_editor).

Any idea which mingw compiler might work?

Thanks and best regards
Bryn

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

Re: Compilation error: neuron python module (e_editor)

Post by hines » Fri Aug 26, 2011 10:28 am

I thought maybe the two-pass style would avoid your compile problem for e_editor.
I've been doing my compiling under xp. In a few weeks, I'll have a VirtualBox on my
ubuntu linux running windows 7 and can try everything again at that time.
Since I believe your issue is due to some minor environment difference it makes
sense to take this problem to email so we can work it out without cluttering the forum
with tentative experiments. Can you send me the output of the first pass to
michael dot hines at yale dot edu . I assume you were able to successfully execute
sh build.sh
in the cloned nrn repository.

blloyd
Posts: 11
Joined: Tue Aug 16, 2011 4:33 am

Re: Compilation error: neuron python module (e_editor)

Post by blloyd » Thu Sep 01, 2011 11:39 am

Dear Michael

Sorry to repeat this, but maybe it could be useful also for others, searching for solution.
As I wrote to you in an e-mail, there is following issue:

1. Cygwin is only shipped as 32-bit. In order to compile therefore a cross-compiler is needed (even in Linux 32-bit a cross-compiler for 64-bit needed, if you build for 64-bit).

2. The mingw 64-bit cross-compiler does not work (POSIX related stuff, maybe more)

Best regards
Bryn

Post Reply