How am I able to use CGo outside of the main package?
/*
#cgo LDFLAGS: -L./lib -lhi
#include “./libhi.h”
*/
import “C”
The header file is always recognized. If I move the file to another package, anything I do, it cannot be found:
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lhi
this is my makefile:
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
go build -ldflags="-r $(ROOT_DIR)lib" -v -o bot.exe -tags=jsoniter .
run: build
./main