# Cross compile Topbeat for Windows on Linux

**URL:** <https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102>\
**Category:** Beats\
**Created:** [June 17, 2016, 7:15am UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102 "2016-06-17T07:15:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![arunachala](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arunachala/32/126762_2.png) [@arunachala](https://discuss.elastic.co/u/arunachala)\
**Post date:** [June 17, 2016, 7:15am UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/1 "2016-06-17T07:15:14Z")

</div>

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

I have the following installed:

- docker
- go
- beats-packer (from [github.com/elastic/beats-packer](http://github.com/elastic/beats-packer))

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

> **[elastic/beats](https://github.com/elastic/beats)**
>
> beats - :tropical\_fish: Beats - Lightweight shippers for Elasticsearch & Logstash

  
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](http://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](http://github.com/elastic/beats)]  
Fetching main repository [github.com/elastic/beats](http://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

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [June 17, 2016, 10:21am UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/2 "2016-06-17T10:21:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![arunachala](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arunachala/32/126762_2.png) [@arunachala](https://discuss.elastic.co/u/arunachala)\
**Post date:** [June 17, 2016, 4:04pm UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/3 "2016-06-17T16:04:54Z")

</div>

But there is no rule in there to build topbeat.

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

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [June 20, 2016, 7:49am UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/4 "2016-06-20T07:49:35Z")

</div>

@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](https://www.elastic.co/blog/beats-5-0-0-alpha3-released)

---

<div class="post-metadata">

**Author:** ![arunachala](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arunachala/32/126762_2.png) [@arunachala](https://discuss.elastic.co/u/arunachala)\
**Post date:** [June 21, 2016, 6:20am UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/5 "2016-06-21T06:20:15Z")

</div>

@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](http://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

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [June 21, 2016, 12:20pm UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/6 "2016-06-21T12:20:46Z")

</div>

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](https://github.com/elastic/beats-packer/blob/master/Makefile#L2).

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.

---

<div class="post-metadata">

**Author:** ![arunachala](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arunachala/32/126762_2.png) [@arunachala](https://discuss.elastic.co/u/arunachala)\
**Post date:** [June 23, 2016, 8:42am UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/7 "2016-06-23T08:42:03Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [June 23, 2016, 4:32pm UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/8 "2016-06-23T16:32:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 8, 2016, 7:15am UTC](https://discuss.elastic.co/t/cross-compile-topbeat-for-windows-on-linux/53102/9 "2016-07-08T07:15:15Z")

</div>

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