Skip to content

Instantly share code, notes, and snippets.

$ make clean all TARGET_OS=android ARCH=arm CROSS_PREFIX=arm-linux-androideabi CROSS_HOME=/usr/local/gcc-4.8.0-arm-linux-androideabi
rm -rf build/android_arm build/android_arm/obj/libtorrent_wrap.o build/android_arm/obj/libtorrent_wrap.cxx libtorrent_gc.c libtorrent.go *.so
mkdir -p build/android_arm
mkdir -p build/android_arm/obj
mkdir -p build/android_arm/bin
swig -go -c++ -soname libtorrent-go.so -intgosize 32 -I/usr/local/gcc-4.8.0-arm-linux-androideabi/include -I/usr/local/gcc-4.8.0-arm-linux-androideabi/arm-linux-androideabi/include -DTORRENT_USE_OPENSSL -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -I/usr/local/gcc-4.8.0-arm-linux-androideabi
sed -i '' 's/} \*swig_a/} __attribute__((__packed__)) \*swig_a/g' build/android_arm/obj/libtorrent_wrap.cxx
sed -i '' 's/} a/} __attribute__((__packed__)) a/g' build/android_arm/obj/libtorrent_wrap.cxx
fatal error: runtime: stack split during syscall
runtime stack:
runtime.throw(0x6a8934)
/usr/local/go/src/pkg/runtime/panic.c:464 +0x5c
runtime.newstack()
/usr/local/go/src/pkg/runtime/stack.c:261 +0x5bc
runtime.morestack()
/usr/local/go/src/pkg/runtime/asm_arm.s:212 +0x44
$ arm-linux-androideabi-g++ test.cpp -ltorrent-rasterbar -L/usr/local/gcc-4.8.0-arm-linux-androideabi/lib -I/usr/local/gcc-4.8.0-arm-linux-androideabi/include -DTORRENT_USE_OPENSSL -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED
#include <windows.h>
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
void (*crosscall2)(void (*fn)(void *, int), void *, int);
void (*_cgo_allocate)(void *, int);
void (*_cgo_panic)(void *, int);
#ifdef __cplusplus
@steeve
steeve / overclock.sh
Last active December 26, 2015 03:39
OpenELEC resize to SD card
cd /
touch /var/lock/xbmc.disabled
killall -9 xbmc.bin
fuser -m /storage | xargs kill -9; umount /storage
parted /dev/mmcblk0
unit s
rm 2
mkpart primary 258048 -1
quit
e2fsck -f /dev/mmcblk0p2 && resize2fs /dev/mmcblk0p2 && mount /dev/mmcblk0p2 /storage
@steeve
steeve / config.txt
Last active December 26, 2015 03:38
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2012 Stephan Raue ([email protected])
# Inspired and partly copied from:
# http://youresuchageek.blogspot.fr/2012/09/howto-raspberry-pi-openelec-on.html
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
@steeve
steeve / _readme.md
Last active March 25, 2025 07:32
How to cross compile Go with CGO programs for a different OS/Arch

How to cross compile Go with CGO programs for a different OS/Arch

It is possible to compile Go programs for a different OS, even though go build says otherwise.

You'll need:

void
_wrap_add_torrent_params_name_get(void *swig_v)
{
libtorrent::add_torrent_params *arg1 = (libtorrent::add_torrent_params *) 0 ;
std::string *result = 0 ;
struct swigargs {
libtorrent::add_torrent_params *arg1;
long : 0;
_gostring_ result;
@steeve
steeve / test-int64.go
Created October 7, 2013 18:13
When run on Windows/386, outputs values like "4603183328" instead of "1".
package main
// #include <stdio.h>
// #include <stdint.h>
// int64_t get(int n)
// {
// return 1;
// }
import "C"
diff -rupN swig-2.0.11/Doc/Manual/Go.html swig-2.0.11.tmp/Doc/Manual/Go.html
--- swig-2.0.11/Doc/Manual/Go.html 2013-09-15 23:06:10 +0200
+++ swig-2.0.11.tmp/Doc/Manual/Go.html 2013-09-25 09:42:11 +0200
@@ -139,6 +139,10 @@ swig -go -help
or <tt>int64</tt>. The &lt;s&gt; argument should be 32 or 64.</td>
</tr>
+<tr>
+<td>-windows</td>
+<td>Generate code for Windows.</td>