Ask Your Question
0

Failed to compile cv2.pyd with VS 2012

asked 2014-02-08 10:56:42 -0600

lesca gravatar image

Hello experts,

I am trying to compiling opencv on my computer but with no luck. Please help and find where is wrong!

My platform:

Windows 7 + VS2012 + Cmaker 2.8.11.2 + Python 2.7.6

I am getting following errors, but I am not sure what lib I am missing. Any help is welcome!

Error 2 error LNK2019: unresolved external symbol __imp___Py_NegativeRefcount referenced in function __catch$?pycvCalcEMD2@@YAPAU_object@@PAU1@00@Z$0 C:\opencv\build\modules\python\cv2.obj opencv_python
Error 3 error LNK2019: unresolved external symbol __imp___Py_Dealloc referenced in function __catch$?pycvCalcEMD2@@YAPAU_object@@PAU1@00@Z$0 C:\opencv\build\modules\python\cv2.obj opencv_python
Error 4 error LNK2019: unresolved external symbol __imp___PyObject_DebugMalloc referenced in function "struct _object * __cdecl pyopencv_CvRTrees_CvRTrees(struct _object *,struct _object *,struct _object *)" (?pyopencv_CvRTrees_CvRTrees@@YAPAU_object@@PAU1@00@Z) C:\opencv\build\modules\python\cv2.obj opencv_python
Error 5 error LNK2019: unresolved external symbol __imp___PyObject_DebugFree referenced in function "void __cdecl Capture_dealloc(struct _object *)" (?Capture_dealloc@@YAXPAU_object@@@Z) C:\opencv\build\modules\python\cv2.obj opencv_python
Error 6 error LNK2019: unresolved external symbol __imp__Py_InitModule4TraceRefs referenced in function "struct _object * __cdecl init_cv(void)" (?init_cv@@YAPAU_object@@XZ) C:\opencv\build\modules\python\cv2.obj opencv_python
Error 7 error LNK2001: unresolved external symbol __imp___Py_RefTotal C:\opencv\build\modules\python\cv2.obj opencv_python
Error 8 error LNK1120: 6 unresolved externals C:\opencv\build\lib\Debug\cv2.pyd opencv_python
edit retag flag offensive close merge delete

Comments

hi lesca, hope you don't mind i deleted your duplicate question, thanks

berak gravatar imageberak ( 2014-02-08 13:19:17 -0600 )edit

@berak That's all right. but there was an error when I submit my question. I guess that's why the duplicate appears.

lesca gravatar imagelesca ( 2014-02-10 01:57:05 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2014-02-08 13:21:31 -0600

berak gravatar image

unfortunately, since there is no debug version of the python.lib, you can only do a RELEASE build.

after that finished, run the INSTALL project in your sln. this will copy cv2.pyd to your site-package

edit flag offensive delete link more

Comments

That's right! It was successfully compiled with RELEASE build.

lesca gravatar imagelesca ( 2014-02-10 01:55:16 -0600 )edit
2

answered 2014-05-21 19:19:58 -0600

Mehrnoush gravatar image

I had this problem when I was trying to build 64-bit cv2.pyd with VS2010 and Python 2.7. Turned out I was linking against 32-bit python27.lib instead of the 64-bit. I changed the cmake settings and specified the path to the 64-bit python library in cmake GUI. Then the errors were resolved.

edit flag offensive delete link more

Comments

nice hint, too.

berak gravatar imageberak ( 2014-05-22 00:51:24 -0600 )edit

Question Tools

Stats

Asked: 2014-02-08 10:56:42 -0600

Seen: 1,404 times

Last updated: May 21 '14