I understand robotgo is built for Linux and Mac OS, but I think FreeBSD should be fairly similar.
I believe have all the necessary libraries, but they’re located at /usr/local/include instead of /usr/include. By that, I mean that I have grepped the headers located in /usr/local/include for a few of the symbols the compiler was complaining about and found them there.
When attempting to build the simple mouse example on my system, I end up getting unknown symbols such as:
ld: error: undefined symbol: XCloseDisplay
>>> referenced by xdisplay_c.h:13 (/home/w/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/../base/xdisplay_c.h:13)
>>> /tmp/go-link-2600121927/000002.o:(XCloseMainDisplay)
>>> referenced by xdisplay_c.h:13 (/home/w/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/../base/xdisplay_c.h:13)
>>> /tmp/go-link-2600121927/000002.o:(XGetMainDisplay)
>>> referenced by screen_c.h:48 (/home/w/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/screen_c.h:48)
>>> /tmp/go-link-2600121927/000002.o:(sys_scale)
>>> referenced 28 more times
I tried exporting variables to see if that might help, but no change:
The error seems to be the loader complaining it couldn’t find an external function in some object library rather than the compiler complaining it couldn’t find an import for that function in some header file.
Maybe the object files are under /usr/local/lib? So you’d want CGO_LDFLAGS=-L/usr/local/lib?
I started with a new terminal just to clear out my env:
export CGO_LDFLAGS=-L/usr/local/lib
build [mouse] (go)
Building mouse
# github.com/go-vgo/robotgo
error: unable to rename temporary '/tmp/go-build4173788811/b002//_cgo_-5eddc94d.o.tmp' to output file '/tmp/go-build4173788811/b002//_cgo_.o': 'No such file or directory'
1 error generated.
# github.com/go-vgo/robotgo
In file included from /home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/robotgo.go:48:
In file included from /home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/goWindow.h:12:
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:242:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:266:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:281:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
Strange, I reran the command again and ended up back where I was. I checked the env and the variable was still there.
EDIT: here is the 2nd run:
build [mouse] (go)
Building mouse
# github.com/go-vgo/robotgo
In file included from /home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/robotgo.go:48:
In file included from /home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/goWindow.h:12:
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:242:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:266:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:281:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
# robotgo/mouse
/usr/local/go123/pkg/tool/freebsd_amd64/link: running cc failed: exit status 1
/usr/bin/cc -m64 -o $WORK/b001/exe/a.out -Wl,--export-dynamic-symbol=__progname -Wl,--export-dynamic-symbol=_cgo_panic -Wl,--export-dynamic-symbol=_cgo_topofstack -Wl,--export-dynamic-symbol=crosscall2 -Wl,--export-dynamic-symbol=environ -Qunused-arguments -Wl,--compress-debug-sections=zlib /tmp/go-link-3870144045/go.o /tmp/go-link-3870144045/000000.o /tmp/go-link-3870144045/000001.o /tmp/go-link-3870144045/000002.o /tmp/go-link-3870144045/000003.o /tmp/go-link-3870144045/000004.o /tmp/go-link-3870144045/000005.o /tmp/go-link-3870144045/000006.o /tmp/go-link-3870144045/000007.o /tmp/go-link-3870144045/000008.o /tmp/go-link-3870144045/000009.o /tmp/go-link-3870144045/000010.o /tmp/go-link-3870144045/000011.o /tmp/go-link-3870144045/000012.o /tmp/go-link-3870144045/000013.o /tmp/go-link-3870144045/000014.o /tmp/go-link-3870144045/000015.o /tmp/go-link-3870144045/000016.o /tmp/go-link-3870144045/000017.o /tmp/go-link-3870144045/000018.o /tmp/go-link-3870144045/000019.o /tmp/go-link-3870144045/000020.o /tmp/go-link-3870144045/000021.o /tmp/go-link-3870144045/000022.o /tmp/go-link-3870144045/000023.o /tmp/go-link-3870144045/000024.o /tmp/go-link-3870144045/000025.o /tmp/go-link-3870144045/000026.o -L/usr/local/lib -L/usr/local/lib -lpthread -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -no-pie
ld: error: undefined symbol: XCloseDisplay
>>> referenced by xdisplay_c.h:13 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/../base/xdisplay_c.h:13)
>>> /tmp/go-link-3870144045/000002.o:(XCloseMainDisplay)
>>> referenced by xdisplay_c.h:13 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/../base/xdisplay_c.h:13)
>>> /tmp/go-link-3870144045/000002.o:(XGetMainDisplay)
>>> referenced by screen_c.h:48 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/screen_c.h:48)
>>> /tmp/go-link-3870144045/000002.o:(sys_scale)
>>> referenced 28 more times
ld: error: undefined symbol: XOpenDisplay
>>> referenced by xdisplay_c.h:27 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/../base/xdisplay_c.h:27)
>>> /tmp/go-link-3870144045/000002.o:(XGetMainDisplay)
>>> referenced by xdisplay_c.h:31 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/../base/xdisplay_c.h:31)
>>> /tmp/go-link-3870144045/000002.o:(XGetMainDisplay)
>>> referenced by xdisplay_c.h:36 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/../base/xdisplay_c.h:36)
>>> /tmp/go-link-3870144045/000002.o:(XGetMainDisplay)
>>> referenced 25 more times
ld: error: undefined symbol: XResourceManagerString
>>> referenced by screen_c.h:32 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/screen_c.h:32)
>>> /tmp/go-link-3870144045/000002.o:(sys_scale)
ld: error: undefined symbol: XrmGetStringDatabase
>>> referenced by screen_c.h:34 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/screen_c.h:34)
>>> /tmp/go-link-3870144045/000002.o:(sys_scale)
ld: error: undefined symbol: XrmGetResource
>>> referenced by screen_c.h:39 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/screen_c.h:39)
>>> /tmp/go-link-3870144045/000002.o:(sys_scale)
ld: error: undefined symbol: XrmDestroyDatabase
>>> referenced by screen_c.h:45 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/screen_c.h:45)
>>> /tmp/go-link-3870144045/000002.o:(sys_scale)
ld: error: undefined symbol: XDefaultRootWindow
>>> referenced by screengrab_c.h:114 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/screengrab_c.h:114)
>>> /tmp/go-link-3870144045/000002.o:(copyMMBitmapFromDisplayInRect)
>>> referenced by mouse_c.h:132 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:132)
>>> /tmp/go-link-3870144045/000002.o:(location)
>>> referenced by mouse_c.h:132 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:132)
>>> /tmp/go-link-3870144045/000002.o:(smoothlyMoveMouse)
>>> referenced 2 more times
ld: error: undefined symbol: XGetImage
>>> referenced by screengrab_c.h:114 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/screen/screengrab_c.h:114)
>>> /tmp/go-link-3870144045/000002.o:(copyMMBitmapFromDisplayInRect)
ld: error: undefined symbol: XWarpPointer
>>> referenced by mouse_c.h:95 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:95)
>>> /tmp/go-link-3870144045/000002.o:(moveMouse)
>>> referenced by mouse_c.h:95 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:95)
>>> /tmp/go-link-3870144045/000002.o:(dragMouse)
>>> referenced by mouse_c.h:95 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:95)
>>> /tmp/go-link-3870144045/000002.o:(smoothlyMoveMouse)
>>> referenced 2 more times
ld: error: undefined symbol: XSync
>>> referenced by mouse_c.h:97 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:97)
>>> /tmp/go-link-3870144045/000002.o:(moveMouse)
>>> referenced by mouse_c.h:97 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:97)
>>> /tmp/go-link-3870144045/000002.o:(dragMouse)
>>> referenced by mouse_c.h:155 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:155)
>>> /tmp/go-link-3870144045/000002.o:(toggleMouse)
>>> referenced 33 more times
ld: error: undefined symbol: XQueryPointer
>>> referenced by mouse_c.h:132 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:132)
>>> /tmp/go-link-3870144045/000002.o:(location)
>>> referenced by mouse_c.h:132 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:132)
>>> /tmp/go-link-3870144045/000002.o:(smoothlyMoveMouse)
>>> referenced by mouse_c.h:132 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:132)
>>> /tmp/go-link-3870144045/000002.o:(_cgo_dd183ab93a93_Cfunc_location)
ld: error: undefined symbol: XTestFakeButtonEvent
>>> referenced by mouse_c.h:154 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:154)
>>> /tmp/go-link-3870144045/000002.o:(toggleMouse)
>>> referenced by mouse_c.h:154 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:154)
>>> /tmp/go-link-3870144045/000002.o:(clickMouse)
>>> referenced by mouse_c.h:154 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:154)
>>> /tmp/go-link-3870144045/000002.o:(clickMouse)
>>> referenced 11 more times
ld: error: undefined symbol: floor
>>> referenced by mouse_c.h:296 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:296)
>>> /tmp/go-link-3870144045/000002.o:(smoothlyMoveMouse)
>>> referenced by mouse_c.h:296 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/mouse/mouse_c.h:296)
>>> /tmp/go-link-3870144045/000002.o:(smoothlyMoveMouse)
ld: error: undefined symbol: XSetErrorHandler
>>> referenced by pub.h:118 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:118)
>>> /tmp/go-link-3870144045/000002.o:(XDismissErrors)
>>> referenced by pub.h:123 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:123)
>>> /tmp/go-link-3870144045/000002.o:(XDismissErrors)
>>> referenced by pub.h:118 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:118)
>>> /tmp/go-link-3870144045/000002.o:(is_valid)
>>> referenced 23 more times
ld: error: undefined symbol: XInternAtom
>>> referenced by pub.h:156 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:156)
>>> /tmp/go-link-3870144045/000002.o:(initWindow)
>>> referenced by pub.h:157 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:157)
>>> /tmp/go-link-3870144045/000002.o:(initWindow)
>>> referenced by pub.h:158 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:158)
>>> /tmp/go-link-3870144045/000002.o:(initWindow)
>>> referenced 10 more times
ld: error: undefined symbol: XFree
>>> referenced by window.h:113 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:113)
>>> /tmp/go-link-3870144045/000002.o:(is_valid)
>>> referenced by window.h:409 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:409)
>>> /tmp/go-link-3870144045/000002.o:(get_active)
>>> referenced by pub.h:202 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:202)
>>> /tmp/go-link-3870144045/000002.o:(GetWindowProperty)
>>> referenced 7 more times
ld: error: undefined symbol: XGetInputFocus
>>> referenced by window.h:422 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:422)
>>> /tmp/go-link-3870144045/000002.o:(get_active)
ld: error: undefined symbol: XGetWindowProperty
>>> referenced by pub.h:186 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:186)
>>> /tmp/go-link-3870144045/000002.o:(GetWindowProperty)
ld: error: undefined symbol: XGetWindowAttributes
>>> referenced by pub.h:225 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/pub.h:225)
>>> /tmp/go-link-3870144045/000002.o:(set_active)
>>> referenced by window.h:317 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:317)
>>> /tmp/go-link-3870144045/000002.o:(set_active)
>>> referenced by win_sys.h:113 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/win_sys.h:113)
>>> /tmp/go-link-3870144045/000002.o:(get_client)
ld: error: undefined symbol: XStringToKeysym
>>> referenced by keycode_c.h:65 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/key/keycode_c.h:65)
>>> /tmp/go-link-3870144045/000001.o:(keyCodeForChar)
>>> referenced by keycode_c.h:65 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/key/keycode_c.h:65)
>>> /tmp/go-link-3870144045/000001.o:(toggleKey)
>>> referenced by keypress_c.h:331 (/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/key/keypress_c.h:331)
>>> /tmp/go-link-3870144045/000001.o:(input_utf)
>>> referenced 1 more times
ld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
# github.com/go-vgo/robotgo
In file included from /home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/robotgo.go:48:
In file included from /home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/goWindow.h:12:
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:242:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:266:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
/home/user/go/pkg/mod/github.com/go-vgo/robotgo@v0.110.6/window/window.h:281:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
I have my own wrapper utility (build) which automatically runs the appropriate go cmds, in this case, go install -a -race -ldflags (and then passes a bunch that the utility determines from the repository, current dir, etc.).
EDIT:
The first part looks like it was either a permission error, or my build script cleaning up a bit too early (more likely). The build script has callbacks that run at the end to remove temporary files. Why the first run appeared to work better and the second not is strange.
EDIT:
Rerunning in a new terminal window with the variable set doesn’t get me back to the best output yet, so it seems I’m back to square 1.
Well, the second run does include “-L/usr/local/lib” (at the end of the long /usr/bin/cc command line) so you succeeded in changing where it’s looking. But it’s still not finding!
I took a look at the robotgo project and it seems others also have build problems; they seem to be using the project owner’s procedure involving go build (with lots of tweaks to environment and command line flags). Does your build tool boil down to that?
I don’t know enough about the deets of this project to be of further help. I see you’ve raised an issue on github, that should work. You might try adding a log with the full command lines that your build tool is generating, and an indication of where you found the actual X11 object files.