LINK : fatal error LNK1104: cannot open file 'OgreMain.lib'

Problems building or running the engine, queries about how to use features etc.
EGD Eric
Halfling
Posts: 41
Joined: Mon Dec 13, 2004 4:07 pm
Location: St. Bruno, Quebec, Canada

Post by EGD Eric »

So I think you're confused about the difference between compiling and running.
No, I know the difference. If I get an error, that's a compiler error. If I get something screwy happening in the program, like a thrown exception, or some message box saying that it couldn't find a certain dll, that's a runtime thing. I just used the word "Runtime" for this particular runtime error because it had the acronym: CRT in it. I thought it stood for "check run-time", because it said something about that in the C++.net documentation about that error.

Well, I did skim over the porting notes, and there were lots of things that seemed irrelevant to my problem, so I kept skimming.
Standard Windows procedure is that DLLs are found either in the working directory of the executable or on your PATH, as specified by the environment variable. So either put the folder with your Ogre DLLs in it on you PATH, or just copy your executable to the folder with OgreMain_d.dll and all the other Ogre DLLs in it, i.e. ogrenew/Samples/Common/bin/Debug
Wow, you just said a mouthfull. Alot of that I didn't completely understand. To simplify things for now, I just decided to copy/paste the OgreMain dlls into the project folder. Now the error message changes to: "cannot find zlib1.dll" when running the app. I've done a search in the whole OgreNew folder and found no zlib.dll, just a zlib.h.

In case you want to know, the parts I didn't understand are the following:
"environment variable". I've searched alot to find info on this, but I couldn't make heads or tails of any of it.

What's this "PATH" thing?

Copy your executable to the folder with the dll? You mean the executable that's produced when the program is built?
User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia
Contact:

Post by monster »

Space error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
Trust me, this is a linker error. That's why the error number is prefixed by LNK.

From the MSVC Help;
Linker Tools Error LNK2019
unresolved external symbol 'symbol' referenced in function 'function'

An undefined external symbol (symbol) was found in function. To resolve this error, provide a definition for symbol or remove the code that references it.

In Visual C++ .NET 2003, this error will be generated when /clr is used and the CRT is not linked into your executable. Any object code generated by the compiler that is not built with /clr:initialAppDomain contains a reference to the, etc, etc...
What's this "PATH" thing?
http://www.vlaurie.com/computers2/Artic ... onment.htm

On my machine (XP) I go to Start -> Control Panel -> System -> Advanced -> Environment Variables. And there you can see (and set) your PATH. Or just go to a command prompt and type "echo %PATH%", or "echo $PATH" on any Unix-alike.

The zlib1.dll library should be in your ogrenew\Samples\Common\bin\Debug and Release folders. If it's not, then you haven't extracted the Dependencies correctly. I know it's in OgreDependencies_VC71_1.0.0RC1.zip because I've just checked. Dunno about the version you downloaded.
Copy your executable to the folder with the dll? You mean the executable that's produced when the program is built?
Yes. The executable that you want to execute.
EGD Eric
Halfling
Posts: 41
Joined: Mon Dec 13, 2004 4:07 pm
Location: St. Bruno, Quebec, Canada

Post by EGD Eric »

Ok, thank you very much for your help (and patience). I didn't mess around with that PATH windows thing-didn't want to screw anything up. If I set the output file (the exe) to be put in the same directory as the output file, then it had no trouble finding the .dll file (like you said).

Oh, and the zlib.dll wasn't there because I did not extract the dependencies folder properly. All I did was take the dependencies folder from the .zip (using Winrar) and dumped it into the OgreNew folder. This time, I extracted it properly, and everything was there.

Another problem I had, once the dlls were findable, was that the application would throw an exception, not being able to find the resources.cfg file, yet it would run when I went to where the exe was and double-clicked it, but not when pressing the "run" button in Visual Studio. So, I changed the working directory to be the same as the output file's directory. I figured that out by comparing this project to another one that worked in the previous Ogre version.

thank you again 8)
Post Reply