Comments (6)
Looks like this is caused by autoconf's AC_FUNC_MALLOC. I think that
libcoap should be able to go without in the long run. My proposed fix
therefore is as simple as the following:
diff --git a/configure.ac b/configure.ac
index 31158d8..1cf082e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -276,7 +276,6 @@ AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Checks for library functions.
-AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo \
strnlen])
from libcoap.
Hello guys,
For now I've solved changing (as suggested here Link):
AC_FUNC_MALLOC
to AC_CHECK_FUNCS([malloc])
I wil test it better as soon as I can.
from libcoap.
ikoes [email protected] writes:
I have updated my local repository and tried to rebuild without
exporting the env variable as explained before.By the way the result is the same:
Please note that the proposed patch is not yet applied to the code in
the repository. It was supposed to be (tested and) discussed.
from libcoap.
ikoes [email protected] writes:
For now I've solved changing:
AC_FUNC_MALLOCto AC_CHECK_FUNCS([malloc])
This will fix the compilation issue. The question I had raised was
whether or not this is the right thing to do.
from libcoap.
The error that happen while cross compiling is quite logical if you know what the check AC_FUNC_MALLOC is made for. The behavior isn't really wrong (for me) because autoconf can't really test the created code due it's for another platform. Some nice explanation about the whole problem can be found here:
http://wiki.buici.com/xwiki/bin/view/Programing+C+and+C%2B%2B/Autoconf+and+RPL_MALLOC
But as long as libcoap uses malloc from the libc we need a check for the proper implementation for this cases. So removing AC_FUNC_MALLOC isn't solving the problem. We need at least a check for a malloc functionality which can be done by AC_CHECK_FUNC(S) like suggested above. So would change the autoconf check to something like this:
diff --git a/configure.ac b/configure.ac
index 7f2ff90..f4452ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -276,9 +276,8 @@ AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Checks for library functions.
-AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo \
- strnlen])
+ strnlen malloc])
# Check if -lsocket -lnsl is required (specifically Solaris)
AC_SEARCH_LIBS([socket], [socket])
After this you will get cross compiled binaries like native non cross builds.
$ PATH=/home/carsten/gitprojects/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/:$PATH
$ ./autogen.sh
....
$ ./configure --host=arm-bcm2708-linux-gnueabi --disable-documentation
$ ./configure --host=arm-bcm2708-linux-gnueabi --disable-documentation
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-bcm2708-linux-gnueabi-strip... arm-bcm2708-linux-gnueabi-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-bcm2708-linux-gnueabi-gcc... arm-bcm2708-linux-gnueabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-bcm2708-linux-gnueabi-gcc accepts -g... yes
checking for arm-bcm2708-linux-gnueabi-gcc option to accept ISO C89... none needed
checking whether arm-bcm2708-linux-gnueabi-gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of arm-bcm2708-linux-gnueabi-gcc... gcc3
checking for arm-bcm2708-linux-gnueabi-ar... arm-bcm2708-linux-gnueabi-ar
checking the archiver (arm-bcm2708-linux-gnueabi-ar) interface... ar
checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-bcm2708-linux-gnueabi
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by arm-bcm2708-linux-gnueabi-gcc... /home/carsten/gitprojects/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/bin/ld
checking if the linker (/home/carsten/gitprojects/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /home/carsten/gitprojects/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin//arm-bcm2708-linux-gnueabi-nm -B
checking the name lister (/home/carsten/gitprojects/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin//arm-bcm2708-linux-gnueabi-nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to arm-bcm2708-linux-gnueabi format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /home/carsten/gitprojects/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/bin/ld option to reload object files... -r
checking for arm-bcm2708-linux-gnueabi-objdump... arm-bcm2708-linux-gnueabi-objdump
checking how to recognize dependent libraries... pass_all
checking for arm-bcm2708-linux-gnueabi-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-bcm2708-linux-gnueabi-ar... (cached) arm-bcm2708-linux-gnueabi-ar
checking for archiver @FILE support... @
checking for arm-bcm2708-linux-gnueabi-strip... (cached) arm-bcm2708-linux-gnueabi-strip
checking for arm-bcm2708-linux-gnueabi-ranlib... arm-bcm2708-linux-gnueabi-ranlib
checking command to parse /home/carsten/gitprojects/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin//arm-bcm2708-linux-gnueabi-nm -B output from arm-bcm2708-linux-gnueabi-gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for arm-bcm2708-linux-gnueabi-mt... no
checking for mt... mt
configure: WARNING: using cross tools not prefixed with host triplet
checking if mt is a manifest tool... no
checking how to run the C preprocessor... arm-bcm2708-linux-gnueabi-gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if arm-bcm2708-linux-gnueabi-gcc supports -fno-rtti -fno-exceptions... no
checking for arm-bcm2708-linux-gnueabi-gcc option to produce PIC... -fPIC -DPIC
checking if arm-bcm2708-linux-gnueabi-gcc PIC flag -fPIC -DPIC works... yes
checking if arm-bcm2708-linux-gnueabi-gcc static flag -static works... yes
checking if arm-bcm2708-linux-gnueabi-gcc supports -c -o file.o... yes
checking if arm-bcm2708-linux-gnueabi-gcc supports -c -o file.o... (cached) yes
checking whether the arm-bcm2708-linux-gnueabi-gcc linker (/home/carsten/gitprojects/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether C compiler accepts -Wlogical-op... yes
checking whether C compiler accepts -fdiagnostics-color... no
checking whether the linker accepts -Wl,--version-script=./libcoap-1.map... yes
checking for ctags... /usr/bin/ctags
checking assert.h usability... yes
checking assert.h presence... yes
checking for assert.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking for unistd.h... (cached) yes
checking sys/unistd.h usability... yes
checking sys/unistd.h presence... yes
checking for sys/unistd.h... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for size_t... yes
checking for ssize_t... yes
checking for memset... yes
checking for select... yes
checking for socket... yes
checking for strcasecmp... yes
checking for strrchr... yes
checking for getaddrinfo... yes
checking for strnlen... yes
checking for malloc... yes
checking for library containing socket... none required
checking for library containing inet_ntop... none required
checking for library containing clock_gettime... -lrt
checking operating system... Linux
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating examples/Makefile
config.status: creating examples/coap-client.txt
config.status: creating examples/coap-server.txt
config.status: creating examples/coap-rd.txt
config.status: creating include/coap/coap.h
config.status: creating tests/Makefile
config.status: creating libcoap-1.pc
config.status: creating coap_config.h
config.status: coap_config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
libcoap configuration summary:
libcoap package version : "4.1.2"
libcoap library version : "0.0.0"
libcoap API version : "1"
host system : "arm-bcm2708-linux-gnueabi"
build documentation : "no"
build unit test binary : "no"
build examples : "yes"
--> use a2x : "no"
$ make -j4
....
$ file examples/.libs/coap-client
examples/.libs/coap-client: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.1.9, not stripped
from libcoap.
Fair enough. Although AC_FUNC_MALLOC obviously has its value here, I have dropped it in favor of tijuca's patch. All uses of coap_malloc() that invoke the system's malloc() function should already pass a value greater than zero but I did not review the entire code to ensure this.
from libcoap.
Related Issues (20)
- Removal of `COAP_MUTEX_DEFINE()` breaks Zephyr build
- Do not destroy mutexes in `coap_cleanup()` HOT 3
- Libcoap coap_io_process segmentation fault HOT 4
- Tracking subscribe responses when receiving block transfers (MTU < CoAP response) HOT 4
- 4.3.3 tag archive checksum has changed HOT 2
- Segmentation fault in coap_new_client_session HOT 2
- Sent PDU in response handler not correctly read HOT 6
- Add zephyr integration HOT 2
- libcoap DTLS seems to lack server chain file HOT 1
- Req: Support for self-signed certificates, optionable CRL check, and optimize WS communication HOT 6
- Allow coap-client disable CSM HOT 5
- Is coaps+tcp client supported by lwip+mbedtls? HOT 4
- coaps+tcp client support Full-duplex? HOT 8
- Improving behavior of coap_cleanup/coap_debug_reset HOT 1
- Can I know if a received request on CoAP server is a multicast or unicast HOT 8
- Block-Wise Transfers, the SZX does not match the size of the payload in bytes. HOT 7
- Does libcoap support coap+DTLS1.3? HOT 17
- Error code 4.08 is not being returned when previous block is missing. HOT 4
- Changing block size after negotiation HOT 2
- Type field is not matching Code field. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libcoap.