6

If I want to run any code with robotgo under windows 10 I get following error:

# github.com/go-vgo/robotgo
In file included from ./bitmap/../base/str_io_c.h:2:0,
                 from ./bitmap/goBitmap.h:17,
                 from ..\go\src\github.com\go-vgo\robotgo\robotgo.go:45:
./bitmap/../base/zlib_util_c.h:2:18: fatal error: zlib.h: No such file or directory
compilation terminated.

my PATH variables:

https://i.stack.imgur.com/FTXBB.png

Followed the installation and looked through the issues.

https://github.com/go-vgo/robotgo#installation

Someone had a similar error here: https://github.com/go-vgo/robotgo/issues/100

But their fix "Solved, should change gcc compiler in the %PATH%" did not work for me.

import (
    "github.com/go-vgo/robotgo"
)

func main() {
    robotgo.ScrollMouse(10, "up")
    robotgo.MouseClick("left", true)
    robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
}
Julia Schwarz
  • 61
  • 1
  • 3

2 Answers2

2

I try this one below and worked for me
https://github.com/lowkey42/MagnumOpus/wiki/TDM-GCC-Mingw64-Installation#zlib-x64

download ZLIB x64 from this link

copy _\zlib\bin to \TDM\bin
copy _\zlib\bin to \Git\bin
copy \zlib\include to \TDM\include
copy \zlib\lib to \TDM\lib

panapol-p
  • 535
  • 4
  • 8
  • this fixed the problem for me once i found zlib-1.2.5-bin-x64.zip and copied zlib.h to my mingw64 directory – lm5050 Aug 27 '22 at 03:13
1

Solution 1: ignore bitmap.go

Your code doesn't use bitmap so you don't need to compile this file, and then you will not encounter this error.

put //go:build ignore to bitmap.go

//go:build ignore     // 

// ...
//#include "screen/goScreen.h"
#include "bitmap/goBitmap.h"
*/
import "C"

import (
    "unsafe"

    "github.com/vcaesar/tt"
)
// ...

Solution2: install MinGW-W64.{gcc, g++}

go to sourceforge to download MinGW-W64 GCC

Select what you want

  • version:{..., 8.1.0, 7.3.0, 6.4.0, 5.4.0, ...}
  • arch. : x86_64, i686similarly x86
  • threads: posix, win32
  • exception: sjlj, dwarf, seh

download MinGW-W64

I select x86_64-win32-seh8.1.0

and then

  1. unzip the file.

  2. copy the path: for example C:\downloads\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\mingw64\bin (which contains: gcc.exe, g++.exe)

  3. set go env: CC, CXX

    • go env -w CC=C:\downloads\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\mingw64\bin\gcc
    • go env -w CXX=C:\downloads\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\mingw64\bin\g++

Finally, try to go build again. It should work.


Carson
  • 6,105
  • 2
  • 37
  • 45