horde3d / Horde3D

Horde3D is a small 3D rendering and animation engine. It is written in an effort to create an engine being as lightweight and conceptually clean as possible.
http://horde3d.org/
1.55k stars 308 forks source link

compiler error (2.0.0) #186

Closed ghoomfrog closed 3 years ago

ghoomfrog commented 3 years ago
In file included from /home/u/rep/Horde3D-2.0.0/Extensions/Overlays/Source/extension.cpp:13:
/home/u/rep/Horde3D-2.0.0/Horde3D/Source/Shared/utPlatform.h: In function ‘float toFloat(const char*)’:
/home/u/rep/Horde3D-2.0.0/Horde3D/Source/Shared/utPlatform.h:208:9: error: ‘strtof_l’ was not declared in this scope
  208 |  return strtof_l(str, nullptr, locale.get());
      |         ^~~~~~~~
make[2]: *** [Extensions/Overlays/Source/CMakeFiles/Horde3DOverlays.dir/build.make:76: Extensions/Overlays/Source/CMakeFiles/Horde3DOverlays.dir/extension.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:543: Extensions/Overlays/Source/CMakeFiles/Horde3DOverlays.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

i use arch btw

algts commented 3 years ago

Hello. What compiler are you using? What version? It seems that additional include is needed.

ghoomfrog commented 3 years ago

gcc 10.2.0

algts commented 3 years ago

Currently I'm using previous version of gcc, so I cannot reproduce this error. But it seems like mac and ios have the same issue. Please try adding PLATFORM_LINUX define to line 185 int utPlatform.h and see if it works.

// Locale independent version of atof (taking always dot as decimal separator)
#if defined( PLATFORM_MAC ) || defined ( PLATFORM_IOS ) || defined ( PLATFORM_LINUX )
    #include <xlocale.h>
#endif
ghoomfrog commented 3 years ago

I've done it, but:

In file included from /home/u/rep/Horde3D-2.0.0/Extensions/Overlays/Source/extension.cpp:13:
/home/u/rep/Horde3D-2.0.0/Horde3D/Source/Shared/utPlatform.h:186:11: fatal error: xlocale.h: No such file or directory
  186 |  #include <xlocale.h>
      |           ^~~~~~~~~~~
compilation terminated.
make[2]: *** [Extensions/Overlays/Source/CMakeFiles/Horde3DOverlays.dir/build.make:76: Extensions/Overlays/Source/CMakeFiles/Horde3DOverlays.dir/extension.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:543: Extensions/Overlays/Source/CMakeFiles/Horde3DOverlays.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
algts commented 3 years ago

It seems that gcc removed this file from libc and judging by https://bugs.freedesktop.org/show_bug.cgi?id=102454 it should be moved to stdlib.h. Could you please try the following:

// Locale independent version of atof (taking always dot as decimal separator)
#if defined( PLATFORM_MAC ) || defined ( PLATFORM_IOS ) 
    #include <xlocale.h>
#elif defined( PLATFORM_LINUX )
        #include <cstdlib>
#endif

If it doesn't work, you may have to add #define __USE_GNU before including cstdlib. Sorry for nagging you with different proposals :)

ghoomfrog commented 3 years ago

That worked! make has been successful. And I didn't need to add #define __USE_GNU. And don't be sorry for helping out :).