Linker Error..

cobra8472

13-05-2008 23:32:06

Hi,

Getting this linker error when just putting one line of code that has with PagedGeometry to do in my app (just wanted to test if I had done everything right).

1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall PagedGeometry::PagedGeometry(class Ogre::Camera *,float)" (??0PagedGeometry@@QAE@PAVCamera@Ogre@@M@Z)
1>C:\Users\Cobra\Desktop\Ogre3D Flight Simulator\Ogre3D Flight Simulator\bin\release\Engine2.exe : fatal error LNK1120: 1 unresolved externals


I've double and triple checked so that the PagedGeometry.lib is where it is supposed to be and told the compiler where that directory is.

Not exactly sure which version of Ogre i'm using. 1.4.5 IIRC.


EDIT: It throws more Linker errors as I add more PagedGeometry code
Currently the following code;

PagedGeometry *trees1 = new PagedGeometry(mCamera, 500);
trees1->addDetailLevel<BatchPage>(200,50);
trees1->addDetailLevel<ImpostorPage>(1500,300);


Which throws 22 linker errors :S

1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall GeometryPage::clearBoundingBox(void)" (?clearBoundingBox@GeometryPage@@UAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall GeometryPage::addEntityToBoundingBox(class Ogre::Entity *,class Ogre::Vector3 const &,class Ogre::Quaternion const &,class Ogre::Vector3 const &)" (?addEntityToBoundingBox@GeometryPage@@UAEXPAVEntity@Ogre@@ABVVector3@3@ABVQuaternion@3@1@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual class Ogre::AxisAlignedBox const & __thiscall GeometryPage::getBoundingBox(void)" (?getBoundingBox@GeometryPage@@UAEABVAxisAlignedBox@Ogre@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "protected: void __thiscall PagedGeometry::_addDetailLevel(class GeometryPageManager *,float,float)" (?_addDetailLevel@PagedGeometry@@IAEXPAVGeometryPageManager@@MM@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall PagedGeometry::PagedGeometry(class Ogre::Camera *,float)" (??0PagedGeometry@@QAE@PAVCamera@Ogre@@M@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall GeometryPageManager::GeometryPageManager(class PagedGeometry *)" (??0GeometryPageManager@@QAE@PAVPagedGeometry@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BatchPage::setFade(bool,float,float)" (?setFade@BatchPage@@UAEX_NMM@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BatchPage::setVisible(bool)" (?setVisible@BatchPage@@UAEX_N@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BatchPage::removeEntities(void)" (?removeEntities@BatchPage@@UAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BatchPage::build(void)" (?build@BatchPage@@UAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BatchPage::addEntity(class Ogre::Entity *,class Ogre::Vector3 const &,class Ogre::Quaternion const &,class Ogre::Vector3 const &,class Ogre::ColourValue const &)" (?addEntity@BatchPage@@UAEXPAVEntity@Ogre@@ABVVector3@3@ABVQuaternion@3@1ABVColourValue@3@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ImpostorPage::update(void)" (?update@ImpostorPage@@UAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall BatchPage::~BatchPage(void)" (??1BatchPage@@UAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ImpostorPage::setFade(bool,float,float)" (?setFade@ImpostorPage@@UAEX_NMM@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BatchPage::init(class PagedGeometry *)" (?init@BatchPage@@UAEXPAVPagedGeometry@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ImpostorPage::setVisible(bool)" (?setVisible@ImpostorPage@@UAEX_N@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ImpostorPage::removeEntities(void)" (?removeEntities@ImpostorPage@@UAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ImpostorPage::build(void)" (?build@ImpostorPage@@UAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ImpostorPage::addEntity(class Ogre::Entity *,class Ogre::Vector3 const &,class Ogre::Quaternion const &,class Ogre::Vector3 const &,class Ogre::ColourValue const &)" (?addEntity@ImpostorPage@@UAEXPAVEntity@Ogre@@ABVVector3@3@ABVQuaternion@3@1ABVColourValue@3@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ImpostorPage::setRegion(float,float,float,float)" (?setRegion@ImpostorPage@@UAEXMMMM@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall ImpostorPage::~ImpostorPage(void)" (??1ImpostorPage@@UAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ImpostorPage::init(class PagedGeometry *)" (?init@ImpostorPage@@UAEXPAVPagedGeometry@@@Z)


I guess its almost like its not seeing the PagedGeometry lib, but it IS there..


EDIT2: Adding all the .cpp files to my project doesn't work either. Throws about 100 errors.
Most of them ending with "symbol cannot be defined within namespace 'Forests'"


Thanks

NoodlesOnMyBack

14-05-2008 00:24:51

Why dont you add Paged Geometry project to your solution,check if you can compile it from there, then right click on your own project and select Project Dependencies, check it, and add the include dir of PG, hope it helps

JohnJ

14-05-2008 04:18:16

I know you probably know this and have tried it, but in addition to specifying the lib folder to the linker, have you also added "PagedGeometry.lib" (for release mode) and "PagedGeometry_d.lib" (for debug mode) to the list of libraries to use? If you don't specify the file names, the linker doesn't open them.

cobra8472

14-05-2008 07:50:28

I know you probably know this and have tried it, but in addition to specifying the lib folder to the linker, have you also added "PagedGeometry.lib" (for release mode) and "PagedGeometry_d.lib" (for debug mode) to the list of libraries to use? If you don't specify the file names, the linker doesn't open them.

Yep, I have :'(

JohnJ

15-05-2008 15:25:24

Do the PagedGeometry examples work? If they do, then there must be something wrong with the project setup, but I guess it's just hard to find.

If you give up on including the PagedGeometry lib into your project, you could try it another way: add PagedGeometry's .cpp and .h files directly into the project (so there's no library step involved), and they should compile and link with your code.

cobra8472

15-05-2008 16:09:49

Do the PagedGeometry examples work? If they do, then there must be something wrong with the project setup, but I guess it's just hard to find.

If you give up on including the PagedGeometry lib into your project, you could try it another way: add PagedGeometry's .cpp and .h files directly into the project (so there's no library step involved), and they should compile and link with your code.


No dice there either. Added all the .cpp and .h files, and was rewarded with;

1>Project - 370 error(s), 9 warning(s)


Sample of the errors encountered;

1>..\..\..\PagedGeometry\source\TreeLoader3D.cpp(432) : error C2888: 'TreeRef TreeIterator3D::getNext(void)' : symbol cannot be defined within namespace 'Forests'
1>..\..\..\PagedGeometry\source\TreeLoader3D.cpp(439) : error C2888: 'void TreeIterator3D::moveNext(void)' : symbol cannot be defined within namespace 'Forests'



Most end with the, "Symbol cannot be defined within namespace Forests".

I must be doing something seriously wrong. The examples work fine...

JohnJ

15-05-2008 16:20:41

I just looked up error C2888, and I think I know what may be causing the problem. When you call #include "PagedGeometry.h", are you calling from within any namespace? Because you should always add your #include calls at the top of the program, before anything else. Otherwise you're likely to run into problems like this.

cobra8472

15-05-2008 17:43:30

I just looked up error C2888, and I think I know what may be causing the problem. When you call #include "PagedGeometry.h", are you calling from within any namespace? Because you should always add your #include calls at the top of the program, before anything else. Otherwise you're likely to run into problems like this.

Hmm, well, i'm not including any PagedGeometry .h files to my original source code just yet, because I haven't written any PagedGeometry code in it.

It throws all those errors when I try to compile the program with the PagedGeometry header and src files included into my project (directly).

Most of the errors are C2888, however alot are also stuff like;
1>..\..\..\PagedGeometry\source\TreeLoader2D.cpp(500) : error C2039: 'heightFunctionUserData' : is not a member of 'TreeLoader2D'

This doesn't make any sense to me. It's like the entire PagedGeometry code doesn't work! :S

JohnJ

16-05-2008 04:18:39

That is strange. The only thing I can think of now is, maybe try removing everything from the project but PagedGeometry's files and see if that compiles. If that doesn't work, something's seriously wrong with the project setup. I just can't figure out what it might be.

JarasM

12-11-2009 20:18:09

Hello. Sorry for bringing this thread back from the dead (if this issue is inappropriate for this thread, as it most probably has a different cause, I'd like to ask any mod to move it to another thread..), but I have an identical problem as the original poster - PagedGeometry just won't link, like so (part of the output, can't post it all):
1>PagedGeometry_d.lib(ImpostorPage.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported
1>PagedGeometry_d.lib(PropertyMaps.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported
1>PagedGeometry_d.lib(StaticBillboardSet.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported
1>PagedGeometry_d.lib(BatchedGeometry.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported
1>PagedGeometry_d.lib(TreeLoader2D.obj) : warning LNK4217: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported in function "public: void __thiscall Forests::TreeLoader2D::addTree(class Ogre::Entity *,class Ogre::Vector3 const &,class Ogre::Degree,float,void *)" (?addTree@TreeLoader2D@Forests@@QAEXPAVEntity@Ogre@@ABVVector3@4@VDegree@4@MPAX@Z)
1>PagedGeometry_d.lib(PagedGeometry.obj) : warning LNK4217: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported in function "public: __thiscall std::_Iterator_base::~_Iterator_base(void)" (??1_Iterator_base@std@@QAE@XZ)
1>PagedGeometry_d.lib(GrassLoader.obj) : warning LNK4217: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported in function "public: virtual void __thiscall Forests::GrassLoader::frameUpdate(void)" (?frameUpdate@GrassLoader@Forests@@UAEXXZ)
1>PagedGeometry_d.lib(BatchPage.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported
1>PagedGeometry_d.lib(ImpostorPage.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z (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 *)) imported
1>PagedGeometry_d.lib(PropertyMaps.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z (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 *)) imported
1>PagedGeometry_d.lib(StaticBillboardSet.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z (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 *)) imported
1>PagedGeometry_d.lib(BatchedGeometry.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z (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 *)) imported
1>PagedGeometry_d.lib(TreeLoader2D.obj) : warning LNK4217: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z (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 *)) imported in function "public: void __thiscall Forests::TreeLoader2D::addTree(class Ogre::Entity *,class Ogre::Vector3 const &,class Ogre::Degree,float,void *)" (?addTree@TreeLoader2D@Forests@@QAEXPAVEntity@Ogre@@ABVVector3@4@VDegree@4@MPAX@Z)
1>PagedGeometry_d.lib(PagedGeometry.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z (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 *)) imported

[...]

1>..\bin\Debug\Uruk_hai.exe : fatal error LNK1120: 23 unresolved externals


It worked fine up to now, but I can't build it any more since I, well, updated to Visual Studio 2010 Beta 2. I created a new project from scratch manually, same thing. I was hoping, if the issue was resolved, the original poster (or anyone else who had these errors) could reveal a possible solution. This was for Debug. For Release I get
1>LINK : fatal error C1047: The object or library file 'C:\Program Files (x86)\OgreSDK\PagedGeometry\lib\PagedGeometry.lib' was created with an older compiler than other objects; rebuild old objects and libraries
1>LINK : fatal error LNK1257: code generation failed


Most (or all) of these are probably because of incompatibilities between VS10 and older versions, and it's hard to expect any actual support for an IDE that's not even out yet, however if anybody has any ideas I'd be glad to hear them. For now I think it might be a good idea to rebuild PagedGeometry from sources as the linker suggested, so I'll try that...

Edit: False alarm. It seems rebuilding PagedGeometry under VC10 did the trick. I actually get access violations after the build right now, but these don't seem to have anything to the with the addon right now. I consider Pagedeometry VS 2010 approved :)