# libc.a Undefined references.



## kolbycrouch (Jun 26, 2013)

Hi _a_ll. I'm trying to build a completely static userland, and most things work fine simply having 
	
	



```
LDFLAGS=-static
```
 in /etc/src.conf.

However some builds fail with undefined references to environ and __getprogname.

Usually this is fixed by adding some library to your linker flags, but I'm not sure which library should have this, I thought it was defined in libc. Out of about 700 packages or so I've been building statically, this is the error I get about 95% of the time, if something fails. Most packages are fine, and a few programs have bugs (I guess) that are only exposed when linked statically.

Thanks I advance, and congra_t_ulations to the freebsd FreeBSD developers getting KMS for my new Intel card to work fairly well, in a pretty short time :e


----------



## SirDice (Jun 27, 2013)

kolbycrouch said:
			
		

> Out of about 700 packages or so I've been building statically, this is the error I get about 95% of the time, if something fails. Most packages are fine, and a few programs have bugs (I guess) that are only exposed when linked statically.


Settings in src.conf only apply to the kernel and userland tools of the base OS. They do nothing for ports.



> The src.conf file contains settings that will apply to every build involving the FreeBSD source tree; see build(7).


From src.conf(5)

As for the option, you really should apply it like this:

```
LDFLAGS+=-static
```
This will _add_ the option. In your case it will _replace_ all the options with -static.


----------



## kolbycrouch (Jul 29, 2013)

*Undefined references*

I get undefined references to environ and __progname from libc.a when linking certain programs statically. What I'm wanting to know, is if there is anyway to force libc to build with those symbols defined, or is there any way I can use objdump to define it?


----------



## cpm@ (Jul 29, 2013)

You posted a similar thread:
http://forums.freebsd.org/showthread.php?t=40493.

Please, continue writting there instead open a new one.

Related to your problem, have you tried to rebuild and install lib/libc?


----------



## DutchDaemon (Jul 29, 2013)

[ merged ]


----------

