How to add a static library to my project in Visual Studio ( Static Linking )

There are several ways to include/link a static library into a project and it seems that you're trying to mix some of them.

1. Create a Solution that contains both your static library project and the application project. This is what the article is talking about. Then you can open the References and you should be able to see the static library project.

Another options is :

1. Go to the "C/C++ - General - Additional Include directories" and add the path to your static libraries header files. Then, got to the "Linker / General / Additional Library Directories" and add the path to the static librarys .lib files.

2a. Go to "Linker / Input / Additional Dependencies" and add all the .lib files you need. ( Ex. MyLib.lib )

2b. Instead of step 2a you can use the #pragma comment(lib, "...")statement in you code file:

#pragma comment(lib, "yourstaticlib.lib")

Theres also a referece in msdn under the location http://msdn2.microsoft.com/en-us/library/ms235627.aspx

Check for the libraries , if theres any exception errors check for the function , thrown by the exception. This functions implementation

should be present in some lib which must be also added to the settings in Visual Studio

Ex :

// this is defined in a header file... lets call it ExportMe.h

#ifndef _EXPORT_ME_H_
#define _EXPORT_ME_H_

class __declspec( dllexport ) ExportMe
{
public:
  void SetExportMeInt( int n );

private:
  int m_nExportMeInt;

};

#endif // _EXPORT_ME_H_

// this is defined in the implementation file... lets call it ExportMe.cpp

void ExportMe::SetExportMeInt( int n )
{
  m_nExportMeInt = n;
}
#include "ExportMe.h"  // export me has not been changed in anyway from the above

#pragam comment( lib, "ExportMe.lib" )

void main( )
{
  ExportMe em;
  em.SetExportMeInt(69);
}

How to create and add a Dynamic Library in a project DLL

http://msdn2.microsoft.com/en-us/library/ms235636.aspx

Note :"Add Reference" is for adding a .NET object or a COM object. Both are
packaged (usually) as a DLL. However, they are very special DLL files. A
"regular" DLL is simply a library that is linked by the linker to your C++
compiled code.

But if the Project ( creating DLL ) and Project ( testing/using dll ) remain in Same Solution

then using Add Reference will work.

Addionally

To execute the program "prog.exe" Windows needs to have leda_<opt>.dll in its search path for DLL's. Therefore, you need to do one of the following.

 

 

Hosted by www.Geocities.ws

1