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

Problem compiling the code #1

Open
StanleyLG opened this issue Jun 10, 2019 · 6 comments
Open

Problem compiling the code #1

StanleyLG opened this issue Jun 10, 2019 · 6 comments

Comments

@StanleyLG
Copy link

Hi when i tried to use python3 setup.p build_ext --inplace on my RPI, it returned an error
"cannot find -lexamples" , "collect2:error:ld returned 1 exit status", error:command 'arm-linux-gnueabihf-gcc' failed with exit status 1.

When i tried it on Windows 10, it returned 'fatal error C1083, io.h' not found as well as 'cl.exe failed with exit status 2'.

Is it possible you could clear my doubts, this is the first time i'm trying out cython.
Appreciate if you could take some time and i look forward to the reply..

@stavshamir
Copy link
Owner

Hi, did you make sure to follow the instructions specified here?

I am not familiar with the errors you mentioned, so please first make sure that cython is insatlled and the code is exactly as in the instructions. Please reply if it still doesn't work.

@jonathan-durbin
Copy link

I'll leave my solution for anyone in the future who runs into this problem.

I too got this error, and after some troubleshooting, I realized that my examples.c was missing the following two lines:

#include <stdio.h>

#include "examples.h"

Also, I didn't end up creating examples.h, which is in the github repo, but not in the article.

You might also need to create a lib directory and/or position the files in the same structure as shown in the repo.

Hope this helps!

@disadone
Copy link

disadone commented Sep 14, 2019

I clone the repo, however, I have the same problem as @StanleyLG.
I am using python3.7 and Cython 0.29.6 on fedora workstation 30 system.

running build_ext
building 'pyexamples' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Ilib -I/usr/include/python3.7m -c pyexamples.c -o build/temp.linux-x86_64-3.7/pyexamples.o
gcc -pthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -g build/temp.linux-x86_64-3.7/pyexamples.o -Llib -L/usr/lib64 -lexamples -lpython3.7m -o /home/flumer/tmp/cython-c-wrapper/pyexamples.cpython-37m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lexamples
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

@os1315
Copy link

os1315 commented Jun 24, 2020

I'm getting a similar error after running make on the cloned repo.

LINK : fatal error LNK1181: cannot open input file 'examples.lib'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\link.exe' failed with exit status 1181

My specs: Windows 10, Python 3.7.4, Cython 0.29.20, gcc version 9.2.0 (MinGW distribution)

@stavshamir
Copy link
Owner

@os1315 This tutorial was created in linux, so I guess there might be some compatibility issues when using Windows. Sorry I can't give a better answer.

@diydsp
Copy link

diydsp commented Mar 25, 2021

I had a few errors in this. First, running main.py needs the path to the created .so file. In my case, on an RPi4 running Ubuntu20, and python 3.7, the file is pyexamples.cpython-37m-arm-linux-gnueabihf.so. To find the search path, you can follow these directions: https://realpython.com/lessons/module-search-path/ For simplicity, I added this line to the top-level makefile:
cp pyexamples.cpython-37m-arm-linux-gnueabihf.so ~/.local/lib/python3.8/site-packages/pyexamples

So far so good, but when I run main.py, I get this error:

thirtybirds@pinballmatrix:~/noah/cython-c-wrapper$ python main.py
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    pyexamples.py_hello(b"world")
AttributeError: module 'pyexamples' has no attribute 'py_hello'

Any ideas what could be going wrong? Thank you for the tutorial, it's been easy to follow so far.

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

6 participants