Skip to main content
GameDev.net gamedev.net
🔒 Locked

Static Library Errors

Started by AndOrXor Aug 15, 2004 at 6:40 PM 7 replies 850+ views
Original Post
AndOrXor
AndOrXor
I created a .lib file with VC++7, and a header file that declares the functions, and added the library to the project (I don't get a library not found error, so I added it correctly). Even though the library is there, I get this error:
project.obj : error LNK2019: unresolved external symbol _aoxCircle@12 referenced in function "void __stdcall DrawCircle(int)" (?DrawCircle@@YGXH@Z)
DJHoy
DJHoy
Might be a couple of different things...

first, make sure that the linker can find your .lib file (even though it's in the project, it might have problems) - go to the project properties, under "Linker" / "Input" and make sure to add your lib there under the Additional Dependencies, and also under "Linker"/"General", add the path to the lib's directory in the "Additional Library Directories" just to make sure...

The other thing to consider (and I've done this too many times myself) is to check what type of code generation was used - in the project that you used to create the lib, go to the project properties under "C/C++" / "Code Generation" and look at the value for "Runtime Library". Now, go back to your project that uses the library and check the Runtime Library value there... they should be the same - I've had problems with this in the past... it's not the problem all the time, but it's worth a shot to look at.
AndOrXor
AndOrXor
It's not the first one, because I put the library in the Library folder (that the compiler already looks in), and I called it in Additional Dependencies..

For the second one I found out that they weren't the same, but I made them both /MD and I still get the problem.
Hedos
Hedos
Try directly including all the required headers ( Well, at least the header in which _aoxCircle@12 should be defined ) in the source file where "void __stdcall DrawCircle(int)" is defined, in your library project.. Don't rely on other headers to include for you the specific header(s) you need for a specific file. I remember I had a similar problem with a library some time ago and directly including the correct header was the solution.
This might not be the problem, but at least it costs nothing to try ;)
Toolmaker
Toolmaker
Did you tell the linker to import the lib file into your project?

If not, add this to the main header file(Or just your main.cpp):

#ifdef _DEBUG    #pragma comment(lib, "ddwrap_d.lib")#else    #pragma comment(lib, "ddwrap.lib")#endif


The _DEBUG is there because I have a version with and without debug symbols. I also added the directory in which the lib file resides into the project settings(Like you did) and the same goes for the directory with the headers files.

Toolmaker
 
AndOrXor
AndOrXor
Sorry, neither of these have helped. I'm including standard OpenGL libraries fine, but I can't use my own.. I just don't understand..

in the library source I have:
void aoxCircle(arguments) {     //code}

and in the header for the library:
void aoxCircle(arguments);
Jedite
Jedite
try putting the library in a separate folder and adding it. besides that i couldnt think of anything that would be causing that problem. Ive written a couple of static libs and have had no problems adding them to my project. Aslong as the code generation was the same and they were in the correct directory and added to the aditional dependancies they should work fine..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.