I'm using Mac, and I am trying to write my own c code to use it from Python. I'm new to this, and trying out a sample example from http://www.tutorialspoint.com/python/python_further_extensions.htm.
But, when I run the setup.py file to install my c file, it gives me an error, and I'm not sure what to do. Below is the resulting error message. Thanks a lot!
$ sudo python3 setup.py install
Password:
running install
running build
running build_ext
building 'sample' extension
clang -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/sqlite/include -DFOO=1 -UBAR -I/some/dir -I/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c pysample.c -o build/temp.macosx-10.10-x86_64-3.4/pysample.o
clang -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.10-x86_64-3.4/pysample.o -L/usr/local/lib -lsample -o build/lib.macosx-10.10-x86_64-3.4/sample.so
ld: library not found for -lsample
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
Related
There are many similar posts with the same error what I am facing, but none of the solutions worked for me. Please do not think this as repeated. I am reaching you out after trying with all the solutions suggested.
I am trying to create a python library from c++ file that uses boost library with
#include <boost/thread.hpp>
I have installed Boost in Ubuntu through the commands
./bootstrap.sh --prefix=/usr/local
and then
./b2 install --with-thread
.
Now, when I try to run a file with #include <boost/thread.hpp> it gives me this error saying
src/main.cpp:2:10: fatal error: boost/thread.hpp: No such file or directory
Am I missing on something? Can someone help me how can I solve this.
Error
I will attach a screenshot of the same for viewing.
Also pasting the error description in-case someone does not feel comfortable to view image
Failed building wheel for python-example
Running setup.py clean for python-example
Failed to build python-example
Installing collected packages: python-example
Running setup.py install for python-example ... error
Complete output from command /home/hmi/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-h4742spy /setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-3l3u7dxm/install-record.txt --single-version-externally- managed --compile:
running install
running build
running build_ext
gcc -pthread -B /home/hmi/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hmi/anaconda3/include/python3.7m -c /tmp/tmpbv27mdxm.cpp -o tmp/tmpbv27mdxm.o -std=c++17
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/hmi/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hmi/anaconda3/include/python3.7m -c /tmp/tmps2iqs0qp.cpp -o tmp/tmps2iqs0qp.o -fvisibility=hidden
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
building 'python_example' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/src
gcc -pthread -B /home/hmi/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hmi/anaconda3/include -I/home/hmi/anaconda3/include -I/home/hmi/anaconda3/include/python3.7m -c src/main.cpp -o build/temp.linux-x86_64-3.7/src/main.o -DVERSION_INFO="0.0.1" -std=c++17 -fvisibility=hidden
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/main.cpp:2:10: fatal error: boost/thread.hpp: No such file or directory
#include <boost/thread.hpp>
^~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
I have also tried with this command
g++ -std=c++11 main.cpp -lpthread -lboost_system -lboost_thread -o main
. But similar result.
OS : Ubuntu 18.04
Boost version : 1.55
I have now resolved it with the command mentioned by Botje but with sudo.
sudo apt install libboost-thread-dev
But I did not want to do through root. So I have refrained its usage. But now I did not find any other way. I would be glad to know if any other solution works
I am trying to download pygame and am getting an error. I am on a mac computer on OS X 10.11.6. I have an updated version of pip and have Xcode already installed.The error comes up when I type in pip3 install pygame. The error is below...
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -DENABLE_NEWBUF=1 -I/NEED_INC_PATH_FIX -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c src/scrap.c -o build/temp.macosx-10.6-intel-3.5/src/scrap.o
src/scrap.c:27:10: fatal error: 'SDL.h' file not found
#include "SDL.h"
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
Most sites say to run this in terminal: xcode-select --install which will install xcode tools.
As for installing pygame with python3 on mac, it can be tricky sometimes, so if running the above in terminal stops that error but brings up another un-xcode-related one, I would suggest going here or here if that link fails.
I have problems building pywt from source on Ubuntu.
When I run python setup.py build, I get the following error:
running build
running build_py
running build_ext
Cython is not installed. Using compiled file: src/_pywt.pyx
building 'pywt._pywt' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPY_EXTENSION -Isrc -I/usr/local/include/python2.7 -c src/_pywt.c -o build/temp.linux-x86_64-2.7/src/_pywt.o
gcc: error: src/_pywt.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 4
When I run cython --version I get the following output:
Cython version 0.21.1
pywt can be installed as an Ubuntu package using apt-get:
sudo apt-get install python-pywt
I'm trying to install pip install python-docx but get the following error. Why doesn't it work?
building 'lxml.etree' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
creating build/temp.linux-x86_64-2.7/src/lxml
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_plakshma/lxml/src/lxml/includes -I/opt/python2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
gcc -pthread -shared build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -L/usr/lib64 -L. -lxslt -lexslt -lxml2 -lz -lm -lpython2.7 -o build/lib.linux-x86_64-2.7/lxml/etree.so
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Type this in your terminal/cmd.
pip install python-docx.
For me when I made typed it in the apple terminal it was an error but type in the Pycharm terminal and it should work.
I am trying to make a backup solution off docker containers using rdiff. I have python install and the python-dev packages but when I run the install command:
python ./setup.py install
I get the following error
running install
running build
running build_py
running build_ext
building 'rdiff_backup._librsync' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.7 -c _librsyncmodule.c -o build/temp.linux-x86_64-2.7/_librsyncmodule.o
_librsyncmodule.c:25:22: fatal error: librsync.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Your container needs the librsync-dev package.