Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6337267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:13:16+00:00 2026-05-24T19:13:16+00:00

I am walking through the Cython documentation and building each of the example apps.

  • 0

I am walking through the Cython documentation and building each of the example apps. I’m a little stuck at Using C Libraries. After successfully building the .so file and attempting to import it in a python file called test.py the following error is thrown.

$ python3.2 test.py 
Traceback (most recent call last):
  File "test.py", line 12, in <module>
    from queue import Queue
ImportError: dlopen(/Users/jeremy/Development/labs/python/cython_lib_wrapper/queue.so, 2): Symbol not found: _queue_free
  Referenced from: /Users/jeremy/Development/labs/python/cython_lib_wrapper/queue.so
  Expected in: flat namespace
 in /Users/jeremy/Development/labs/python/cython_lib_wrapper/queue.so

The .so file sits right next to the test.py file. So, it seems as though it should be found.
This is running the latest version of Cython, with Python 3.2 on a OSX 10.6.

Any insights?

Edit – adding build command and output

$ python3.2 setup.py build_ext --inplace
running build_ext
cythoning queue.pyx to queue.c
building 'queue' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m -c queue.c -o build/temp.macosx-10.6-intel-3.2/queue.o
    queue.c: In function ‘__pyx_f_5queue_5Queue_append’:
    queue.c:627: warning: cast to pointer from integer of different size
    queue.c: In function ‘__pyx_f_5queue_5Queue_extend’:
    queue.c:740: warning: cast to pointer from integer of different size
    queue.c: In function ‘__pyx_f_5queue_5Queue_peek’:
    queue.c:813: warning: cast from pointer to integer of different size
    queue.c: In function ‘__pyx_f_5queue_5Queue_pop’:
    queue.c:965: warning: cast from pointer to integer of different size
    gcc-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.6-intel-3.2/queue.o -o 

Edit 2 – adding “otool” cmd requested in comment

queue.so:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)

Edit 3 – adding “nm” output

U ___stack_chk_fail
U ___stack_chk_guard
U _queue_free
U _queue_is_empty
U _queue_new
U _queue_peek_head
U _queue_pop_head
U _queue_push_tail
U dyld_stub_binder

grep cmd outputs this:

(undefined) external _queue_free (dynamically looked up)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:13:18+00:00Added an answer on May 24, 2026 at 7:13 pm

    EDIT:

    Ah, you didn’t mention you had a dependency on the code in libcalg. That stuff needs to be compiled and included when you build the cextension.

    Just modify setup.py:

    # setup.py
    # ...
    ext_modules = [Extension("queue", ["queue.pyx", "libcalg/queue.c"])]
    # ...
    

    We could step back and see if you can build a really simple example:

    I’ve tried the following (3 files, myext.pyx, test.py, setup.py) and it appears to work fine. Of course I’m on OS X 10.7 so it’s not exactly the same as your environment. To rule out differences perhaps you can copy these and build them as a sanity check.

    Contents of myext.pyx:

    # myext.pyx
    def square(x):
        return x * x
    

    Contents of test.py

    # test.py
    from myext import square
    print "%d squared is %d"%(4, square(4))
    

    Contents of setup.py:

    # setup.py
    from distutils.core import setup
    from distutils.extension import Extension
    from Cython.Distutils import build_ext
    
    ext_modules = [Extension("myext", ["myext.pyx"])]
    
    setup(
      name = 'Hello world app',
      cmdclass = {'build_ext': build_ext},
      ext_modules = ext_modules
    )
    

    I build in the directory containing these 3 files:

    cython_test$ /usr/bin/python setup.py build_ext --inplace 
    running build_ext
    cythoning myext.pyx to myext.c
    building 'myext' extension
    creating build
    creating build/temp.macosx-10.7-intel-2.7
    llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c myext.c -o build/temp.macosx-10.7-intel-2.7/myext.o
    llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/myext.o -o /Users/steder/SO/cython_test/myext.so
    
    cython_test$ python test.py
    4 squared is 16:
    

    My environment has similar otool output and DYLD_LIBRARY_PATH is also unset but nm -m shows squared as defined.

    Specifically:

    00000000000011d0 (__DATA,__data) non-external ___pyx_k__square
    00000000000011e0 (__DATA,__data) non-external ___pyx_mdef_5myext_square
    0000000000001218 (__DATA,__bss) non-external ___pyx_n_s__square
    0000000000000c80 (__TEXT,__text) non-external ___pyx_pf_5myext_square
    

    Please give this a shot and see what it nm -m shows in your environment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm walking through a small example to hit https web services. It requires building
I am using the Google Appengine remote shell, with Python. I am walking through
I am walking through a xml definition file and I have a DOMNodeList that
Ok, I'm certainly familiar with walking through a table using a read-only cursor, but
I am walking through the MS Press Windows Workflow Step-by-Step book and in chapter
I am walking through a Visual FoxPro program trying to document the code in
While walking HTML5 DOM tree I want to determine whether each element is a
I have a 2giga mpeg file of people runnig,jogging,walking etc. in it. I will
I'm walking through the FrontStore series tutorial on TDD in MVC ( Part 3
If I am walking through an IEnumerable<T> , is there any way to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.