I'm trying to build OpenSfM on my M1 MacBook. I installed GCC11, Ceres and OpenCV via MacPorts. I needed to add /opt/local/lib manually to OpenSfM's CMakeLists.txt as setuptools somehow didn't find ceres.h, but afterwards compiling OpenSfM worked fine.
When I later on run a program that uses OpenSfM, it fails with:
Traceback (most recent call last):
File "/Users/pvitt/projects/odm/./run.py", line 19, in <module>
from stages.odm_app import ODMApp
File "/Users/pvitt/projects/odm/stages/odm_app.py", line 10, in <module>
from stages.run_opensfm import ODMOpenSfMStage
File "/Users/pvitt/projects/odm/stages/run_opensfm.py", line 14, in <module>
from opendm.osfm import OSFMContext
File "/Users/pvitt/projects/odm/opendm/osfm.py", line 14, in <module>
from opensfm.large import metadataset
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/opensfm-0.5.2-py3.9.egg/opensfm/large/metadataset.py", line 7, in <module>
from opensfm import io
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/opensfm-0.5.2-py3.9.egg/opensfm/io.py", line 11, in <module>
from opensfm import context, features, geo, pygeometry, pymap, types
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/opensfm-0.5.2-py3.9.egg/opensfm/features.py", line 9, in <module>
from opensfm import context, pyfeatures
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/opensfm-0.5.2-py3.9.egg/opensfm/pyfeatures.cpython-39-darwin.so, 2): Library not loaded: #rpath/libgomp.1.dylib
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/opensfm-0.5.2-py3.9.egg/opensfm/pyfeatures.cpython-39-darwin.so
Reason: image not found
Having a look into /opt/local/lib/ shows me that there is a libgomp.1.dylib:
% ls -al /opt/local/lib/gcc11/libgomp.1.dylib
lrwxr-xr-x 1 root admin 37 May 16 00:57 /opt/local/lib/gcc11/libgomp.1.dylib -> /opt/local/lib/libgcc/libgomp.1.dylib
% ls -al /opt/local/lib/libgcc/libgomp.1.dylib
-rwxr-xr-x 1 root admin 245120 May 16 00:24 /opt/local/lib/libgcc/libgomp.1.dylib
[EDIT]
As my CPU architecture is ARM, I need to have the tools and libs also build for this architecture, what they are:
% file `which gcc`
/opt/local/bin/gcc: Mach-O 64-bit executable arm64
% file /opt/local/lib/opencv4/libopencv_core.4.5.2.dylib
/opt/local/lib/opencv4/libopencv_core.4.5.2.dylib: Mach-O 64-bit dynamically linked shared library arm64
% file /opt/local/lib/gcc11/libgomp.1.dylib
/opt/local/lib/gcc11/libgomp.1.dylib: Mach-O 64-bit dynamically linked shared library arm64
[/EDIT]
So I'm wondering where the error is coming from. Did I do a mistake during compilation? How can I find the reason for this error? As I also had to add /opt/local/lib manually to the CMakeLists.txt file, I suspect that this path is somehow not published properly. But how comes that a folder where MacPorts puts all it's stuff is not used by cmake? Do I have to publish it manually? Via CPATH/LIBRARY_PATH? And why can I just use OpenMP:
% cat test_omp.c
#include <stdio.h>
#include <omp.h>
void main() {
#pragma omp parallel
{
printf("Hello World... from thread = %d\n", omp_get_thread_num());
}
}
% gcc -fopenmp test_omp.c
% ./a.out
Hello World... from thread = 1
Hello World... from thread = 3
Hello World... from thread = 2
Hello World... from thread = 5
Hello World... from thread = 4
Hello World... from thread = 6
Hello World... from thread = 0
Hello World... from thread = 7
I fear it is something really silly, but I just don't see it.
Related
Installing pymqi in a MacOS M1 Pro 12.1 Monterey, Python 3.9.9 in a virtualenv and the usual suspect appeared again:
Traceback (most recent call last):
File "/Users/a.gounaris/.virtualenvs/mxhub39/lib/python3.9/site-packages/pymqi/__init__.py", line 132, in <module>
from . import pymqe # type: ignore
ImportError: dlopen(/Users/a.gounaris/.virtualenvs/mxhub39/lib/python3.9/site-packages/pymqi/pymqe.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_MQBACK'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/a.gounaris/.virtualenvs/mxhub39/lib/python3.9/site-packages/pymqi/__init__.py", line 134, in <module>
import pymqe # type: ignore # Backward compatibility
ModuleNotFoundError: No module named 'pymqe'
All paths are in place /opt/mqm/bin:/opt/mqm/samp/bin and Python sees the env variable os.environ['DYLD_LIBRARY_PATH']=='/opt/mqm/lib64'
After reinstalling pymqi with --verbose flag, this warning showed up:
ld: warning: ignoring file /opt/mqm/lib64/libmqic_r.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Might be the root cause of the exception symbol not found in flat namespace '_MQBACK' in M1 Pro Silicon platforms ?
It says that ibmqic_r.dylib is ignored.
Would a new release of MacOS Toolkit build for macOS-arm64 solve the issue?
Another option - theoretically speaking - could be to run the build for macOS-x86_64 with Rosetta 2 as suggested in this post, I don't know how to do it..
Any help will be mostly appreciated.
I am trying to compile following trivial code with Cython on Windows7 (64bit) and WinPython:
File testpy.py:
print("hello world from testpy.py file.")
File compile.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
Extension("testpy", ["testpy.py"]),
# ... all your modules that need be compiled ...
]
setup(
name = 'My Program Name',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
I first give command to use mingw:
D:\myfolder> make_cython_use_mingw
cython has been set to use mingw32
to remove this, remove file "E:\WinPython\settings\pydistutils.cfg"
I then give command to compile:
D:\myfolder> python compile.py build_ext --inplace
The process starts but ends with following error:
running build_ext
skipping 'testpy.c' Cython extension (up-to-date)
building 'testpy' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -IE:\WinPython\python-3.6.5.amd64\include -IE:\WinPython\python-3.6.5.amd64\include -c testpy.c -o build
\temp.win-amd64-3.6\Release\testpy.o
In file included from E:\WinPython\python-3.6.5.amd64\include/Python.h:68:0,
from testpy.c:4:
E:\WinPython\python-3.6.5.amd64\include/pytime.h:122:12: warning: 'struct timeval' declared inside parameter list will not be visible outsid
e of this definition or declaration
struct timeval *tv,
^~~~~~~
E:\WinPython\python-3.6.5.amd64\include/pytime.h:127:12: warning: 'struct timeval' declared inside parameter list will not be visible outsid
e of this definition or declaration
struct timeval *tv,
^~~~~~~
writing build\temp.win-amd64-3.6\Release\testpy.cp36-win_amd64.def
C:\MinGW\bin\gcc.exe -shared -s build\temp.win-amd64-3.6\Release\testpy.o build\temp.win-amd64-3.6\Release\testpy.cp36-win_amd64.def -LE:\Wi
nPython\python-3.6.5.amd64\libs -LE:\WinPython\python-3.6.5.amd64\PCbuild\amd64 -lpython36 -o D:\myfolder\testpy.cp36-win_amd64.pyd
Cannot export PyInit_testpy: symbol not defined
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1
Where is the problem and how can it be solved?
Edit:
On renaming py file as pyx as suggested by #ead in comments, it worked to create pyd file. However, on trying it gives following error:
D:\Myfolder>python -c "import Testpy"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.
Why is this not a valid Win32 application?
My python version is as follows:
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Edit: I found that I had mingw installed separately also (apart from part of winpython). I removed that and tried again. I am now getting following error:
python compile.py build_ext --inplace
Traceback (most recent call last):
File "compile.py", line 12, in <module>
ext_modules = ext_modules
File "E:\WinPython\python-3.6.5.amd64\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "E:\WinPython\python-3.6.5.amd64\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "E:\WinPython\python-3.6.5.amd64\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "E:\WinPython\python-3.6.5.amd64\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "E:\WinPython\python-3.6.5.amd64\lib\distutils\command\build_ext.py", line 308, in run
force=self.force)
File "E:\WinPython\python-3.6.5.amd64\lib\distutils\ccompiler.py", line 1031, in new_compiler
return klass(None, dry_run, force)
File "E:\WinPython\python-3.6.5.amd64\lib\distutils\cygwinccompiler.py", line 282, in __init__
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
File "E:\WinPython\python-3.6.5.amd64\lib\distutils\cygwinccompiler.py", line 126, in __init__
if self.ld_version >= "2.10.90":
TypeError: '>=' not supported between instances of 'NoneType' and 'str'
How can this be corrected?
When running a Python script that contain import theano, I get this error:
===============================
00001 #include <Python.h>
00002 #include "structmember.h"
00003 #include <sys/time.h>
00004
00005 // Old Python compatibility from here:
00006 // http://www.python.org/dev/peps/pep-0353/
[...]
01077 return RETVAL;
01078 }
01079
01080
Problem occurred during compilation with the command line below:
C:\programming\cpp\gcc-4.9.2-tdm-1-core\bin\g++.exe -shared -g -D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -IC:\Anaconda\lib\site-packages\numpy\core\include -IC:\Anaconda\include -o C:\Users\Francky\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.10-64\lazylinker_ext\lazylinker_ext.pyd C:\Users\Francky\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.10-64\lazylinker_ext\mod.cpp -LC:\Anaconda\libs -LC:\Anaconda -lpython27
===============================
g++.exe: error: CreateProcess: No such file or directory
Traceback (most recent call last):
File "C:\Users\Francky\Documents\GitHub\nlp\6864project\code\theano\eval_dialog_cat.py", line 7, in <module>
import theano
File "c:\users\francky\downloads\theano-rel-0.7\theano-rel-0.7\theano\__init__.py", line 55, in <module>
from theano.compile import \
File "c:\users\francky\downloads\theano-rel-0.7\theano-rel-0.7\theano\compile\__init__.py", line 9, in <module>
from theano.compile.function_module import *
File "c:\users\francky\downloads\theano-rel-0.7\theano-rel-0.7\theano\compile\function_module.py", line 18, in <module>
import theano.compile.mode
File "c:\users\francky\downloads\theano-rel-0.7\theano-rel-0.7\theano\compile\mode.py", line 11, in <module>
import theano.gof.vm
File "c:\users\francky\downloads\theano-rel-0.7\theano-rel-0.7\theano\gof\vm.py", line 568, in <module>
import lazylinker_c
File "c:\users\francky\downloads\theano-rel-0.7\theano-rel-0.7\theano\gof\lazylinker_c.py", line 116, in <module>
preargs=args)
File "c:\users\francky\downloads\theano-rel-0.7\theano-rel-0.7\theano\gof\cmodule.py", line 2010, in compile_str
(status, compile_stderr.replace('\n', '. ')))
. ception: Compilation failed (return status=1): g++.exe: error: CreateProcess: No such file or directory
It looks like g++.exe: error: CreateProcess: No such file or directory is caused by the absence of the file C:\Users\Francky\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.10-64\lazylinker_ext\lazylinker_ext.pyd. How am I supposed to get this file?
I have installed Theano in Anaconda Python 2.7.10 X64 as follows:
conda install mingw libpython
pip install theano
Then I changed the g++ compiler namely TDM-GCC MinGW Compiler so that it compiles to x64 (otherwise I get C:\Users\Francky\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.10-64\lazylinker_ext\mod.cpp:1: sorry, unimplemented: 64-bit mode not compiled in).
From here.
Have you closed your Command window and opened a new one? Changes to your environment variables (via the standard Windows dialogue window) will not apply to open Command windows (you could set the variables separately and manually in an open Command window though).
If setting environment variables doesn't help, the other answers to the linked question may help.
I've spent a couple of days on this. Ultimately I had to update theano AFTER changing my G++ compiler to 64 bit (I used http://mingw-w64.org/doku.php). Windows "where" command makes it easy to see where the g++ is installed: where g++ gave me several locations including the 32bit version.
I need to run node 0.8.4 for a project, but I'm having trouble getting it to install. I've installed nvm in order to run it alongside my current system version of node, but I'm getting an error when I run nvm install 0.8.4:
Node.js configure error: No acceptable C compiler found!
Please make sure you have a C compiler installed on your system and/or
consider adjusting the CC environment variable if you installed
it in a non-standard prefix.
./configure
Node.js configure error: No acceptable C compiler found!
Please make sure you have a C compiler installed on your system and/or
consider adjusting the CC environment variable if you installed
it in a non-standard prefix.
python tools/gyp_node -f make
Traceback (most recent call last):
File "tools/gyp_node", line 58, in <module>
run_gyp(gyp_args)
File "tools/gyp_node", line 18, in run_gyp
rc = gyp.main(args)
File "./tools/gyp/pylib/gyp/__init__.py", line 471, in main
options.circular_check)
File "./tools/gyp/pylib/gyp/__init__.py", line 111, in Load
depth, generator_input_info, check, circular_check)
File "./tools/gyp/pylib/gyp/input.py", line 2378, in Load
depth, check)
File "./tools/gyp/pylib/gyp/input.py", line 430, in LoadTargetBuildFile
includes, depth, check)
File "./tools/gyp/pylib/gyp/input.py", line 384, in LoadTargetBuildFile
build_file_data, PHASE_EARLY, variables, build_file_path)
File "./tools/gyp/pylib/gyp/input.py", line 975, in ProcessVariablesAndConditionsInDict
variables, build_file, 'variables')
File "./tools/gyp/pylib/gyp/input.py", line 982, in ProcessVariablesAndConditionsInDict
expanded = ExpandVariables(value, phase, variables, build_file)
File "./tools/gyp/pylib/gyp/input.py", line 739, in ExpandVariables
' in ' + build_file
KeyError: 'Undefined variable target_arch in /Users/raddevon/.nvm/src/node-v0.8.4/deps/v8/tools/gyp/v8.gyp while loading dependencies of /Users/raddevon/.nvm/src/node-v0.8.4/node.gyp while trying to load /Users/raddevon/.nvm/src/node-v0.8.4/node.gyp'
make: *** [out/Makefile] Error 1
nvm: install v0.8.4 failed!
I first tried to make sure I had the Xcode command line tools installed, and it appears that I do. gcc does work. Any ideas how I can get this working?
I'm running on a Macbook, OS X 10.6.4. I've installed the latest version of libusb 1.x and also libusb-compat. The example applications in libusb compile and run, no problems there so I am assuming that it's installed correctly. Libftdi also appears to install correctly, but it seems to be having trouble with libusb. I tried one of the example apps and I get this error message:
$ ./simple
dyld: lazy symbol binding failed: Symbol not found: _usb_init
Referenced from: /Users/Me/Downloads/libftdi-0.19/src/.libs/libftdi.1.dylib
Expected in: flat namespace
dyld: Symbol not found: _usb_init
Referenced from: /Users/Me/Downloads/libftdi-0.19/src/.libs/libftdi.1.dylib
Expected in: flat namespace
Trace/BPT trap
The assumption that libusb is to blame is because _usb_init is a libusb function, I found a post here that was along the same lines http://www.jedi.be/blog/2009/11/11/ruby-usb-libusb/ but for Ruby.
Trying to get things going with Pylibftdi,
Traceback (most recent call last):
File "blah/list_devices.py", line 4, in <module>
for device in Driver().list_devices():
File "/Library/Python/2.6/site-packages/pylibftdi/driver.py", line 61, in __init__
fdll = CDLL(ftdi_lib)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 345, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/libftdi.dylib, 6): Symbol not found: _usb_bulk_read
Referenced from: /usr/local/lib/libftdi.dylib
Expected in: flat namespace
in /usr/local/lib/libftdi.dylib
Note that to get anything to even run using Pyftdi I had to install libftdi for i386 rather than x86_64 as default (throws up mach-o errors) - however, even installing libftdi 'normally' gives the OSErrors above. Any suggestions would be greatly appreciated.
I believe with libftdi 0.19 you're supposed to use libusb 0.1 (atleast according to thier web page. http://www.intra2net.com/en/developer/libftdi/download.php). There's a port of libftdi out there to use libusb 1.0 if you want. I've been using it for SYNC and ASYNC Fifos and its been working great.
http://developer.intra2net.com/git/?p=libftdi-1.0
git://developer.intra2net.com/libftdi-1.0
Good luck