I successfully compiled libnfc written in C under Windows. After compilation I get 3 files: libnfc.dll, libnfc.dll.a, libnfc.lib. I want to call functions of this library in my Go application. My test program
package main
/*
#cgo CFLAGS: -I .
#cgo LDFLAGS: -L . -lnfc
#include <nfc/nfc.h>
*/
import "C"
import "fmt"
func main() {
res:= C.nfc_version()
fmt.Printf(C.GoString(res))
}
nfc_version - name of function available in library. I put libnfc.lib file in directory with go source and also copy folder nfc with header files. (If I put libnfc.dll or libnfc.dll.a instead of libnfc.lib - I get error message library not found.) Then I run
go build
Go successfully compiled program, but when I try to start it I get error: "This application has failed to start because (null).DLL was not found." How to properly use library with golang application?