karalabe / xgo

Go CGO cross compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

provide additional header files

nrobert13 opened this issue · comments

I'm trying to compile a program which requires systemd's headers. like this:

GOPATH=/home/src xgo -x -v -image xgo-latest-sd ./

The Dockerfile of xgo-latest-sd looks like this, to add the required headers.

FROM karalabe/xgo-latest

RUN apt-get update && \
    apt-get install -y libsystemd-dev

the header is installed under:

# docker run --rm -it --entrypoint /usr/bin/find xgo-latest-sd -- /usr/ -name sd-journal.h
/usr/include/systemd/sd-journal.h

but as far as I can tell cgo doesn't find it due to -I $WORK/b206/

CGO_LDFLAGS='"-fPIE"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b206/ -importpath github.com/coreos/go-systemd/sdjournal -- -I $WORK/b206/ -fPIE ./journal.go
# github.com/coreos/go-systemd/sdjournal
/go/pkg/mod/github.com/coreos/go-systemd@v0.0.0-20191104093116-d3cd4ed1dbcf/sdjournal/journal.go:27:33: fatal error: systemd/sd-journal.h: No such file or directory
 // #include <systemd/sd-journal.h>
                                 ^
compilation terminated.

is there a way to get this compiled with xgo?

thanks in advance.

got it working for specific target like

GOPATH=/home/src xgo  -image xgo-latest-sd  -targets linux/arm-7 ./