GithubHelp home page GithubHelp logo

Comments (2)

ericchiang avatar ericchiang commented on May 30, 2024

Several of the OSes that don't use pkg-config directly include the PCSC include (it looks like that'd be "/usr/include/PCSC" on your system). You may need to try that

https://github.com/go-piv/piv-go/blob/master/piv/pcsc_unix.go

// #cgo darwin LDFLAGS: -framework PCSC
// #cgo linux pkg-config: libpcsclite
// #cgo freebsd CFLAGS: -I/usr/local/include/
// #cgo freebsd CFLAGS: -I/usr/local/include/PCSC
// #cgo freebsd LDFLAGS: -L/usr/local/lib/
// #cgo freebsd LDFLAGS: -lpcsclite
// #cgo openbsd CFLAGS: -I/usr/local/include/
// #cgo openbsd CFLAGS: -I/usr/local/include/PCSC
// #cgo openbsd LDFLAGS: -L/usr/local/lib/
// #cgo openbsd LDFLAGS: -lpcsclite
// #include <PCSC/winscard.h>
// #include <PCSC/wintypes.h>

See StackOverflow for an explanation of the error: https://stackoverflow.com/a/17466697/2325264

Going to close out for now since cross-compiling CGO is messy (godspeed!) and something I don't think this package want to support directly.

from piv-go.

circa10a avatar circa10a commented on May 30, 2024

For those who later find this issue, I was able to resolve using goxx and osxcross which is done via docker. Here's the dockerfile

# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM crazymax/osxcross AS osxcross

FROM --platform=$BUILDPLATFORM crazymax/goxx AS build
ENV CGO_ENABLED=1 
WORKDIR /go/src/app
ARG TARGETPLATFORM
ARG BINARY_NAME
ARG VERSION
RUN goxx-apt-get update && \
    goxx-apt-get install -y binutils gcc pkg-config libpcsclite-dev
RUN --mount=type=bind,source=. \
  --mount=from=osxcross,target=/osxcross,src=/osxcross,rw \
  goxx-go env && goxx-go build -v -o /out/$BINARY_NAME -ldflags="-X main.Version=$VERSION" .

FROM scratch AS artifact
COPY --from=build /out/$BINARY_NAME /

FROM scratch
COPY --from=build /out/$BINARY_NAME /
ENTRYPOINT [ "/$BINARY_NAME" ]

Then the docker build command:

docker buildx build --platform "darwin/amd64" --build-arg=VERSION=$VERSION --build-arg=BINARY_NAME=$BINARY_NAME --target "artifact" --output "./dist" .

I've had issues doing the same for darwin/arm64 as M1 Macs report damaged binaries and I couldn't find a way around it, however the x64 bit version worked fine thanks to Rosetta.

from piv-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.