gocv icon indicating copy to clipboard operation
gocv copied to clipboard

multiple definition

Open jinzhongmin opened this issue 1 year ago • 1 comments

c functions should be prefixed. I ran into a naming conflict with other libraries.

Description

D:\Program\Go\root\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1
D:/Program/Msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Program/Msys2/mingw64/bin/../lib/libgdi32.a(libgdi32s00803.o):(.text+0x0): multiple definition of `Rectangle'; C:\Users\JINZHO~1\AppData\Local\Temp\go-link-496729062\000031.o:F:\Code\iup\vendor\gocv.io\x\gocv/imgproc.cpp:404: first defined here
D:/Program/Msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Program/Msys2/mingw64/bin/../lib/libgdi32.a(libgdi32s00396.o):(.text+0x0): multiple definition of `Ellipse'; C:\Users\JINZHO~1\AppData\Local\Temp\go-link-496729062\000031.o:F:\Code\iup\vendor\gocv.io\x\gocv/imgproc.cpp:379: first defined here
collect2.exe: error: ld returned 1 exit status

Steps to Reproduce

  1. link libgdi32.a

Your Environment

  • Operating System and version: windows 10
  • OpenCV version used: 4.6.0
  • How did you install OpenCV? yes , msys2 opencv 4.6.0 pkg-config
  • GoCV version used: v0.31.0
  • Go version: go version go1.18.1 windows/amd64
  • Did you run the env.sh or env.cmd script before trying to go run or go build? yes

jinzhongmin avatar Oct 27 '22 09:10 jinzhongmin

I'd submit a PR but this really needs to be done properly and prefixing all C function names.

This can be fixed by changing the following code:

imgproc.cpp line 446, rename "Rectangle" to "cvRectangle", same for Ellipse or other conflicting symbols above:

void cvRectangle(Mat img, Rect r, Scalar color, int thickness) {

imgproc.h line 93, same thing rename "Rectangle" to "cvRectangle", and also do same for Ellipse:

void cvRectangle(Mat img, Rect rect, Scalar color, int thickness);

imgproc.go line 1383, rename "C.Rectangle()" function calls to "C.cvRectangle()", same for Ellipse:

C.cvRectangle(img.p, cRect, sColor, C.int(thickness))

At some point I'll try to submit a PR to prefix every function but it's going to be a lot of work :(

tenten8401 avatar Apr 24 '24 19:04 tenten8401