Answer the question
In order to leave comments, you need to log in
How to combine C++ and Python with Cython?
Help build the module.
Here are the files used:
"HelloUser.h"
namespace hello {
class HelloUser {
public:
HelloUser();
~HelloUser();
int message();
};
}
#include "HelloUser.h"
#include <windows.h>
using namespace hello;
HelloUser::HelloUser() {
}
HelloUser::~HelloUser() {
}
int HelloUser::message() {
MessageBoxA(NULL, "Hello!", "Сообщение", MB_OK);
return 0;
cdef extern from "HelloUser.h" namespace "hello":
cdef cppclass HelloUser:
HelloUser() except +
void message()
cdef class PyHelloUser:
cdef HelloUser *thisptr
def __cinit__(self):
self.thisptr = new HelloUser()
def __dealloc__(self):
del self.thisptr
def message(self):
return self.thisptr.message()
C:\Расширения для Python на C++\Импорт классов из C++>python setup.py build_ext
--inplace
running build_ext
building 'hello_user' extension
C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /
GL /DNDEBUG /MD -IC:\Python36\include -IC:\Python36\include "-IC:\Program Files\
Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files\Windows Kits\10\inc
lude\10.0.10240.0\ucrt" "-IC:\Program Files\Windows Kits\8.1\include\shared" "-I
C:\Program Files\Windows Kits\8.1\include\um" "-IC:\Program Files\Windows Kits\8
.1\include\winrt" /EHsc /Tphello_user.cpp /Fobuild\temp.win32-3.6\Release\hello_
user.obj
hello_user.cpp
C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /
GL /DNDEBUG /MD -IC:\Python36\include -IC:\Python36\include "-IC:\Program Files\
Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files\Windows Kits\10\inc
lude\10.0.10240.0\ucrt" "-IC:\Program Files\Windows Kits\8.1\include\shared" "-I
C:\Program Files\Windows Kits\8.1\include\um" "-IC:\Program Files\Windows Kits\8
.1\include\winrt" /EHsc /TpHelloUser.cpp /Fobuild\temp.win32-3.6\Release\HelloUs
er.obj
HelloUser.cpp
C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\link.exe /nologo /INCREMENT
AL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Python36\libs
/LIBPATH:C:\Python36\PCbuild\win32 "/LIBPATH:C:\Program Files\Microsoft Visual S
tudio 14.0\VC\LIB" "/LIBPATH:C:\Program Files\Windows Kits\10\lib\10.0.10240.0\u
crt\x86" "/LIBPATH:C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86" /EXPORT
:PyInit_hello_user build\temp.win32-3.6\Release\hello_user.obj build\temp.win32-
3.6\Release\HelloUser.obj "/OUT:C:\Расширения для Python на C++\Импорт классов и
з C++\hello_user.cp36-win32.pyd" /IMPLIB:build\temp.win32-3.6\Release\hello_user
.cp36-win32.lib
Creating library build\temp.win32-3.6\Release\hello_user.cp36-win32.lib and o
bject build\temp.win32-3.6\Release\hello_user.cp36-win32.exp
HelloUser.obj : error LNK2001: unresolved external symbol [email protected]
C:\Расширения для Python на C++\Импорт классов из C++\hello_user.cp36-win32.pyd
: fatal error LNK1120: 1 unresolved externals
error: command 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC\\BIN\\link.e
xe' failed with exit status 1120
C:\Расширения для Python на C++\Импорт классов из C++>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question