Go Down

Topic: Statically linking C++ programs in Linino (Read 2649 times) previous topic - next topic

noblepepper

I have bossac working in Linino, but I can not figure out how to statically link so I had to put libstdc++.so.6 on the Yun which takes up over 1  meg and this seems like a horrible waste of space.

Can someone give me some hints on how to statically link C++ programs in the openWrt environment, or at least reduce the size of libstdc++.so.6?


PeterVH

Long time ago I had to do the same thing, on a much different platform. There may be more sophisticated solutions, but I simply renamed the libstdc++.so* files, such that the linker does not find them. The linker will fallback to linking statically against the corresponding .a files. Other libs will still be linked dynamically,   

Are you sure this still is relevant? I have no Yun so I don't know whether all packages you install ends up in the flash or on the micro sd card. If you can put it on the micro sd, I would just use libstdc++.so. On the other hand, I built linino and searched for elf images needing libstdc++, there are indeed only a few that do.

noblepepper

Thanks for the advice. It worked like a charm.

My first thought -that's going to throw errors all over the place, second thought -  it's worth a try, third thought - WOW that was easy!

GreyCon

Hi,
  can you tell me what toolchain you use to compile for Linino?

Cheers,
Con

noblepepper

Just saw this, if you haven't found it yet there is a thread about compiling linino http://forum.arduino.cc//index.php?topic=187938.0 

Federico reports the "official" build is done with Ubuntu 12.04, jjdive and lock talk about arch linux and gentoo which are a bit less mainstream than ubuntu. I use ubuntu 13.04.

I have seen at least one snide comment about trying to do this on windows in the OpenWrt world which obviously Linino is very similar to so don't expect much help from that community if you are working in windows. I believe it can be done on Unix like apple systems.

Expect frustration, the problems seem to change from day to day because OpenWrt (thus linino) downloads sources every time and works from there, if something upstream changes your build can get clobbered.

Cheers

fibasile

I guess you can do it by passing the -static flag to configure. If it doesn't support the flag, you can also pass it along:

./configure LDFLAGS=-static

If you don't use configure you can do by adding an LDFLAGS variable to your build script or makefile, i.e.
CC=xxx
..etc..
LDFLAGS=-static

noblepepper

#6
Oct 17, 2013, 01:13 pm Last Edit: Oct 17, 2013, 01:15 pm by noblepepper Reason: 1
The bossac source I worked from uses a make file not configure. I did try some LDFLAGS but don't remember exactly which ones. I'll try the LDFLAGS=-static early next week when my dev box and the Yun are within arm's reach.

Go Up