[SOLVED] Strange linker errors

PrdglSqrl

31-01-2008 22:50:02

I'll get right to it. Here are linker errors:

1>PagedGeometry_d.lib(GrassLoader.obj) : error LNK2005: "public: virtual __thiscall GrassPage::~GrassPage(void)" (??1GrassPage@@UAE@XZ) already defined in Seeder.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Seeder.obj : error LNK2019: unresolved external symbol "public: void __thiscall TreeLoader2D::addTree(class Ogre::Entity *,class Ogre::Vector2 const &,class Ogre::Degree,float)" (?addTree@TreeLoader2D@@QAEXPAVEntity@Ogre@@ABVVector2@3@VDegree@3@M@Z) referenced in function "public: void __thiscall MeshSeeder::addSeed(class Ogre::Entity *,float,float)" (?addSeed@MeshSeeder@@QAEXPAVEntity@Ogre@@MM@Z)
1>Seeder.obj : error LNK2019: unresolved external symbol "public: void __thiscall GrassLoader::updateAnimation(void)" (?updateAnimation@GrassLoader@@QAEXXZ) referenced in function "public: void __thiscall BillboardSeeder::update(void)" (?update@BillboardSeeder@@QAEXXZ)


This is what happens when I attempt to link against your library. I recently updated my version of Ogre from 1.4.5 to 1.4.6. I recompiled your addon and even tested the examples. They worked flawlessly. However, every time I attempt you use them in my own application, where I have copied the library files into my projects library directory, I recieve the above linker problems.

The first is especially weird, the way I interpret is as though I have redefined the deconstructor for your GrassPage class. Nowhere in my code do I do any such thing.

Now, the way I'm using the library is by wrapping the core functionality of it into classes I call Seeders. Here's the layout for my BillBoardSeeder class:

class BillboardSeeder{
private:
PagedGeometry* seeder;
GrassLoader* loader;
vector<bool> animated;
map<string, GrassLayer*> layers;

public:
BillboardSeeder();
BillboardSeeder(YEI3D* app, float pageSize, float cullDist);
~BillboardSeeder();
void init(YEI3D* app, float pageSize, float cullDist);
void destroy();
void update();
void reload();

GrassLayer* addLayer(string name, string mname);
GrassLayer* addLayer(string name, string mname, float minw, float minh, float maxw, float maxh, float density, FadeTechnique fadeTech, bool animated=true, float swaydist=1.0, float swaylen=1.0, float swayspd=1.0);
bool configureLayer(string name, float minw, float minh, float maxw, float maxh, float density, FadeTechnique fadeTech, bool animated=true, float swaydist=1.0, float swaylen=1.0, float swayspd=1.0);
void configureLayer(GrassLayer* layer, float minw, float minh, float maxw, float maxh, float density, FadeTechnique fadeTech, bool animated=true, float swaydist=1.0, float swaylen=1.0, float swayspd=1.0);
void setDensityMap(string name, string fname, TBounds bounds);
void setAnimated(string name, bool b);
void setHeightFunction(Real (*heightFunc)(Real, Real)){ loader->setHeightFunction(heightFunc); }
map<string, GrassLayer*> getLayers(){ return layers; }
};


The only place I use a GrassPage is in init(), which looks like this:

void BillboardSeeder::init(YEI3D* app, float pageSize, float cullDist){
seeder = new PagedGeometry(app->getCamera(), pageSize);
seeder->addDetailLevel<GrassPage>(cullDist);
loader = new GrassLoader(seeder);
seeder->setPageLoader(loader);
}


I can't see anything wrong with that, especially considering it all worked before I switched to the new version of Ogre. And since I made sure to recompile your library under the new version, and copy the .lib files, I can't think of what I've done wrong.

What do you think?

JohnJ

01-02-2008 01:33:14

I'm not exactly sure what's causing those linker errors, but a few people have had similar problems due to the linker settings not including PagedGeometry.lib. Did you make sure your linker "Additional Dependencies" includes "PagedGeometry.lib" and "Additional Library Directories" includes the PagedGeometry\lib folder?

BTW, it's usually best to not copy PagedGeometry's .lib files and instead point the linker directly to it as it is. This way when you update/recompile PagedGeometry, all projects using it will use the new version automatically.

PrdglSqrl

01-02-2008 16:12:19

I'm not exactly sure what's causing those linker errors, but a few people have had similar problems due to the linker settings not including PagedGeometry.lib. Did you make sure your linker "Additional Dependencies" includes "PagedGeometry.lib" and "Additional Library Directories" includes the PagedGeometry\lib folder?

Yeah, I double and triple checked. Even reordered the list of dependencies, but to no avail.

BTW, it's usually best to not copy PagedGeometry's .lib files and instead point the linker directly to it as it is. This way when you update/recompile PagedGeometry, all projects using it will use the new version automatically.

I was copying them because there are more than one person developing this project, and I figured having one common library directory would make managing the project between multiple developers easier. But after using Visual C++ and seeing what quirks and stuff we've had to follow, I would agree that we should just be linking it as you suggest.

So, I did as you suggested, but the linker errors remain there. I plan on recreating my project, but I have a gut feeling that won't be able to fix my current linking problems. I wish I knew of how to recreate this problem, as I'm sure you could debug this better than I could. But even still, any suggestions?

[EDIT]
I rerolled the entire project, adding things back piece by piece, and it works now! Hooray!
[/EDIT]

JohnJ

06-02-2008 21:55:07

Ok, glad to hear you got it working :)