Compiling a PHP extension with OpenCV in Visual Studio 2017 [closed]

asked 2017-08-01 22:37:25 -0600

fifo_thekdi gravatar image

updated 2017-08-02 02:48:04 -0600

LBerger gravatar image

I've been successfully developing several PHP extensions for data processing both on Windows and Linux. In addition to that, I have many OpenCV projects on both operating systems fully working.

Recently I've been trying to create a PHP extension for PHP 7.2 using the official SDK on Windows. I could easily compile it with nmake and it loaded without any problem. Then I compiled an OCR library of my own that uses OpenCV 3.2 and linked it to an exe and it worked too.

The I try linking the dll of the extension to both the PHP SDK library file and the library I made using OpenCV, but no matter what I try I always get these errors only when I link both libs to the dll:

1>my_ocr_lib.lib(my_ocr_lib.obj) : error LNK2005: "public: void __cdecl std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QEAAXXZ) already defined in php_my_ocr.obj
1>my_ocr_lib.lib(my_ocr_lib.obj) : error LNK2005: "public: void __cdecl std::_Container_base12::_Swap_all(struct std::_Container_base12 &)" (?_Swap_all@_Container_base12@std@@QEAAXAEAU12@@Z) already defined in php_my_ocr.obj
1>my_ocr_lib.lib(my_ocr_lib.obj) : error LNK2005: "void * __cdecl std::_Allocate(unsigned __int64,unsigned __int64,bool)" (?_Allocate@std@@YAPEAX_K0_N@Z) already defined in php_my_ocr.obj
1>my_ocr_lib.lib(my_ocr_lib.obj) : error LNK2005: "void __cdecl std::_Deallocate(void *,unsigned __int64,unsigned __int64)" (?_Deallocate@std@@YAXPEAX_K1@Z) already defined in php_my_ocr.obj
1>   Creating library C:/cpp/my_ocr/build/Debug/php_my_ocr.lib and object C:/cpp/my_ocr/build/Debug/php_my_ocr.exp
1>C:\cpp\my_ocr\build\Debug\php_my_ocr.dll : fatal error LNK1169: one or more multiply defined symbols found /MDd flag

Any suggestions?

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by LBerger
close date 2017-08-02 02:55:35.170351

Comments

there is no problem with opencv. May be answer is in error message. you can try /FORCE:MULTIPLE

LBerger gravatar imageLBerger ( 2017-08-02 02:55:05 -0600 )edit

I tried that and I could compile it without errors But PHP could not load the extension saying that "module not found"

fifo_thekdi gravatar imagefifo_thekdi ( 2017-08-02 12:04:56 -0600 )edit