Import Error: Undefined Symbol

592 views
Skip to first unread message

CyclingNinja

unread,
Oct 24, 2016, 7:47:33 AM10/24/16
to cython-users
Sorry for the spam, but this is all very new to me and I've had a few days of misdiagnosis of the issue.

when running my code, it compiles just fine using python setup.py etc.

However when importing the results into python I get that error and my variables names are 'Mangled' as I believe the technical term is and look like this:

0000000000007ab8 r _ZL12__pyx_k_main
0000000000007aaf r _ZL12__pyx_k_test
000000000020a160 b _ZL12__pyx_lineno
000000000020a000 b _ZL12__pyx_n_s_np
0000000000209fc0 b _ZL12__pyx_n_s_pd
0000000000209f28 b _ZL12__pyx_tuple_
000000000020a150 b _ZL13__pyx_clineno

instead of this

0000000000007ab8 r __pyx_k_main
0000000000007aaf r __pyx_k_test
000000000020a160 b __pyx_lineno
000000000020a000 b __pyx_n_s_np
0000000000209fc0 b __pyx_n_s_pd
0000000000209f28 b __pyx_tuple_
000000000020a150 b __pyx_clineno


At first I thought it was because the structure was pointing in a different place, however, changing that method did not help.
Having googled around, I've ruled out clashing names of files but that about it.

I can demangle them using nm -C as I found on the interwebs, but I do not know how to implement this into the code to fix it as it builds, my set up file currently looks like

ext_modules = cythonize("cyfile.pyx",
                        sources=['cfile.cpp'],
                        libraries=['stdc++'],
                        language="c++"
                        )

setup(
    name="cyModule",
    ext_modules=ext_modules,
    include_dirs=[numpy.get_include()]
)

And I'm wondering if I need to include the nm library, whatever that is...

Again, sorry for the spam, however you are my only hope at this stage, thank you

Robert Bradshaw

unread,
Oct 25, 2016, 2:54:54 AM10/25/16
to cython...@googlegroups.com
This looks like a C vs. C++ issue, but without aN example it's hard to
diagnose exactly what is off in your setup.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "cython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cython-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Samuel M Bennett

unread,
Oct 26, 2016, 12:56:42 AM10/26/16
to cython...@googlegroups.com
Yes I apologise for that, I'm currently working at braking a better example to show exactly what exactly is happening.

It would make sense that its c vs cpp. I've only been fumbling around so far and I've been defining functions in .cpp but only creating a .h header, which could be the cause.



> For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe@googlegroups.com.

CyclingNinja

unread,
Oct 26, 2016, 11:59:27 AM10/26/16
to cython-users
So I was being an idiot, I was missing the

# distutils: language = c++
# distutils: sources = RoadDensityPyMod.cpp

in the .pyx, your suggestion was enough to guide me into the right place.

Thanks to all of you who helped, this has been a gratifyingly steep learning curve
Reply all
Reply to author
Forward
0 new messages