aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: cross compilations fails with undeclared ::malloc and ::realloc  (Read 4093 times)

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292

This has been giving me headaches for days already.
stdlib.h is included by this file and the warning I placed directly underneath the declaration of malloc was displayed as well, but somehow (see mingw) are malloc and realloc undeclared again. When compiling natively on Linux nothing like this happens and I have trouble understanding what's going on.

Anyone an idea?

i686-apple-darwin8:
Quote
i686-apple-darwin8-g++ -DHAVE_CONFIG_H -I. -I..    -DENABLE_UPNP=1 -I/home/macosx/wxMac-2.8.4/build/lib/wx/include/i686-apple-darwin8-mac-unicode-release-static-2.8 -I/home/macosx/wxMac-2.8.4/include -I/home/macosx/wxMac-2.8.4/contrib/include -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__     -I./libs -Ilibs -DUSE_EMBEDDED_CRYPTO -W -Wall -Wshadow -Wundef -O2  -DUSE_WX_EXTENSIONS -MT amule-ExternalConn.o -MD -MP -MF .deps/amule-ExternalConn.Tpo -c -o amule-ExternalConn.o `test -f 'ExternalConn.cpp' || echo './'`ExternalConn.cpp
In file included from ExternalConn.h:31,
                 from ExternalConn.cpp:34:
./libs/ec/cpp/ECSpecialTags.h:28:2: warning: #warning Kry - Preferences packet derived from packet, and that's ok, but shouldn't be here because this is a tag file and forces a stupid include
In file included from ExternalConn.cpp:35:
updownclient.h:632:3: warning: #warning CHECK FOR USAGE - OBFUSCATION (rewrite addsources / server code)
updownclient.h:633:3: warning: #warning CHECK FOR USAGE - UDP encrypted send
In file included from ExternalConn.cpp:36:
Server.h:127:3: warning: #warning review;
In file included from ExternalConn.cpp:44:
ClientList.h:343:3: warning: #warning ALSO FIX THIS, NOW!!!
ExternalConn.cpp:847:2: warning: #warning Kry - lfroen, please fix this to work with 64bits
/opt/mac/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/cstdlib:110: error: '::malloc' has not been declared
/opt/mac/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/cstdlib:118: error: '::realloc' has not been declared
ClientList.h:344: warning: unused parameter 'ip'
make[3]: *** [amule-ExternalConn.o] Error 1

i486-mingw32:
Quote
i486-mingw32-g++ -DHAVE_CONFIG_H -I. -I..     -I/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/build/lib/wx/include/i486-mingw32-msw-unicode-release-static-2.8 -I/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include -I/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/contrib/include -D__WXMSW__ -mthreads    -I./libs -Ilibs -DNOMINMAX -DUSE_EMBEDDED_CRYPTO -W -Wall -Wshadow -Wundef -O2  -DUSE_WX_EXTENSIONS -MT amule-ExternalConn.o -MD -MP -MF .deps/amule-ExternalConn.Tpo -c -o amule-ExternalConn.o `test -f 'ExternalConn.cpp' || echo './'`ExternalConn.cpp
In file included from ExternalConn.h:31,
                 from ExternalConn.cpp:34:
./libs/ec/cpp/ECSpecialTags.h:28:2: warning: #warning Kry - Preferences packet derived from packet, and that's ok, but shouldn't be here because this is a tag file and forces a stupid include
In file included from ExternalConn.cpp:35:
updownclient.h:632:3: warning: #warning CHECK FOR USAGE - OBFUSCATION (rewrite addsources / server code)
updownclient.h:633:3: warning: #warning CHECK FOR USAGE - UDP encrypted send
In file included from ExternalConn.cpp:36:
Server.h:127:3: warning: #warning review;
In file included from ExternalConn.cpp:44:
ClientList.h:343:3: warning: #warning ALSO FIX THIS, NOW!!!
ExternalConn.cpp:846:2: warning: #warning Kry - lfroen, please fix this to work with 64bits
In file included from /usr/lib/gcc/i486-mingw32/4.2.0/../../../../i486-mingw32/include/c++/4.2.0/bits/stl_algobase.h:68,
                 from /usr/lib/gcc/i486-mingw32/4.2.0/../../../../i486-mingw32/include/c++/4.2.0/bits/char_traits.h:46,
                 from /usr/lib/gcc/i486-mingw32/4.2.0/../../../../i486-mingw32/include/c++/4.2.0/string:47,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/string.h:176,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/memory.h:16,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/object.h:20,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/event.h:17,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/socket.h:23,
                 from ./libs/ec/cpp/ECMuleSocket.h:29,
                 from ExternalConn.cpp:30:
/usr/lib/gcc/i486-mingw32/4.2.0/../../../../i486-mingw32/include/c++/4.2.0/cstdlib:123: error: '::malloc' has not been declared
/usr/lib/gcc/i486-mingw32/4.2.0/../../../../i486-mingw32/include/c++/4.2.0/cstdlib:131: error: '::realloc' has not been declared
In file included from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/clntdata.h:17,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/event.h:18,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/socket.h:23,
                 from ./libs/ec/cpp/ECMuleSocket.h:29,
                 from ExternalConn.cpp:30:
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/hashmap.h: In member function 'wxLongToLongHashMap_wxImplementation_HashTable::Node** wxLongToLongHashMap_wxImplementation_HashTable::GetNodePtr(const long int&) const':
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/hashmap.h:714: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/event.h:18,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/socket.h:23,
                 from ./libs/ec/cpp/ECMuleSocket.h:29,
                 from ExternalConn.cpp:30:
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/clntdata.h: In member function 'wxShadowObjectMethods_wxImplementation_HashTable::Node** wxShadowObjectMethods_wxImplementation_HashTable::GetNodePtr(const wxString&) const':
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/clntdata.h:20: warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/clntdata.h: In member function 'wxShadowObjectFields_wxImplementation_HashTable::Node** wxShadowObjectFields_wxImplementation_HashTable::GetNodePtr(const wxString&) const':
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/clntdata.h:25: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/clntdata.h:162,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/event.h:18,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/socket.h:23,
                 from ./libs/ec/cpp/ECMuleSocket.h:29,
                 from ExternalConn.cpp:30:
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/vector.h: In member function 'bool wxVectorBase::Alloc(size_t)':
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/vector.h:35: error: 'realloc' was not declared in this scope
In file included from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/event.h:21,
                 from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/socket.h:23,
                 from ./libs/ec/cpp/ECMuleSocket.h:29,
                 from ExternalConn.cpp:30:
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/gdicmn.h: In member function 'wxStringToColourHashMap_wxImplementation_HashTable::Node** wxStringToColourHashMap_wxImplementation_HashTable::GetNodePtr(const wxString&) const':
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/gdicmn.h:544: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from /home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/url.h:23,
                 from ./libs/common/ConvAmule.h:31,
                 from ./libs/common/StringFunctions.h:35,
                 from ./libs/ec/cpp/ECTag.h:34,
                 from ./libs/ec/cpp/ECPacket.h:28,
                 from ./libs/ec/cpp/ECSpecialTags.h:29,
                 from ExternalConn.h:31,
                 from ExternalConn.cpp:34:
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/protocol/http.h: In member function 'wxStringToStringHashMap_wxImplementation_HashTable::Node** wxStringToStringHashMap_wxImplementation_HashTable::GetNodePtr(const wxString&) const':
/home/johkra/devel/mingw/wxMSW/wxMSW-2.8.4/include/wx/protocol/http.h:21: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from ExternalConn.cpp:44:
ClientList.h: At global scope:
ClientList.h:344: warning: unused parameter 'ip'
ExternalConn.cpp: In member function 'void CPartFile_Encoder::Encode(CECTag*)':
ExternalConn.cpp:882: warning: dereferencing type-punned pointer will break strict-aliasing rules
make[3]: *** [amule-ExternalConn.o] Error 1
Logged

Coronas

  • Approved Newbie
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 48
Re: cross compilations fails with undeclared ::malloc and ::realloc
« Reply #1 on: July 17, 2007, 08:19:44 PM »

No, not the remotest idea, just a very dirty, despaired workaround and a link...

http://forum.openwrt.org/viewtopic.php?pid=4158

Code: [Select]
diff -Naur amule-cvs/configure amule-cvs.new/configure
--- amule-cvs/configure 2007-05-01 06:01:21.000000000 +0100
+++ amule-cvs.new/configure 2007-05-01 06:53:48.905808913 +0100
@@ -15022,7 +15022,7 @@
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
-  ac_cv_func_malloc_0_nonnull=no
+  ac_cv_func_malloc_0_nonnull=yes
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -15762,7 +15762,7 @@
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
-  ac_cv_func_realloc_0_nonnull=no
+  ac_cv_func_realloc_0_nonnull=yes
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: cross compilations fails with undeclared ::malloc and ::realloc
« Reply #2 on: July 17, 2007, 08:59:41 PM »

Thanks a lot, this did the trick, I finally got to see the errors I was actually looking for (linking errors) and can now finally start (to try) to fix the last show-stoppers before 2.2.0.
(linking errors + crash at statistics page on Mac)
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: cross compilations fails with undeclared ::malloc and ::realloc
« Reply #3 on: August 30, 2007, 05:44:19 PM »

A fix is already in svn. However, the real "fix" would be not to use malloc()/realloc() at all.
Logged
concordia cum veritate