Problem with Cython, extern "C" and unresolved external symbol

195 views
Skip to first unread message

Walter White

unread,
Feb 5, 2016, 8:40:59 AM2/5/16
to cython...@googlegroups.com
Hello,

thanks Robert for answering my previous questions on the public stuct.
Now this works fine, but there are other problems now.
#pyximport uses parameter language='c++'

I have a header.h file like

---
int Test1(int input); extern "C" { _declspec(dllexport) int Test1_C(int input) { return Test1(input); } }
--
The cython pyx code is like: cdef extern from "header.h": cdef int Test1(int input) cdef int Test1_C(int input) --
Now when I am trying to run my Python code I get the
following error message: error LNK2019: unresolved external symbol "int __cdecl Test1(int)" (?Test1@@YAHH@Z) referenced in function Test1_C


These are things that might cause the problem but I could not solve it:
I am not sure if this related to what is mentioned here:
http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html#access-to-c-only-functions
Is it?

The cpp-file states "using namespace std".
Does this mean I have to use
cdef extern from "header.h" namespace "std" ?

I am using pyximport with the following pyxbld file:

---
def make_ext(modname, pyxfilename):
    return Extension(name=modname,

    sources=[pyxfilename],

    include_dirs = include_dirs,

    library_dirs = library_dirs,

    language='c++')

---

Any help is very much appreciated!

Joe


Reply all
Reply to author
Forward
0 new messages