# configure: error: c++ preprocessor "/lib/cpp" fails sanity check



## fredvs (Feb 27, 2016)

Hello.

I try to compile faad audio library.

But after `./configure`, there is that error message :
_
configure: error: c++ preprocessor "/lib/cpp" fails sanity check_

gcc was installed with: `pkg install gcc`

What is wrong ?

Thanks.

Fre;D


----------



## kpa (Feb 27, 2016)

/lib/cpp is a Linuxism as far as I know and to compile the source you'll have to do some patching to work around those. What prevents you from using the audio/faad port?


----------



## fredvs (Feb 28, 2016)

kpa -> Many thanks for your light.


kpa said:


> What prevents you from using the audio/faad port?



Ok, I will (try) to explain the problem.

faad audio-library uses a other library -> libmp4ff.

In FreeBSD package: faad2-2.7_5,1.txz there is:
libfaad.so.2.0.0 -> the main dynamic library.
libmp4ff.a -> the static library used by libfaad.so.2.0.0 .

My audio suite needs both *dynamic* libraries.
https://github.com/fredvs/uos

To make a static library -> dynamic, you may use that code:
`gcc -shared -o libmp4ff.so.0.0.0 -Wl,--whole-archive libmp4ff.a -Wl,--no-whole-archive`

Sadly, libmp4ff.a given in FreeBSD package was compiled without *-fPIC*, so gcc refuse to make a dynamic library.

It is the reason why I (try to) recompile the library, but with this:
`./configure CFLAGS=-fPIC --with-mp4v2 --enable-shared
make clean`

But without luck (see first topic).

Maybe I must do a other way ?

Thanks.

Fre;D


----------



## tobik@ (Feb 28, 2016)

But libmp4ff.a is compiled with -fPIC? Just look at the port Makefile and work/faad2-2.7/common/mp4ff/Makefile.am (after `make patch`). 

Can't you do this instead to get a dynamic library?

```
ar x /usr/local/lib/libmp4ff.a
cc -shared -o libmp4ff.so *.o
```


----------



## fredvs (Feb 28, 2016)

tobik said:


> Can't you do this instead to get a dynamic library?
> 
> ```
> ar x /usr/local/lib/libmp4ff.a
> ...



`ar x /usr/local/lib/libmp4ff.a`--> OK

`cc -shared -o libmp4ff.so *.o`--> cc is not found-installed (how to do it?), 
so I try with:
`gcc -shared -o libmp4ff.so *.o`--> _gcc: No match_
so I try with:
`gcc -shared -o /usr/local/lib/libmp4ff.so *.o`--> _gcc: No match_
so I try with:
`gcc -shared -o /usr/local/lib/libmp4ff.a *.o`--> _gcc: No match_

_;-(_

Thanks.


----------



## tobik@ (Feb 28, 2016)

fredvs said:


> `ar x /usr/local/lib/libmp4ff.a`--> OK
> 
> `cc -shared -o libmp4ff.so *.o`--> cc is not found-installed (how to do it?), so I try with:
> `gcc -shared -o libmp4ff.so *.o`--> _"rodatta" can not be used when making a shared object, recompile with -fPIC_
> ...


What FreeBSD version are you on? `cc` should be available on all supported versions.


----------



## fredvs (Feb 28, 2016)

tobik said:


> What FreeBSD version are you on?  cc should be available on all supported versions.


FreeBSD 10.1.

Indeed strange that gcc is installed and cc not...

But I have to confess that is is from my own distribution.
Maybe I forgot to install cc?

How can it be done?

Thanks.


----------



## kpa (Feb 28, 2016)

How the heck is that system installed? The vanilla 10.1 definitely has /usr/bin/cc and that is Clang. Anything in your /etc/make.conf or /etc/src.conf? Is this system updated/upgraded using freebsd-update(8) or using sources?


----------



## fredvs (Feb 28, 2016)

Hello.

OK, switched to a other "official" FreeBSD machine (Ghost) and with cc installed, your tip works perfectly.
I will test the result-library libmp4ff.so now.



kpa said:


> How the heck is that system installed? The vanilla 10.1 definitely has /usr/bin/cc and that is Clang. Anything in your /etc/make.conf or /etc/src.conf? Is this system updated/upgraded using freebsd-update(8) or using sources?



It is this distro.

Huh, could it be possible to a add a clang, or cc package, like you did for gcc?
`pkg install clang` ?

Other suggestion: you added libmp4ff.a in the patch.
That is great! But, be crazy, add libmp4ff.so too, end users need this one, not the static.
And you will be more generous than Linux that, also, only gives the static library.
And obliges, poor end users, to make by they-self static->dynamic.

By the way: many thanks and always solutions with FreeBSD. 

Fre;D


----------



## tobik@ (Feb 29, 2016)

fredvs said:


> But, be crazy, add libmp4ff.so too, end users need this one, not the static.
> And you will be more generous than Linux that, also, only gives the static library.
> And obliges, poor end users, to make by they-self static->dynamic.


It might happen if you submit a patch to audio/faad


----------



## fredvs (Feb 29, 2016)

tobik said:


> It might happen if you submit a patch to audio/faad



Of course, I will do it with great pleasure.

But, before to sent the patch,... it must work.

And, sadly, after test of the the result-library libm4ff.so , there are not only good news.

The library can be loaded with `LoadLibrary()` but fail to `GetProcAdress()`, this for each exported method.

The good news is that with libfaad.so provided by the patch, `GetProcAdress()` is working for all exported methods.

Do you have a idea how to create a dynamic library from a static and export the methods too?

Does it exist a utility in FreeBSD to check a library, to see the exported methods?

Many Thanks.

Fre;D


----------



## tobik@ (Feb 29, 2016)

fredvs said:


> Does it exist a utility in FreeBSD to check a library, to see the exported methods?


nm(1) or objdump(1) might be helpful: `nm -D --defined-only libmp4ff.so`


----------



## fredvs (Mar 2, 2016)

tobik said:


> might be helpful:  nm -D --defined-only libmp4ff.so



Yep ->







So, it seems that the methods are exported.

Sadly, all `GetProcAdress()` fail, for example : `GetProcAdress('mp4ff_open_read')` -> pointer is nil.

And for libfaad.so, all `GetProcAdress()` work.

I loose, I do not find the solution.

;-(

Fre;D


----------



## fredvs (Mar 20, 2016)

tobik said:


> It might happen if you submit a patch to audio/faad



Hello.

There in fpc-forum, they find the solution : use `dlsym()` in place of `GetProcAdress()`

So this dynamic libm4ff.so in attachment could be used for the patch.
Tested with perfect result on FreeBSD 10.1/2

Fre;D


----------

