Again a stupid linker problem

charlie

28-01-2006 17:06:46

I'm following the tutorial in the wiki and ran into the following linker error:

Linking...
MyProject.obj : error LNK2019: unresolved external symbol "public: __thiscall OgreNewt::World::~World(void)" (??1World@OgreNewt@@QAE@XZ) referenced in function "public: void * __thiscall OgreNewt::World::`scalar deleting destructor'(unsigned int)" (??_GWorld@OgreNewt@@QAEPAXI@Z)
MyProject.obj : error LNK2019: unresolved external symbol "public: __thiscall OgreNewt::World::World(void)" (??0World@OgreNewt@@QAE@XZ) referenced in function "protected: __thiscall MyProject::MyProject(void)" (??0MyProject@@IAE@XZ)
MyProject.obj : error LNK2019: unresolved external symbol "public: __thiscall OgreNewt::BasicFrameListener::BasicFrameListener(class Ogre::RenderWindow *,class Ogre::Camera *,class Ogre::SceneManager *,class OgreNewt::World *,int)" (??0BasicFrameListener@OgreNewt@@QAE@PAVRenderWindow@Ogre@@PAVCamera@3@PAVSceneManager@3@PAVWorld@1@H@Z) referenced in function "protected: virtual void __thiscall MyProject::createFrameListener(void)" (?createFrameListener@MyProject@@MAEXXZ)
Release/MyProject.exe : fatal error LNK1120: 3 unresolved externals


I have already added the following two paths to my libary paths:
C:\Ogre\OgreNewt\ogrenewt\OgreNewt_Main\lib\release
C:\NewtonSDK\sdk\dll


Do I have to configure anything else which I missed?

walaber

28-01-2006 18:01:21

did you also add "OgreNewt_Main.lib" and "newton.lib" to the "input" section of the linker settings?

charlie

28-01-2006 18:50:08

No, but once I did the problem (or the errors) got even worse.

I now have as linker input (additional dependencies):
OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib OgreNewt_Main.lib newton.lib

The output is really strange. It says I've already declared things in my code, however I don't know what this could be...


Linking...
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in ActionHandling.obj
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in GUIControl.obj
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in GUIControl.obj
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in ActionHandling.obj
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(char const *)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in GuiFrameListener.obj
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::max_size(void)const " (?max_size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in ActionHandling.obj
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z) already defined in ActionHandling.obj
MSVCRT.lib(MSVCR71.dll) : error LNK2005: "public: __thiscall bad_cast::bad_cast(char const *)" (??0bad_cast@@QAE@PBD@Z) already defined in LIBC.lib(stdexcpt.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBC.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBC.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
Release/MyProject.exe : fatal error LNK1169: one or more multiply defined symbols found

walaber

28-01-2006 23:54:40

make sure in the "C/C++" settings of your project, you have the "code generation" set to multithread DLL. if your main project is set to this, one of the libraries you are linking to has been compiled improperly, and needs to be recompiled as multithread DLL.

FriendlyWarlord

07-07-2006 05:19:30

Hi, sorry for bumping this thread up, I was going to put a link to this one in a new thread, but this one was going to dissapear....

So: I have the OgreNewt demos comiling and running perfectly in VC++ 7.1, and also the tutorial from the wiki. Then I made a new VC++ project (an Ogre project from the Ogre Application Wizard thing) called Sandbox, in ogreaddons\OgreNewt\demos\Sandbox. And I copied the .cpp and .h files from the first demo and put them in the Sandbox project (which is also in the OgreNewt_vc71 solution). Trying to compile Sandbox, but it gives linker errors, pretty much identical to the ones in the first post. All the projects I've been compiling were using the multithreaded DLL... so I'm stuck. Any ideas? Could it be that there's too many build paths?

FriendlyWarlord

09-07-2006 22:50:46

Sorry for the double post...

It turns out I needed to actually add the lib files to the Sandbox project, so now it compiles and links fine. But when I test it, it doesn't start and gives this:
'Sandbox.exe': Loaded 'D:\OgreSDK\ogreaddons\OgreNewt\demos\Sandbox\bin\release\Sandbox.exe', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\OgreSDK\ogreaddons\OgreNewt\demos\Sandbox\bin\release\OgreMain.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\OgreSDK\ogreaddons\OgreNewt\demos\Sandbox\bin\release\zlib1.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\OgreSDK\ogreaddons\OgreNewt\demos\Sandbox\bin\release\DevIL.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\user32.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\msvcr71.dll', Symbols loaded.
'Sandbox.exe': Loaded 'D:\OgreSDK\ogreaddons\OgreNewt\demos\Sandbox\bin\release\ILU.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\msvcp71.dll', Symbols loaded.
'Sandbox.exe': Loaded 'D:\OgreSDK\ogreaddons\OgreNewt\demos\Sandbox\bin\release\Newton.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\OgreSDK\ogreaddons\OgreNewt\demos\Sandbox\bin\release\OgrePlatform.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\dinput8.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'Sandbox.exe': Loaded 'D:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
First-chance exception at 0x7c81eb33 in Sandbox.exe: Microsoft C++ exception: Ogre::Exception @ 0x0012fba0.
First-chance exception at 0x7c81eb33 in Sandbox.exe: Microsoft C++ exception: Ogre::Exception @ 0x0012fcf4.
'Sandbox.exe': Unloaded 'D:\OgreSDK\ogreaddons\OgreNewt\demos\Sandbox\bin\release\OgrePlatform.dll'
'Sandbox.exe': Unloaded 'D:\WINDOWS\system32\dinput8.dll'
'Sandbox.exe': Unloaded 'D:\WINDOWS\system32\advapi32.dll'
'Sandbox.exe': Unloaded 'D:\WINDOWS\system32\rpcrt4.dll'
The program '[1272] Sandbox.exe: Native' has exited with code 0 (0x0).


I also tried doing this same thing in an identical project that wasn't in the OgreNewt demos solution (but in debug). That one compiles fine too, but the debugger breaks in "Microsoft Visual Studio .NET 2003\Vc7\crt\scr\output.c". And I'm using the same DLLs I used for the original OgreNewt demos (which still work perfectly).

So I'm still stumped, although I did find another thread dealing with it, but that solution didn't work. Please help!

walaber

10-07-2006 13:52:54

do you have your "working directory" set properly in the IDE?

FriendlyWarlord

11-07-2006 05:01:20

Earlier I tried looking for where to change the working directory, but couldn't find it. So I found it now, and ironically it was already set up right =p

Still having the same problem, but I found this:
http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=1397&highlight=rpcrt4
looks like I might have to build Ogre from source... =\

FriendlyWarlord

18-07-2006 02:19:03

(One build from source later...)

Exactly the same problem (I made sure to set up the paths to ogrenew). I did notice the working directory for Sandbox had changed, so I changed it back (and still no luck). It's probably something really obvious that I'm missing, has anyone else run into a similar problem? Sorry the thread title doesn't reflect the subject anymore, wouldn't mind if it was changed to something more appropriate... I don't have a clue what's causing it, so I wouldn't know what to rename it =p

Oh, one more thing. I was experimenting with things in the Demo_01 project, and now it exits with a very similar exception when you start the actual 3D part (the ogre app settings choosing box part works fine). Seriously, I'm desparate, this kind of stuff (non-coding) is obviously not my forte...

[Edit]
So somehow it was compiling correctly (or thinking it was up to date) when it should have been compile giving helpful compile errors - I found out that I hadn't re-included the ogre demo application (after recompiling some other projects that it thought weren't up to date). Now all the projects in the OgreNewt Demos solution work fine, but the one project outside of it (a clone of Demo01) still gives the same mysterious runtime error in output.c. So close... but at least I can do some sandbox-y type stuff in OgreNewt now =D