There are a few confusing error messages you can run into when compiling, linking, and debugging programs that use G3D. Here are the common fixes.
Program crashes inside ReferenceCountedPointer methods
You have probably made one of three mistakes in your program. If you use raw pointers
(e.g. Texture*, VARArea*
) to reference counted types, the reference count
will not know about your pointers and may garbage collect at the wrong time. Do not
use C pointers to Ref types. Use only Texture::Ref, VARAreaRef, VertexAndPixelShaderRef, etc.
The second mistake is deleting a Ref type. Never use delete with a Ref class; they automatically
delete themselves when the last pointer is dropped. To force the last pointer to be dropped,
assign NULL
to the Ref variable.
The third mistake is a normal dynamic cast with the wrong types. Any Ref type will
automatically try to cast to any other Ref type, so
VARAreaRef v = Texture::fromFile(...)
will compile correctly, but
fail at runtime inside dynamic_cast.
Program "randomly" crashes AMD systems
See the Microsoft Knowledge Base article.
undefined
symbol SDL_main
The linking error: undefined
symbol SDL_main can result from a main() function that doesn't have argc
and argv arguments. For example:
int main() {..} is no good... make sure you have int main(int argc,
char **argv) {..}
Application Error: The application failed to initialize properly (0xc0000022). Click on OK to terminate the application.
At runtime, your program can't load the SDL.dll, zlib.dll, or glut32.dll dynamic libraries.
This is probably occurring because the current working directory is invalid or because
the files and directory exist but cannot be accessed. This frequently occurs when a Windows
program is running from a Linux file system via Samba. Make sure you have set the eXecute
bit on the DLL's from Linux.
../include/G3D/g3dmath.h:27: limits: No such file or directory
You are using an old version of GCC on Linux. Add these lines to your .cshrc:
setenv CC gcc-3.2 setenv CXX g++-3.2
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::~basic_string ,class std::allocator >(void)" (??1?$basic_strin g@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string ,class std::allocator >::basic_string ,class std::allocator >(char const *,class basic_ string ,class std::allocator >::allocator const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDABV?$allocator@D@1@@Z) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string ,class std::allocator >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Q BEPBDXZ) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class std::basic_string ,class std::allocator > & __thiscall std::basic_string ,class std::allocator >::operator=(cl ass std::basic_string ,class std::allocator > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string ,class std::allocator >::basic_string ,class std::allocator >(class basic_string ,class std::allocator >::basic_string ,class std::allocator > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in main. obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: static double __cdecl std::numeric_limits ::infinity(void)" (?infinity@?$numeric_limits@N@std@@SANXZ) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: static double __cdecl std::numeric_limits ::quiet_NaN(void)" (?quiet_NaN@?$numeric_limits@N@std@@SANXZ) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string ,class std::allocator >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE IXZ) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class std::basic_string ,class std::allocator > & __thiscall std::basic_string ,class std::allocator >::operator+=(c lass std::basic_string ,class std::allocator > const &)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "bool __cdecl std::operator==(class std::basic_string ,class std::allocator > const &,char const *)" (??8std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocat or@D@2@@0@PBD@Z) already defined in main.obj msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class std::basic_string ,class std::allocator > & __thiscall std::basic_string ,class std::allocator >::operator+=(c har const *)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in main.obj MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _fflush already defined in LIBCD.lib(fflush.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _fclose already defined in LIBCD.lib(fclose.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _free already defined in LIBCD.lib(dbgheap.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _realloc already defined in LIBCD.lib(dbgheap.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __vsnprintf already defined in LIBCD.lib(vsnprint.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _exit already defined in LIBCD.lib(crt0dat.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _malloc already defined in LIBCD.lib(dbgheap.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __CrtIsValidHeapPointer already defined in LIBCD.lib(dbgheap.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __CrtIsValidPointer already defined in LIBCD.lib(dbgheap.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _sprintf already defined in LIBCD.lib(sprintf.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _toupper already defined in LIBCD.lib(toupper.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _tolower already defined in LIBCD.lib(tolower.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _calloc already defined in LIBCD.lib(dbgheap.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj) MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __isctype already defined in LIBCD.lib(isctype.obj) LINK : warning LNK4098: defaultlib "MSVCRTD" conflicts with use of other libs; use /NODEFAULTLIB:library Debug/GLG3D_Demo.exe : fatal error LNK1169: one or more multiply defined symbols found
array.h(233) : error C2512: : no appropriate default constructor available
array.h(195) : while compiling
class-template member function 'void __thiscall G3D::Array
You created a G3D::Array of a class that does not provide a default
constructor (constructor with no arguments). Define a default constructor
for your class-- G3D::Array needs it to initialize new elements when you
invoke G3D::Array::resize().
sdlmain.lib(SDL_main.obj) : error LNK2005: _main already defined in main.obj
You need to \#include <SDL.h>
in your main.cpp file.
error LNK2001: unresolved external symbol _glActiveTextureARB
Some other (e.g. MSVC .NET) program's include directory is listed before the
G3D directory and contains conflicting OpenGL drivers. Reorder the include directories
under Tools/Options/Directories
fatal error C1083: Cannot open include file: 'G3DAll.h': No such file or directory
You need to add the g3d/include directory to your include path.
LINK : fatal error LNK1181: cannot open input file
"glg3d.lib"
You need to add the graphics3d/lib directory
to your library path (instructions above)