Jump to content
  • Advertisement
Sign in to follow this  
Magician_Lord

Simple static library creation/usage question (C++ .NET)

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I'm trying to replace my .cpp files with a .lib one but there seems to be a small problem. Here is the example code: //FILE - main.h #include "aClass.h" void main() { aClass aClassInstance; } //FILE - main.cpp #include "main.h" //FILE - aClass.h class aClass { public: aClass(); }; //FILE - aClass.cpp #include "Stdafx.h" #include "aClass.h" aClass::aClass() { //Do something } I have turned the aClass.cpp file into a .lib file using a class library project. I have put it into a Lib directory and the aClass.h into a Inc directory and made both directories accessible to the project. The project only includes the main.cpp and .h files currently. The error I get when I try to compile is the following: LibTest error LNK2019: unresolved external symbol "public: __thiscall aClass::aClass(void)" (??0aClass@@QAE@XZ) referenced in function _main I have no idea why this happens so any help would be appreciated. Maybe I need to change any of the other automatically created files? (stdafx.h etc.) Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Hello and thanks for the reply. I don't think so, I just include the path that contains the .h and .lib file in the VC++ Directories...Looking at the solution explorer the project currently only has the .h file in the Header files list and the .cpp Source files list. I don't know how I can add a .lib file to a project...

Thanks

Share this post


Link to post
Share on other sites
Go to your project properites, under linker / input / additional dependencies, add the name of your .lib file.

Share this post


Link to post
Share on other sites
Thanks again, unfortunately the problem remains.
I put "MyLib.h" (exact directory information necessary?) in the field you mentioned but it now it just says:

LibTest error LNK2001: unresolved external symbol __CorExeMain@0

My project is a Win32 console application BTW.

Thanks

Share this post


Link to post
Share on other sites
I meant that I actually did put "MyLib.lib" in the field but it gives me the error:

LibTest error LNK2001: unresolved external symbol __CorExeMain@0

thanks

Share this post


Link to post
Share on other sites
That sounds like your project is set to build as a .NET framework application instead of a normal Win32 console application.

Share this post


Link to post
Share on other sites
Well when I create the new project I choose New Project - Win32 Project - Console Application - Empty Project so it should be ok right?

Still how can I check how it is set to build?

Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!