[solved] Linking Problem LNK2001 with irrAn8Loader

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
Lunacore
Posts: 18
Joined: Sun May 30, 2010 4:01 pm
Location: Berlin (Germany)

[solved] Linking Problem LNK2001 with irrAn8Loader

Post by Lunacore »

Hello community

I want to use an8-Models from anim8or in my programm. For this I try irrAn8Loader from http://texel3d.free.fr/projets/liban8/index.html.
I use Microsoft Visual Studio 2008. There I link Irrlicht.lib and the include-folder from Irrlicht 1.7.1 and at the top of my code i include one header file which include also irrlicht.h:

Code: Select all

#include<irrAn8Loader.h> //includes irrlicht.h
While compiling, is get the following errors:

Code: Select all

1>main.obj : error LNK2001: unresolved external symbol ""public: virtual __thiscall irr::scene::irrAn8Loader::~irrAn8Loader(void)" (??1irrAn8Loader@scene@irr@@UAE@XZ)".
1>main.obj : error LNK2001: unresolved external symbol ""public: __thiscall irr::scene::irrAn8Loader::irrAn8Loader(class irr::scene::ISceneManager *,class irr::io::IFileSystem *)" (??0irrAn8Loader@scene@irr@@QAE@PAVISceneManager@12@PAVIFileSystem@io@2@@Z)".
Both errors refers to the following codes:

Code: Select all

class irrAn8Loader : public IMeshLoader
{
public:
	irrAn8Loader(scene::ISceneManager* smgr, io::IFileSystem* fs);
	~irrAn8Loader();
	virtual bool isALoadableFileExtension(const io::path& fileName) const;
	virtual IAnimatedMesh* createMesh(io::IReadFile* file);
private:
	void AddMesh(SMesh* am,An8File* aniFile,int meshID,AN8XMATRIX* matrix);
	scene::ISceneManager* SceneManager;
	io::IFileSystem* FileSystem;
};

irrAn8Loader::irrAn8Loader(scene::ISceneManager* smgr, io::IFileSystem* fs) : SceneManager(smgr), FileSystem(fs)
{
	if (FileSystem)	FileSystem->grab();
}

//! destructor
irrAn8Loader::~irrAn8Loader()
{
	if (FileSystem)	FileSystem->drop();
}

I have the suspicion that is something wrong with FileSystem, only those both functions use it and generate errors.
After 6 hours I give up searching for a troubleshooting. Did I missed something, should I include some other files or how can I get solved this problem?

Greetings Lunacore
Last edited by Lunacore on Sun May 30, 2010 11:52 pm, edited 1 time in total.
Viz_Fuerte
Posts: 91
Joined: Sun Oct 19, 2008 5:29 pm
Location: Valencia (Spain)
Contact:

Post by Viz_Fuerte »

It seems that the problem is simple, I think :?

In (??1irrAn8Loader@scene@irr@@UAE@XZ), for example, refers to a namespace that supposedly is not written in the code that you have shown.

Try writing this and compile it at the beginning of the code:

Code: Select all

using namespace irr;
using namespace scene;
Or, write this at the beginning and end of the code that you have shown:

Code: Select all

namespace irr
{
namespace scene
{
.................
.................
} // end namespace scene
} // end namespace irr
Lunacore
Posts: 18
Joined: Sun May 30, 2010 4:01 pm
Location: Berlin (Germany)

Post by Lunacore »

I write all namespaces in my code, I don't wrote it here for less text.
I include everything I found before. My code looks like the following:

Code: Select all

#include <irrAn8Loader.h> //include Irrlicht.h
#include <iostream>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

int main()
{
	...
	// Add an8loader
	irrAn8Loader loaderAn8(smgr,device->getFileSystem());
	smgr->addExternalMeshLoader(&loaderAn8);
	...
}
Headerfiles start also with

Code: Select all

namespace irr
{
namespace scene
{
...................
} // end namespace scene
} // end namespace irr
so this isn't the problem. Any other suggestions?

€dit:
After many hours I solved the problem. The linking error occurs, when class functions are declared in a header-file, but are written in an extra cpp-file. I wrote them into the header-file. I also include the 4 lib-files from libAn8 into the project with the pragma-command.

Code: Select all

	#ifdef _IRR_WINDOWS_
	#pragma comment(lib, "Irrlicht.lib") //Irrlicht-Bibliothek einfügen
	#pragma comment(lib, "liban8_MD.lib")
	#pragma comment(lib, "liban8_MDd.lib")
	#pragma comment(lib, "liban8_MT.lib")
	#pragma comment(lib, "liban8_MTd.lib")
	#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") //kein Konsolenfenster
	#endif
Then I had everytime the problem that I can't load an8-files, it seemed that the file-extension was still not acceptet. So I changed the extension-check.

Code: Select all

bool irrAn8Loader::isALoadableFileExtension(const c8* fileName) const
{
	//return strstr(fileName, ".an8");
        return true;
}
I know, it's important to check, if it is a legal file, but I use only an8-files, so I don't need the check. Now I'm so happy for loading an8-files. :D
Post Reply