scard icon indicating copy to clipboard operation
scard copied to clipboard

Cannot compile for Linux

Open dacalin opened this issue 2 years ago • 5 comments

It works well for windows and mac. But when I try to compile for Linux using this command: GOOS=linux GOARCH=arm64 go build -o ../bin/card-reader-driver-amd64-linux

I get:

github.com/ebfe/scard

../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:35:12: undefined: scardEstablishContext ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:45:7: undefined: scardIsValidContext ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:58:7: undefined: scardCancel ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:67:7: undefined: scardReleaseContext ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:76:15: undefined: scardListReaders ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:81:14: undefined: strbuf ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:271:11: undefined: strbuf ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:275:11: undefined: strbuf ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:291:37: undefined: strbuf ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:304:21: undefined: strbuf ../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:81:14: too many errors

Any idea?

I tried to compile it from mac and linux machines.

dacalin avatar Jul 17 '24 09:07 dacalin

same here

jensen0915 avatar Oct 16 '24 10:10 jensen0915

Unfortunately I have the same problem. I'm using MacOS as my day to day OS.

dimarzio avatar Nov 21 '24 13:11 dimarzio

Native linux and macos build are working here. I suspect the issue is related to cross-compilation, the error suggest something off with the build tags. Independent of that I'm unsure if cross-compilation works with pkg-config (which is used on linux and mac to find the native libpcsc and headers).

ebfe avatar Nov 21 '24 14:11 ebfe

same here, can't build on mac

liron-navon avatar Mar 24 '25 16:03 liron-navon

Hi, thats a issue with cross compiling, you can try to link the needed libraries but the easiest option is to run a vm and compile it there. I used docker buildx for that and then in the docker install the needed libraries, this is what i needed to install for my case.

FROM golang:1.23-bullseye AS builder

RUN apt-get update && apt-get install -y
libpcsclite-dev
libpcsclite1
pcscd && apt-get -y upgrade

I hope it helps, sorry for my bad english is not my first language and I prefer not to use AI to write my messages :)

pedrofmu avatar May 09 '25 17:05 pedrofmu