Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_array causing install errors #20

Open
dc1340 opened this issue Sep 6, 2017 · 1 comment
Open

import_array causing install errors #20

dc1340 opened this issue Sep 6, 2017 · 1 comment

Comments

@dc1340
Copy link

dc1340 commented Sep 6, 2017

Trying to install on a brand new Mac (10.12.6):

python --version

Python 2.7.11 :: Anaconda 2.5.0 (x86_64)

conda list

packages in environment at //anaconda/envs/kinect:

freetype 2.5.5 2
jpeg 8d 2
lcms 1.19 0
libpng 1.6.30 1
mkl 2017.0.3 0
numpy 1.7.1 py27_2
opencv 2.4.8 np17py27_2
openssl 1.0.2l 0
pil 1.1.7 py27_2
pip 9.0.1 py27_1
python 2.7.13 0
readline 6.2 2
scipy 0.13.2 np17py27_1
setuptools 27.2.0 py27_0
sqlite 3.13.0 0
tk 8.5.18 0
wheel 0.29.0 py27_0
zlib 1.2.11 0

sudo python setup.py install

src/Frame.cpp:44:2: error: non-void function 'py_Frame_getData' should return a value [-Wreturn-type]
import_array();
^
//anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1532:144: note: expanded from macro 'import_array'
#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IM...
^
src/Frame.cpp:64:2: error: non-void function 'py_Frame_getDepthData' should return a value [-Wreturn-type]
import_array();
^
//anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1532:144: note: expanded from macro 'import_array'
#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IM...

Commenting out the import_array() calls in Frame.cpp leads to the following error:

sudo python setup.py install

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
//anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1448:1: warning: unused function '_import_array' [-Wunused-function]
_import_array(void)
^
1 warning generated.
g++ -bundle -undefined dynamic_lookup -L//anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/pyfreenect2.o build/temp.macosx-10.5-x86_64-2.7/src/Frame.o build/temp.macosx-10.5-x86_64-2.7/src/FrameMap.o build/temp.macosx-10.5-x86_64-2.7/src/Freenect2.o build/temp.macosx-10.5-x86_64-2.7/src/Freenect2Device.o build/temp.macosx-10.5-x86_64-2.7/src/Registration.o build/temp.macosx-10.5-x86_64-2.7/src/SyncMultiFrameListener.o build/temp.macosx-10.5-x86_64-2.7/src/SmartFrame.o -L//anaconda/lib -lfreenect2 -o build/lib.macosx-10.5-x86_64-2.7/_pyfreenect2.so

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]

clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'g++' failed with exit status 1
`

@dc1340
Copy link
Author

dc1340 commented Sep 6, 2017

Should also state that I modified SmartPtr.hpp to deal with a previous error where pthread_spin_init, pthread_spin_destroy, etc, were apparently not portable on Mac OS. Following the thread here, I added the following lines to SmartPtr.hpp:

#include <libkern/OSAtomic.h>

\\...
\\...
\\...

typedef int pthread_spinlock_t;

int pthread_spin_init(pthread_spinlock_t *lock, int pshared) {
    __asm__ __volatile__ ("" ::: "memory");
    *lock = 0;
    return 0;
}

int pthread_spin_destroy(pthread_spinlock_t *lock) {
    return 0;
}

int pthread_spin_lock(pthread_spinlock_t *lock) {
    while (1) {
        int i;
        for (i=0; i < 10000; i++) {
            if (__sync_bool_compare_and_swap(lock, 0, 1)) {
                return 0;
            }
        }
        sched_yield();
    }
}

int pthread_spin_trylock(pthread_spinlock_t *lock) {
    if (__sync_bool_compare_and_swap(lock, 0, 1)) {
        return 0;
    }
    return EBUSY;
}

int pthread_spin_unlock(pthread_spinlock_t *lock) {
    __asm__ __volatile__ ("" ::: "memory");
    *lock = 0;
    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant