Quantlib Mac OSX - ld: symbol(s) not found for architecture arm64 - python

I want to install Quantlib from source to enable intraday support for Python. When installing QuantLib from source on Mac OSX 11.1 with M1 chip I am facing a problem during the 'make' in the tests.
Undefined symbols for architecture arm64:
"_PrimitivePolynomials", referenced from:
LowDiscrepancyTest::testPolynomialsModuloTwo() in lowdiscrepancysequences.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [quantlib-test-suite] Error 1
make: *** [all-recursive] Error 1

This looks like the linker is not finding the QuantLib libraries you have just compiled, and is instead trying to link to a version compiled for a different architecture. Try running make install or sudo make install prior to compiling the tests -- if that works, then you have something going on with your library paths.

Related

How does one properly #include "Python.h" in macOS?

I am trying to develop c extensions for python, which requires me to use
#include "Python.h"
in the c source code. However, it appears that Python.h in Ubuntu systems can be obtained by downloading python-dev, but this is not an option for macOS.
I tried compiling using /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers/ (which contains a Python.h file) but When I use the command
gcc test.c -I /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers/
I get the following error:
Undefined symbols for architecture arm64:
"_PyObject_Size", referenced from:
_main in test-165478.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Which makes it seem that the Python.h file on my mac is incomplete somehow. Is the solution to this problem downloading the source of python-dev and then using the Python.h header file that is in that package? If so, where could I find the python-dev source code?

Can't find Python executable "python", you can set the PYTHON env variable

i'm using m1 macbook
on zsh terminal,
I command
python3 --version
then it shows version
but python --version
zsh: command not found: python
what maybe the problem?
I tried pyenv then install ,
but it cause different error
pedrojung#pedroui-MacBookPro newtemp % pyenv install 2.7.5
Downloading openssl-1.0.2k.tar.gz...
-> https://pyenv.github.io/pythons/6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
Installing openssl-1.0.2k...
BUILD FAILED (OS X 12.3 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/j_/1jx3n6k9085b2zsqpw92n84c0000gn/T/python-build.20220322161549.77349
Results logged to /var/folders/j_/1jx3n6k9085b2zsqpw92n84c0000gn/T/python-build.20220322161549.77349.log
Last 10 log lines:
_dgram_write in libcrypto.a(bss_dgram.o)
_RAND_query_egd_bytes in libcrypto.a(rand_egd.o)
...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [link_a.darwin] Error 1
make[3]: *** [do_darwin-shared] Error 2
make[2]: *** [libcrypto.1.0.0.dylib] Error 2
make[1]: *** [shared] Error 2
make: *** [build_crypto] Error 1
About the absence of the python command:
python - calls Python 2
python3 - calls Python 3
If you want to call Python 3 with the python command you can create a symbolic link. Warning: only run this command if you really need to!
Command: sudo ln -s /usr/bin/python3 /usr/bin/python
About the pyenv error: ld: symbol(s) not found for architecture i386 - this means that the installer is alive with the Intel x86 architecture and you have the Apple M1 architecture.

pyarrow==0.17.1 installation ends with fatal error: 'arrow/python/config.h' file not found (Apple M1 chip)

I'm trying to install the pyarrow==0.17.1 package on my MacBook pro machine (Apple M1 chip) and I'm getting the following error
-- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "0.29.2")
-- Found Arrow: /opt/homebrew/Cellar/apache-arrow/7.0.0_3/include (found version "7.0.0")
-- Arrow version: 7.0.0 (HOME: /opt/homebrew/Cellar/apache-arrow/7.0.0_3)
-- Arrow SO and ABI version: 700
-- Arrow full SO version: 700.0.0
-- Found the Arrow core shared library: /opt/homebrew/Cellar/apache-arrow/7.0.0_3/lib/libarrow.dylib
-- Found the Arrow core import library: /opt/homebrew/Cellar/apache-arrow/7.0.0_3/lib/libarrow.dylib
-- Found the Arrow core static library: /opt/homebrew/Cellar/apache-arrow/7.0.0_3/lib/libarrow.a
-- Found ArrowPython: /opt/homebrew/Cellar/apache-arrow/7.0.0_3/include (found version "7.0.0")
-- Found the Arrow Python by HOME: /opt/homebrew/Cellar/apache-arrow/7.0.0_3
-- Found the Arrow Python shared library: /opt/homebrew/Cellar/apache-arrow/7.0.0_3/lib/libarrow_python.dylib
-- Found the Arrow Python import library: /opt/homebrew/Cellar/apache-arrow/7.0.0_3/lib/libarrow_python.dylib
-- Found the Arrow Python static library: /opt/homebrew/Cellar/apache-arrow/7.0.0_3/lib/libarrow_python.a
-- Configuring done
-- Generating done
-- Build files have been written to: /private/var/folders/6m/ychzdp6s7l390zfm77myvxzr0000gn/T/pip-install-lv5qrivl/pyarrow_12e0171ed6fa433da71d5392c3e10c3a/build/temp.macosx-12.0-arm64-3.7
-- Finished cmake for pyarrow
-- Running cmake --build for pyarrow
cmake --build . --config release --
[ 6%] Compiling Cython CXX source for lib...
[ 6%] Built target lib_pyx
[ 13%] Building CXX object CMakeFiles/lib.dir/lib.cpp.o
/private/var/folders/6m/ychzdp6s7l390zfm77myvxzr0000gn/T/pip-install-lv5qrivl/pyarrow_12e0171ed6fa433da71d5392c3e10c3a/build/temp.macosx-12.0-arm64-3.7/lib.cpp:774:10: fatal error: 'arrow/python/config.h' file not found
#include "arrow/python/config.h"
^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/lib.dir/lib.cpp.o] Error 1
make[1]: *** [CMakeFiles/lib.dir/all] Error 2
make: *** [all] Error 2
error: command 'cmake' failed with exit status 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
I couldn't find a proven solution for this problem, the only reference I did review is the following - https://github.com/apache/arrow/issues/2281, as mentioned, no proven solution there.
Versions I'm using are:
python 3.7.12
pip 22.0.4
On my machine, I have the following installed - apache-arrow, apache-arrow-glib, cmake.
I've also tried to install the package with the --no-use-pep517 flag as the following- pip install --no-use-pep517 pyarrow==0.17.1 - no success there.
I took a peek inside arrow/python/ and config.h is obviously missing, I also look inside arrow/ which does contains a config.h, however, it's not the config.h that was required.
Does anyone have an idea how to solve this issue?
pyarrow==0.17.1 predates M1 chips (May 2020 vs November 2020).
Any particular reason you wouldn't want to use pyarrow==7.0.0? Your brew installed arrow seems to be 7.0.0 too.

Install caffe/pycaffe on MacOSX High Sierra

I'm following this tutorial to install caffe on my OSX High Sierra.
I followed all steps but I'm stucked when installing R-CNN example at this step:
$ make -j8 && make pycaffe
LD -o .build_release/lib/libcaffe.so
clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
ld: cannot link directly with /System/Library/Frameworks//vecLib.framework/vecLib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [.build_release/lib/libcaffe.so] Error 1
But the library veclib is present:
$ ls /System/Library/Frameworks//vecLib.framework/vecLib
/System/Library/Frameworks//vecLib.framework/vecLib
Can you help me please to solve this issue ?
I met the same issue. I installed Xcode 9.3 Commandline tool and changed cmake/Modules/FindvecLib.cmake to something like this and it works:
find_path(vecLib_INCLUDE_DIR cblas.h
DOC "vecLib include directory"
PATHS /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
NO_DEFAULT_PATH)
For my case, NO_DEFAULT_PATH must be set or there will be still link error.
You can also refer to this.

OpenCV's Python - OS X

I get the following error while building OpenCV on OS X 10.5 (intel):
ld: warning in .libs/_cv_la-_cv.o, file is not of required architecture
ld: warning in .libs/_cv_la-error.o, file is not of required architecture
ld: warning in .libs/_cv_la-pyhelpers.o, file is not of required architecture
ld: warning in .libs/_cv_la-cvshadow.o, file is not of required architecture
ld: warning in ../../../cv/src/.libs/libcv.dylib, file is not of required architecture
ld: warning in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libcxcore.dylib, file is not of required architecture
Undefined symbols for architecture i386:
"_fputs$UNIX2003", referenced from:
_PySwigObject_print in _cv_la-_cv.o
_PySwigPacked_print in _cv_la-_cv.o
_PySwigPacked_print in _cv_la-_cv.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/Sr/Srq9N4R8Hr82xeFvW3o-uk+++TI/-Tmp-//cchT0WVX.out (No such file or directory)
make[4]: *** [_cv.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
While running ./configure --without-python everything is ok. Another strange thing is that when I used Python 2.4.5 or 2.5.1 everything has built ok, the problem occured after switching to Python Framework 2.5.2
It seems a little weird that it is warning about different architectures when looking for /Developer/SDKs/MacOSX10.4u.sdk while linking - can you give us some more detail about your build environment (version of XCode, GCC, Python, $PATH etc)
Alternatively, won't any of the OpenCV binaries available work for you?
/Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib is just a link to /usr/local/lib
after deleting files that caused the warnings I'm getting :
ld: warning in .libs/_cv_la-_cv.o, file is not of required architecture
ld: warning in .libs/_cv_la-error.o, file is not of required architecture
ld: warning in .libs/_cv_la-pyhelpers.o, file is not of required architecture
ld: warning in .libs/_cv_la-cvshadow.o, file is not of required architecture
ld: warning in ../../../cv/src/.libs/libcv.dylib, file is not of required architecture
ld: warning in /Users/Pietras/opencv/cxcore/src/.libs/libcxcore.dylib, file is not of required architecture
Undefined symbols for architecture i386: ... `
And these files are created by make.
gcc: i686-apple-darwin9-gcc-4.0.1
$PATH:
/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/AVRMacPack/bin:/usr/X11R6/bin
XCode 3 (latest)
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) - MacPython from python.org
(tried to downgrade and use it instead of 2.5.2, but that doesn't work anymore...)
which python
/Library/Frameworks/Python.framework/Versions/Current/bin/python
I didn't find any Python OpenCV binaries for OS X.
I've tried to make it while setting python2.4 or 2.5 from macports as default and it compiles and installs, but when I try to import there is a bus error or Fatal Python error Interpreter not initialized (version mismatch?)
and it quits.
Ok, I kind of worked it out
It needs to be compiled with python from macports or whatever. Then I need to run /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 (this is my previous python version) and there OpenCV just works.

Categories