Cross compile Topbeat for Windows on Linux

Hi,
I want to compile topbeat for Windows on my Linux desktop.

I have the following installed:

Now, when try to cross compile Topbeat for Windows, I get the following output and NO .exe

~/beats-dev/src/github.com/elastic/beats-packer$ make topbeat/win

cross compile on ubuntu

cd build && xgo -image=tudorg/beats-builder
-before-build=../xgo-scripts/topbeat_before_build.sh
-branch master
-pkg topbeat


Checking docker installation...
Client:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 21:47:50 2016
OS/Arch: linux/amd64

Server:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 21:47:50 2016
OS/Arch: linux/amd64

Checking for required docker image tudorg/beats-builder... found.
Cross compiling github.com/elastic/beats...
Running docker [run -v /home/arun/beats-dev/src/github.com/elastic/beats-packer/build:/build -v /home/arun/beats-dev/src/github.com/elastic/beats-packer/build/138026786:/scripts -e REPO_REMOTE= -e REPO_BRANCH=master -e PACK=topbeat -e DEPS= -e OUT= -e FLAG_V=false -e FLAG_RACE=false -e BEFORE_BUILD=topbeat_before_build.sh tudorg/beats-builder github.com/elastic/beats]
Fetching main repository github.com/elastic/beats...
Cloning into 'beats'...
Switching over to branch master...
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Fetching dependencies...
Execute /scripts/topbeat_before_build.sh
make: *** No rule to make target `install-cfg'. Stop.
2016/06/17 13:06:03 Failed to cross compile package: exit status 2.
make: *** [topbeat] Error 1

Am I doing something grossly wrong?

Also, how do I tell beats-packer to pick code from a local directory than cloning from github repo?

Regards,
Arun

Beats-packer is now part of the beats repository. You can find it here: https://github.com/elastic/beats/tree/master/dev-tools/packer Please try again with this one.

But there is no rule in there to build topbeat.

make topbeat
make: *** No rule to make target `topbeat'. Stop.

@arunachala Are you working on master? If yes, be aware that Topbeat was removed in alpha3 and all future development should happen in Metricbeat system module: https://www.elastic.co/blog/beats-5-0-0-alpha3-released

@ruflin Thanks. I have moved back to 1.3 branch where topbeat was still separate project.

There also, I am getting the following error when I try to cross compile topbeat for Windows.

~/beats-dev/1.3/src/github.com/elastic/beats/topbeat$ GOOS=windows GOARCH=amd64 go build

github.com/elastic/beats/vendor/github.com/elastic/gosigar

../vendor/github.com/elastic/gosigar/concrete_sigar.go:20: cpuUsage.Get undefined (type Cpu has no field or method Get)
../vendor/github.com/elastic/gosigar/concrete_sigar.go:30: cpuUsage.Get undefined (type Cpu has no field or method Get)
../vendor/github.com/elastic/gosigar/concrete_sigar.go:49: l.Get undefined (type LoadAverage has no field or method Get)
../vendor/github.com/elastic/gosigar/concrete_sigar.go:55: m.Get undefined (type Mem has no field or method Get)
../vendor/github.com/elastic/gosigar/concrete_sigar.go:61: s.Get undefined (type Swap has no field or method Get)
../vendor/github.com/elastic/gosigar/concrete_sigar.go:67: f.Get undefined (type FileSystemUsage has no field or method Get)

Is it even possible to cross compile topbeat on Linux?

-Arun

In your first post, when you tried to use the elastic/beats-packer project to compile the elastic/beats project you were targeting the master branch. You should probably target the 1.3 branch because we no longer use the separate elastic/beats-packer project to build against master. Change master to 1.3 here.

It is possible to cross-compile for Windows on Linux. That's what the beat-packer project does. It just encapsulates all of the compiler dependencies into a docker container.

@andrewkroh Thanks. Now I am able to compile topbeat for Windows on Linux.

It seems beats-packer clones this 1.3 branch every time it needs to build. Is there a way to make beats-packer to build a local directory instead of cloning every time?

Basically, I have cloned branch 1.3 and have some local changes on top. I need to compile this local copy of code rather the freshly cloned from git.

-Arun

You'll have to hack it to make it do that.

We migrated beats-packer into the main beats repo and it now does what you describe, build and package the local source.

This topic was automatically closed after 21 days. New replies are no longer allowed.