Probleme compiling wiht irrXML.h

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
maroxe
Posts: 51
Joined: Wed Dec 10, 2008 1:52 pm

Probleme compiling wiht irrXML.h

Post by maroxe »

Hi,
I tried to compile all2pov(livred with irrnewt), it uses irrlicht.
but when compiling, i get the following errors(all in irrXML.h):

Code: Select all

../../irrlicht-1.4.2/include/irrString.h||In constructor ‘irr::core::string<T, TAlloc>::string(double)’:|
../../irrlicht-1.4.2/include/irrString.h|59|error: there are no arguments to ‘_snprintf’ that depend on a template parameter, so a declaration of ‘_snprintf’ must be available|
../../irrlicht-1.4.2/include/irrString.h|59|error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)|
../../irrlicht-1.4.2/include/irrXML.h|425|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrXML.h|438|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrXML.h|450|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrXML.h|462|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrXML.h|475|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrXML.h|487|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrXML.h|499|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrXML.h|513|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrlicht.h|278|error: expected constructor, destructor, or type conversion before ‘(’ token|
../../irrlicht-1.4.2/include/irrlicht.h|297|error: expected constructor, destructor, or type conversion before ‘(’ token|
/home/bachir/lib/aresfps/all2pov/all2pov.cpp||In function ‘std::string storeMeshbuffer(SingleMeshBuffer)’:|
/home/bachir/lib/aresfps/all2pov/all2pov.cpp|415|warning: comparison between signed and unsigned integer expressions|
/home/bachir/lib/aresfps/all2pov/all2pov.cpp||In function ‘int main(int, char**)’:|
/home/bachir/lib/aresfps/all2pov/all2pov.cpp|452|error: ‘createDevice’ is not a member of ‘irr’|
/home/bachir/lib/aresfps/all2pov/all2pov.cpp|543|warning: comparison between signed and unsigned integer expressions|
||=== Build finished: 13 errors, 2 warnings ===|
how can i solve that?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I'm thinking that the error about _snprintf() is coming up because there is no function declared that matches that name. The Microsoft headers declare the function with the leading underscore, but most systems do not. The #define in irrTypes.h could be tweaked to fix this.

As for the other errors, I think the issue is the declspec macros. I'm pretty sure that it is because Irrlicht and Irrxml are not supported/tested on gcc in Windows.

The simple solution would be to use a platform (compiler/os combination) that is known to work.

Travis
wyrmmage
Posts: 204
Joined: Sun Mar 16, 2008 3:12 am
Contact:

Post by wyrmmage »

check out your third error, too:

Code: Select all

../../irrlicht-1.4.2/include/irrString.h|59|error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)|
Dunno if that flag will help at all, but it's probably worth a shot :)
-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com
Ganadu'r, The Eternal Sage (Other Current Project) - http://rpg.naget.com
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It'll probably fail to link if he uses that flag.
maroxe
Posts: 51
Joined: Wed Dec 10, 2008 1:52 pm

Post by maroxe »

i am ot on widows, but on linux( ubuntu ) ;) and irrlicht is supposed to work with gcc on Linux
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I should have known. I failed to look at the last few lines of the error message. They show the fullly qualified path to the source file.

The following code, from irrTypes.h is causing _snprintf to be used where snprintf is written in irrString.h.

Code: Select all

  92 #ifdef _IRR_WINDOWS_API_
   93 //! Defines for s{w,n}printf because these methods do not match the ISO C
   94 //! standard on Windows platforms, but it does on all others.
   95 //! These should be int snprintf(char *str, size_t size, const char *format, ...);
   96 //! and int swprintf(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...);
   97 #if defined(_MSC_VER) && _MSC_VER > 1310 && !defined (_WIN32_WCE)
   98 #define swprintf swprintf_s
   99 #define snprintf sprintf_s
  100 #else
  101 #define swprintf _snwprintf
  102 #define snprintf _snprintf
  103 #endif
As for the other messages, these are the lines for which they refer...

Code: Select all

  // irrXML.h
  425 	IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file);

  438 	IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback);

  450 	IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename);

  462 	IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file);

  475 	IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback);

  487 	IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename);

  499 	IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file);

  513 	IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback);

  // irrlicht.h
  317 	IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(
  318 		video::E_DRIVER_TYPE deviceType = video::EDT_SOFTWARE,
  319 		// parantheses are necessary for some compilers
  320 		const core::dimension2d<s32>& windowSize = (core::dimension2d<s32>(640,480)),
  321 		u32 bits = 16,
  322 		bool fullscreen = false,
  323 		bool stencilbuffer = false,
  324 		bool vsync = false,
  325 		IEventReceiver* receiver = 0);

  335 	IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(
  336 		const SIrrlichtCreationParameters& parameters);
The only thing about those declarations that isn't pure valid C++ is the macros IRRLICHT_API and IRRCALLCONV. You can see that they are defined in IrrCompileConfig.h. If it is determined that you are not on windows, then the macros are defined to nothing, and they disappear. If you are on windows, then they expand out...

Code: Select all

  305 #ifdef _IRR_WINDOWS_API_
  306 
  307 // To build Irrlicht as a static library, you must define _IRR_STATIC_LIB_ in both the
  308 // Irrlicht build, *and* in the user application, before #including <irrlicht.h>
  309 #ifndef _IRR_STATIC_LIB_
  310 #ifdef IRRLICHT_EXPORTS
  311 #define IRRLICHT_API __declspec(dllexport)
  312 #else
  313 #define IRRLICHT_API __declspec(dllimport)
  314 #endif // IRRLICHT_EXPORT
  315 #else
  316 #define IRRLICHT_API
  317 #endif // _IRR_STATIC_LIB_
  318 
  319 // Declare the calling convention.
  320 #if defined(_STDCALL_SUPPORTED)
  321 #define IRRCALLCONV __stdcall
  322 #else
  323 #define IRRCALLCONV __cdecl
  324 #endif // STDCALL_SUPPORTED
  325 
  326 #else
  327 #define IRRLICHT_API
  328 #define IRRCALLCONV
  329 #endif // _IRR_WINDOWS_API_
So you're doing something that is causing Irrlicht to think that you're on windows. This block of code in IrrCompileConfig.h is likely the one that is causing _IRR_WINDOWS_API_ to be defined.

Code: Select all

   35 #if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) || defined(_WIN32_WCE)
   36 #define _IRR_WINDOWS_
   37 #define _IRR_WINDOWS_API_
   38 #ifndef _IRR_USE_SDL_DEVICE_
   39 #define _IRR_USE_WINDOWS_DEVICE_
   40 #endif
   41 #endif
   42 
   43 // XBox only suppots the native Window stuff
   44 #if defined(_XBOX)
   45 #define _IRR_XBOX_PLATFORM_
   46 #define _IRR_WINDOWS_API_
   47 #define _IRR_USE_WINDOWS_DEVICE_
   48 #endif
So something is being done to make the compiler think you're on windows. This might be happening because the tool you're compiling hasn't been configured to build with gcc.

Regardless, I've helped you as much as I think I possibly can given the information you've provided. You should be able to figure out how to resolve the problem given the information above.

Travis
maroxe
Posts: 51
Joined: Wed Dec 10, 2008 1:52 pm

Post by maroxe »

you're right, i deleted the defines in codeblock project(the author of code blocks is on widows, so he used windows version ofcodeblocks, and every thing is fine now.
thanks :D
Post Reply