Discussion:
Malloc issue when cross-compiling with autotools
Francisco Cuesta
2013-02-04 15:37:47 UTC
Permalink
Hello,

I'm still struggling with autotools plugin in eclipse and some C++ project
I have downloaded.

My goal consists on cross-compilng for an arm processor, so the project is
already configured to work with autotools, but when I try to crosscompile I
have the following issue
*
In file included from /usr/include/c++/4.6/bits/stl_algo.h:61:0,
from /usr/include/c++/4.6/algorithm:63,
from dtntracepath.cpp:17:
/usr/include/c++/4.6/cstdlib:119:11: error: ‘::malloc’ has not been declared
*

I've checked out the configure output of my ibrdtn-tools noticing this
...
checking for stdlib.h... (cached) yes
*checking for GNU libc compatible malloc... no*
checking for memset... yes
...

I know how to fix it through linux terminal through adding the option *export
ac_cv_func_malloc_0_nonnull=yes* , but non through Eclipse or autotools
pluging, since the settings of the project aren't available. May you
enlighten me?

Kind regards,
Thanks in advance,
Francisco

PS: the parameters which I've set in autotools plugin are the following
ones:

-Command: configure CFLAGS="-m32" LDFLAGS="-m32"
CC=/home/t/s/arm-mv5sft-linux-gnueabi/SW3.2p1/bin/arm-mv5sft-linux-gnueabi-gcc
CC=c99
-All options : *--host=arm-mv5sft-linux-gnueabi --build=i686-linux
--target=arm-mv5sft-linux-gnueabi
--with-sysroot=/home/t/s/arm-mv5sft-linux-gnueabi/SW3.2p1/arm-mv5sft-linux-gnueabi/
*
Paul Eggert
2013-02-04 23:32:45 UTC
Permalink
One possible way to fix it is to alter these lines in
m4/malloc.m4:

[case "$host_os" in
# Guess yes on platforms where we know the result.
*-gnu* | freebsd* | netbsd* | openbsd* \
| hpux* | solaris* | cygwin* | mingw*)
ac_cv_func_malloc_0_nonnull=yes ;;
# If we don't know, assume the worst.
*) ac_cv_func_malloc_0_nonnull=no ;;
esac

Is your platform is one where 'yes' is the appropriate
answer? If so, what is the value of "$host_os" for you?
Perhaps we should change gnulib by adding your platform to the list.
Francisco Cuesta
2013-02-05 15:57:50 UTC
Permalink
Hi thanks for reply Paul,

I've been checking the m4 folder in which the project has declared all the
.m4 files and there isn't any funciton called malloc.m4. The only reference
to malloc is done in the configure.ac file with the instance *AC_FUNC_MALLOC
* *.

*
I'm not sure if my platform would pass through the condition since it is a
linux-gnueabi ( when crosscompiling --host=arm-mv5sft-linux-gnueabi)

Thanks in advance,

Regards


**
Post by Paul Eggert
One possible way to fix it is to alter these lines in
[case "$host_os" in
# Guess yes on platforms where we know the result.
*-gnu* | freebsd* | netbsd* | openbsd* \
| hpux* | solaris* | cygwin* | mingw*)
ac_cv_func_malloc_0_nonnull=yes ;;
# If we don't know, assume the worst.
*) ac_cv_func_malloc_0_nonnull=no ;;
esac
Is your platform is one where 'yes' is the appropriate
answer? If so, what is the value of "$host_os" for you?
Perhaps we should change gnulib by adding your platform to the list.
Paul Eggert
2013-02-05 20:29:03 UTC
Permalink
Post by Francisco Cuesta
there isn't any funciton called malloc.m4
Ah, sorry, I thought you were using gnulib.
Hmm, well, then perhaps my suggestion is to
steal the _AC_FUNC_MALLOC_IF macro from
m4/malloc.m4 from gnulib, and possibly
modify it to fix your problem.

http://savannah.gnu.org/projects/gnulib

http://git.savannah.gnu.org/cgit/gnulib.git/tree/m4/malloc.m4

Eric Blake
2013-02-04 23:56:10 UTC
Permalink
Post by Francisco Cuesta
I know how to fix it through linux terminal through adding the option *export
ac_cv_func_malloc_0_nonnull=yes* , but non through Eclipse or autotools
pluging, since the settings of the project aren't available. May you
enlighten me?
Can't you set that environment variable before starting eclipse, so that
it propagates all the way through to when eclipse starts running configure?

Or, it might be possible to set up a config.site that pre-populates the
correct answer for your toolchain:
https://www.gnu.org/software/autoconf/manual/autoconf.html#Site-Defaults
Post by Francisco Cuesta
PS: the parameters which I've set in autotools plugin are the following
-Command: configure CFLAGS="-m32" LDFLAGS="-m32"
CC=/home/t/s/arm-mv5sft-linux-gnueabi/SW3.2p1/bin/arm-mv5sft-linux-gnueabi-gcc
CC=c99
I'm not familiar with eclipse, but wouldn't this -Command: line be where
you can add arbitrary options to configure, including
ac_cv_func_malloc_0_nonnull=yes?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Francisco Cuesta
2013-02-05 16:17:07 UTC
Permalink
Hello Eric, thanks for replying

*Can't you set that environment variable before starting eclipse, so that
it propagates all the way through to when eclipse starts running configure?

*
To be honest, I don't know how to achieve that, since I was used to define
that parameter on project C/C++ build>>setting>>build steps>>prebuild
steps, but with autotools plugin on eclipse that parameter is "hidden" or
not configurable.

*Or, it might be possible to set up a config.site that pre-populates the
correct answer for your toolchain:
https://www.gnu.org/software/autoconf/manual/autoconf.html#Site-Defaults
*
If I have understood correctly, according to that I could create a
config.site in a concrete folder just with the instruction *
ac_cv_func_malloc_0_nonnull=yes
*
Wouldn't this configuration be overridden when executing the macros .m4??


*I'm not familiar with eclipse, but wouldn't this -Command: line be where
you can add arbitrary options to configure, including
ac_cv_func_malloc_0_nonnull=*
*yes?

*
I haven't tried it because compiling through the terminal (which indeed
works) I typed that command before calling ./configure, so I don't know
how to include that opticon in the ./configure command.

Thanks in advance,

Regards,
Post by Francisco Cuesta
Post by Francisco Cuesta
I know how to fix it through linux terminal through adding the option
*export
Post by Francisco Cuesta
ac_cv_func_malloc_0_nonnull=yes* , but non through Eclipse or autotools
pluging, since the settings of the project aren't available. May you
enlighten me?
Can't you set that environment variable before starting eclipse, so that
it propagates all the way through to when eclipse starts running configure?
Or, it might be possible to set up a config.site that pre-populates the
https://www.gnu.org/software/autoconf/manual/autoconf.html#Site-Defaults
Post by Francisco Cuesta
PS: the parameters which I've set in autotools plugin are the following
-Command: configure CFLAGS="-m32" LDFLAGS="-m32"
CC=/home/t/s/arm-mv5sft-linux-gnueabi/SW3.2p1/bin/arm-mv5sft-linux-gnueabi-gcc
Post by Francisco Cuesta
CC=c99
I'm not familiar with eclipse, but wouldn't this -Command: line be where
you can add arbitrary options to configure, including
ac_cv_func_malloc_0_nonnull=yes?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Loading...