Welcome
Welcome to a320

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

Howto compile static binaries

Any and all A320 homebrew topics

Moderator: Moderators

Howto compile static binaries

Postby ainu on Wed Jun 17, 2009 7:54 am

I found next:
ezelkow1 wrote:There is usually a -static or --with-static type option in the configure script, as for the actual command you would have to build with I think you can just add -static, but its been a while so that may not be right

and
Code: Select all
./ configure --enable-static
make LDFLAGS=-static

Is it right?
Lets collect all ways in one place, for future?
What parameters you used while compiling programs?
And lets write short FAQ for compiling and making, for all root filesystems?
Ask you questions!
Let's go:

_______________________________________________________
Compiling and making FAQ:
_______________________________________________________
1. Q: Howto compile you own .c programs (using uclibc toolchain and uclibc root fs)?
A: Copy and unpack toolchain into your PC with Linux. Add /opt/dingoo-uclib-toolchain_dir/usr/bin to you $PATH.
Then go to folder with you own test.c file, and do next:
Code: Select all
mipsel-linux-gcc -o test test.c

or
Code: Select all
mipsel-linux-cc -o test test.c

Copy ready test file, and type ./test on you dingoo linux.
Dingoo Linux user & programmer from Russia
Sorry for my poor English
ainu
 
Posts: 35
Joined: Mon May 18, 2009 8:27 pm

Re: Howto compile static binaries

Postby ezelkow1 on Wed Jun 17, 2009 9:04 am

That can be right, usually before trying something i just run ./configure --help and look at the options, generally look for obvious ones like disabling X or opengl, things like that that are known to not be supported.

Ones that I always use though are --host=mipsel-linux and/or --target=mipsel-linux, some configure scripts have them swapped for their usage so it depends, and sometimes you need both of them. I also include --prefix=/path_to_toolchain, this helps it find some of the libraries if your paths arent properly setup. Keep in mind setting the path though will also change the effect of a make install, and it will install it into your toolchain.
ezelkow1
 
Posts: 84
Joined: Tue Apr 28, 2009 11:58 pm

Re: Howto compile static binaries

Postby zear on Wed Jun 17, 2009 1:29 pm

That's my configure line:
Code: Select all
./configure --host=mipsel-linux --target=mipsel-linux --with-sdl-prefix=/opt/dingoo-uclibc-toolchain-05-28-09/usr/ --enable-static

If that doesn't set it to static compilation, I simply put a --static after gcc path in the Makefile (could be also passed to the CFLAGS, but that way it's quicker (and probably incorrect :P))

Also, keep in mind, that when static compiling, the order of the libs in the CFLAGS section matters.
If you get any "undefined reference" errors, you either have the libs in the wrong order, or static compilation requires you to pass more libs in the Makefile.

BTW I also find it useful to type:
Code: Select all
export PATH="${PATH}:/opt/dingoo-uclibc-toolchain-05-28-09/usr/bin/"

before I crosscompile. This way I don't need to enter absolute pathes to the gcc location in the Makefile/confgure scripts.

I also symlinked sdl-config to mipsel-sdl-config so it won't get confused with my x86 sdl-config, when the path to my toolchain is exported.
zear
 
Posts: 98
Joined: Thu Jun 11, 2009 8:34 pm

Re: Howto compile static binaries

Postby ezelkow1 on Wed Jun 17, 2009 5:04 pm

I do usually do pretty much the same thing except I just permanently have those in my path in my .bashrc. The only thing is that I have found some configure scripts just flat out refuse to use the mipsel linker and so once you get to the end of compilation it gets all screwed up since gcc ld doesnt understand mips libs and you have to do it by hand or heavily edit files. It also sometimes just looks at the wrong libs. I believe one solution for this is to have pkg-config support in the toolchain which I have added recently but not uploaded anywhere, this solves issues on some of the more advanced configure scripts that use this to automatically pull paths.

I recently had to reformat though so Ive lost everything, hoping to get setup again tonight and then get back to work on trying to update the toolchain.
ezelkow1
 
Posts: 84
Joined: Tue Apr 28, 2009 11:58 pm


Return to Homebrew

Who is online

Users browsing this forum: No registered users and 1 guest