www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linker error cross compiling for raspberry pi

reply Jackson Slater <sjjkb gmail.com> writes:
I am using ubuntu, trying to cross compile a d application for 
Raspberry pi.

I installed the "gdc-8-arm-linux-gnueabihf" package, but now when 
I try to compile, I get a linker error:

trying to cross-compile this:
---
import std.stdio;

void main()
{
   writeln("Hello, Pi!");
}
---

But when I compile (using the command `arm-linux-gnueabihf-gdc-8 
main.d`) I get this error:

---
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `deflateInit_'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `deflateInit2_'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `deflate'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `compress2'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `deflateEnd'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `crc32'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `inflate'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `inflateInit2_'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `inflateInit_'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `inflateEnd'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `inflateBackInit_'
/usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: undefined 
reference to `adler32'
collect2: error: ld returned 1 exit status
---

Can anyone help me fix this?
Thanks
May 13 2019
next sibling parent reply Doc Andrew <x x.com> writes:
On Monday, 13 May 2019 at 20:29:06 UTC, Jackson Slater wrote:
 I am using ubuntu, trying to cross compile a d application for 
 Raspberry pi.

 [...]
It looks like you're missing a dependency, probably zlib? You should be able to install the zlib-dev package to resolve this. -Doc
May 13 2019
parent reply Jackson Slater <gsjj28 gmail.com> writes:
On Monday, 13 May 2019 at 22:44:19 UTC, Doc Andrew wrote:
 On Monday, 13 May 2019 at 20:29:06 UTC, Jackson Slater wrote:
 I am using ubuntu, trying to cross compile a d application for 
 Raspberry pi.

 [...]
It looks like you're missing a dependency, probably zlib? You should be able to install the zlib-dev package to resolve this. -Doc
Hm, there is no zlib-dev package, but there is zlib1g-dev, which was already installed. Any other ideas? Thanks so much
May 13 2019
parent reply kinke <noone nowhere.com> writes:
On Monday, 13 May 2019 at 23:38:07 UTC, Jackson Slater wrote:
 but there is zlib1g-dev, which was already installed
For armhf, your desired target architecture?
May 13 2019
parent reply Jackson Slater <gsjj28 gmail.com> writes:
On Monday, 13 May 2019 at 23:42:37 UTC, kinke wrote:
 On Monday, 13 May 2019 at 23:38:07 UTC, Jackson Slater wrote:
 but there is zlib1g-dev, which was already installed
For armhf, your desired target architecture?
I don't think there is a prebuilt one for armhf. I am going to try cross compiling zlib.
May 13 2019
parent reply kinke <noone nowhere.com> writes:
On Monday, 13 May 2019 at 23:47:38 UTC, Jackson Slater wrote:
 I don't think there is a prebuilt one for armhf.
Something like this should work: sudo dpkg --add-architecture armhf sudo apt-get update sudo apt-get install zlib1g-dev:armhf
May 13 2019
parent Jackson Slater <gsjj28 gmail.com> writes:
On Monday, 13 May 2019 at 23:51:30 UTC, kinke wrote:
 On Monday, 13 May 2019 at 23:47:38 UTC, Jackson Slater wrote:
 I don't think there is a prebuilt one for armhf.
Something like this should work: sudo dpkg --add-architecture armhf sudo apt-get update sudo apt-get install zlib1g-dev:armhf
Hm, I am getting a bunch of 404 errors now when running 'apt update'.
May 13 2019
prev sibling parent Jackson Slater <gsjj28 gmail.com> writes:
On Monday, 13 May 2019 at 20:29:06 UTC, Jackson Slater wrote:
 I am using ubuntu, trying to cross compile a d application for 
 Raspberry pi.

 I installed the "gdc-8-arm-linux-gnueabihf" package, but now 
 when I try to compile, I get a linker error:

 trying to cross-compile this:
 ---
 import std.stdio;

 void main()
 {
   writeln("Hello, Pi!");
 }
 ---

 But when I compile (using the command 
 `arm-linux-gnueabihf-gdc-8 main.d`) I get this error:

 ---
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `deflateInit_'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `deflateInit2_'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `deflate'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `compress2'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `deflateEnd'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `crc32'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `inflate'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `inflateInit2_'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `inflateInit_'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `inflateEnd'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `inflateBackInit_'
 /usr/lib/gcc-cross/arm-linux-gnueabihf/8/libgphobos.so: 
 undefined reference to `adler32'
 collect2: error: ld returned 1 exit status
 ---

 Can anyone help me fix this?
 Thanks
Aha! It worked after following this https://github.com/pander86/raspberry_vibed
May 13 2019