victorliu / S4

Stanford Stratified Structure Solver - Electromagnetic simulator for layered periodic structures
http://www.stanford.edu/group/fan/S4/
GNU General Public License v2.0
130 stars 149 forks source link

make S4_pyext not working #29

Open rubyalai opened 8 years ago

rubyalai commented 8 years ago

An error with 'clang' is preventing me from installing the python extension when I use the command "make S4_pyext" after successfully using 'make' to install S4. Thank you for your help!


$ make S4_pyext

mkdir -p ./build mkdir -p ./build/S4k mkdir -p ./build/S4r mkdir -p ./build/modules ar crvs build/libS4.a ./build/S4k/S4.o ./build/S4k/rcwa.o ./build/S4k/fmm_common.o ./build/S4k/fmm_FFT.o ./build/S4k/fmm_kottke.o ./build/S4k/fmm_closed.o ./build/S4k/fmm_PolBasisNV.o ./build/S4k/fmm_PolBasisVL.o ./build/S4k/fmm_PolBasisJones.o ./build/S4k/fmm_experimental.o ./build/S4k/fft_iface.o ./build/S4k/pattern.o ./build/S4k/intersection.o ./build/S4k/predicates.o ./build/S4k/numalloc.o ./build/S4k/gsel.o ./build/S4k/sort.o ./build/S4k/kiss_fft.o ./build/S4k/kiss_fftnd.o ./build/S4k/SpectrumSampler.o ./build/S4k/cubature.o ./build/S4k/Interpolator.o ./build/S4k/convert.o r - ./build/S4k/S4.o r - ./build/S4k/rcwa.o r - ./build/S4k/fmm_common.o r - ./build/S4k/fmm_FFT.o r - ./build/S4k/fmm_kottke.o r - ./build/S4k/fmm_closed.o r - ./build/S4k/fmm_PolBasisNV.o r - ./build/S4k/fmm_PolBasisVL.o r - ./build/S4k/fmm_PolBasisJones.o r - ./build/S4k/fmm_experimental.o r - ./build/S4k/fft_iface.o r - ./build/S4k/pattern.o r - ./build/S4k/intersection.o r - ./build/S4k/predicates.o r - ./build/S4k/numalloc.o r - ./build/S4k/gsel.o r - ./build/S4k/sort.o r - ./build/S4k/kiss_fft.o r - ./build/S4k/kiss_fftnd.o r - ./build/S4k/SpectrumSampler.o r - ./build/S4k/cubature.o r - ./build/S4k/Interpolator.o r - ./build/S4k/convert.o echo "-framework vecLib -framework vecLib -lfftw3 -lpthread " > ./build/tmp.txt sh gensetup.py.sh ./build ./build/libS4.a python setup.py build running build running build_ext building 'S4' extension creating build/temp.macosx-10.10-x86_64-2.7 creating build/temp.macosx-10.10-x86_64-2.7/S4 clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c S4/main_python.c -o build/temp.macosx-10.10-x86_64-2.7/S4/main_python.o S4/main_python.c:661:2: error: function declared in block scope cannot have 'static' storage class static PyObject _S4Sim_SetMaterial(S4Sim self, PyObject args, PyObject kwds); ^ S4/main_python.c:677:18: error: static declaration of 'S4Sim_SetMaterial' follows non-static declaration static PyObject S4Sim_SetMaterial(S4Sim self, PyObject args, PyObject kwds){ ^ S4/main_python.c:661:19: note: previous declaration is here static PyObject S4Sim_SetMaterial(S4Sim self, PyObject args, PyObject kwds); ^ S4/main_python.c:748:20: warning: assigning to 'char ' from 'const char ' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] layer->material = material; ^ ~~~~ S4/main_python.c:1701:51: warning: passing 'double ' to parameter of type 'const double *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers] nf = SpectrumSampler_GetFrequencies(self->SpecS, &freqs); ^~ S4/SpectrumSampler.h:41:82: note: passing argument to parameter 'freqs' here int SpectrumSampler_GetFrequencies(const SpectrumSampler sampler, const double _freqs); ^ S4/main_python.c:1790:35: error: use of undeclared identifier 'S4Sim_SetMaterial' {"SetMaterial" , (PyCFunction)S4Sim_SetMaterial, ... ^ S4/main_python.c:1818:33: error: use of undeclared identifier 'S4Sim_GetEField' {"GetEField" , (PyCFunction)S4Sim_GetEField, ME... ^ S4/main_python.c:1819:33: error: use of undeclared identifier 'S4Sim_GetHField' {"GetHField" , (PyCFunction)S4Sim_GetHField, ME... ^ S4/main_python.c:1823:41: error: use of undeclared identifier 'S4Sim_GetDiffractionOrder' {"GetDiffractionOrder" , (PyCFunction)S4Sim_GetDiffractionOrder, ... ^ S4/main_python.c:1827:33: error: use of undeclared identifier 'S4Sim_GetGList' {"GetGList" , (PyCFunction)S4Sim_GetGL... ^ S4/main_python.c:1828:32: error: use of undeclared identifier 'S4Sim_GetNumG' {"GetNumG" , (PyCFunction)S4Sim_GetNu... ^ S4/main_python.c:1830:44: error: use of undeclared identifier 'S4Sim_SetBasisFieldDumpPrefix' {"SetBasisFieldDumpPrefix" , (PyCFunction)S4Sim_SetBasisFieldDumpPref... ^ S4/main_python.c:1831:42: error: use of undeclared identifier 'S4Sim_SetLatticeTruncation' {"SetLatticeTruncation" , (PyCFunction)S4Sim_SetLatticeTruncation... ^ S4/main_python.c:1985:15: warning: unused variable 'kwlist' [-Wunused-variable] static char kwlist[] = {"Layer", "Simulations", NULL}; ^ S4/main_python.c:1986:14: warning: unused variable 'layerName' [-Wunused-variable] const char *layerName; ^ 4 warnings and 10 errors generated. error: command 'clang' failed with exit status 1

thomaskarg commented 8 years ago

I also tried to install the S4 python extension the same way and received similar warnings of type unused variable / unused function. When I try to do import S4 in python I receive the import error:

ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/S4.so, 2): Symbol not found: __ZNSt8ios_base4InitD1Ev
  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/S4.so
  Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/S4.so

What could be the problem here?

thomaskarg commented 8 years ago

Using clang++ and clang worked for me in the end. I suppose you chose these, too. I am sorry I can't give you any advice.

rubyalai commented 8 years ago

I pinged Victor and he gave me the following response: "I updated the sources on github to fix the compilation errors. I do not maintain the Python extension; some people at MIT do it for me. It seems they added placeholder python functions that were never implemented, so I just commented those out for now."

Victor's most recent commit on Jan 6, 2016 fixed the issue for me.