# libutf-8 compilation error



## Voltar (Nov 25, 2009)

I'm encountering the following error while trying to compile converters/libutf-8 in a jail. The host machine is a freshly installed/compiled/updated FreeBSD 7.2-RELEASE-p4 amd64 system, and a fresh ports tree, likewise with the jail.


```
# make install
===>  Vulnerability check disabled, database not found
===>  Extracting for libutf-8-1.0,1
=> MD5 Checksum OK for libutf-8-1.0.tar.gz.
=> SHA256 Checksum OK for libutf-8-1.0.tar.gz.
===>  Patching for libutf-8-1.0,1
===>  Applying FreeBSD patches for libutf-8-1.0,1
===>  Configuring for libutf-8-1.0,1
===>  Building for libutf-8-1.0,1
cc -O2 -fno-strict-aliasing -pipe -march=nocona -c fget.utf-8.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -c sget.utf-8.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -c fput.utf-8.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -c sput.utf-8.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -c nomacros.c
ld -o libutf-8.so.1 fget.utf-8.o sget.utf-8.o fput.utf-8.o sput.utf-8.o nomacros.o -shared -soname libutf-8.so.1
ld: fget.utf-8.o: relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
fget.utf-8.o: could not read symbols: Bad value
*** Error code 1

Stop in /usr/ports/converters/libutf-8/work/libutf-8-1.0.
*** Error code 1

Stop in /usr/ports/converters/libutf-8.
```

I've been able to replicate the same error on a completely different machine running an up to date 7-STABLE. Also, the Makefile for the port does contain "CFLAGS+= -fPIC", so I am at a loss on the cause of this.

Thanks in advance.


----------



## Voltar (Nov 28, 2009)

Ok, I found the problem, it doesn't seem be honoring the CFLAGS variable. Not sure why I didn't catch that at first. 

Anyone have a suggestion on why that might be? If this really is a problem for more than just me I'd like to fix it and update the port since there doesn't seem to be a maintainer.


----------



## crsd (Nov 28, 2009)

Builds here:

```
===>  Extracting for libutf-8-1.0,1
=> MD5 Checksum OK for libutf-8-1.0.tar.gz.
=> SHA256 Checksum OK for libutf-8-1.0.tar.gz.
===>  Patching for libutf-8-1.0,1
===>  Applying FreeBSD patches for libutf-8-1.0,1
===>  Configuring for libutf-8-1.0,1
===>  Building for libutf-8-1.0,1
cc -O2 -pipe -fPIC -fno-strict-aliasing  -c fget.utf-8.c
cc -O2 -pipe -fPIC -fno-strict-aliasing  -c sget.utf-8.c
cc -O2 -pipe -fPIC -fno-strict-aliasing  -c fput.utf-8.c
cc -O2 -pipe -fPIC -fno-strict-aliasing  -c sput.utf-8.c
cc -O2 -pipe -fPIC -fno-strict-aliasing  -c nomacros.c
ld -o libutf-8.so.1 fget.utf-8.o sget.utf-8.o fput.utf-8.o sput.utf-8.o nomacros.o -shared -soname libutf-8.so.1
```

Do you have CFLAGS defined in /etc/make.conf?


----------



## Voltar (Nov 28, 2009)

Yes I do. 


```
CFLAGS= -O2 -fno-strict-aliasing -pipe
```

Edit: Thanks for the feedback!


----------



## crsd (Nov 28, 2009)

Well, that's your problem. Make it CFLAGS+= if you really need to define CFLAGS.


----------



## Voltar (Nov 28, 2009)

crsd said:
			
		

> Well, that's your problem. Make it CFLAGS+= if you really need to define CFLAGS.



I was under the impression that the "CFLAGS+= -fPIC" in the port's Makefile would be concatenated onto the end of the string in /etc/make.conf, just like my "CXXFLAGS+= -fconserve-space" gets appended to CFLAGS...

I could be wrong though, it is pretty late.


----------



## crsd (Nov 28, 2009)

Yes, sorry, it's really a problem with port itself. Try attached patch (or just specify CFLAGS?=..... in make.conf  )


----------



## Voltar (Nov 29, 2009)

That worked. Did a little tweaking and submitted a pr for an update.

Thanks for the help.


----------

