Lee
Lee

Reputation: 13

How to link dll and lib provided by other to c++ program

I have sample code with following file extension which are written in c++:

The sample code in .cpp is calling API in dll/lib file. My objective is to run the sample code in visual studio 2013 and see how it works. I need some guide on linking the dll or lib file.

I have created a c++ win32 console application in visual studio 2013 and place the cpp file under source file and .h file under header file But I am not sure how to link the dll and lib so that the sample code program can be run successfully

Note that I don't have the source code or implementation of the dll or lib.

Upvotes: 1

Views: 1521

Answers (2)

Dmytro Dadyka
Dmytro Dadyka

Reputation: 2260

  • .h Properties -> C/C++ -> General -> Additional Include Directories, put path to .h file
  • .dll The compiler does not need to know where this file is located. The main thing that it placed on the right path relative to the executable file. Usually in a folder with *.exe
  • .lib Properties -> Linker -> General -> Additional Library Directories , put path to .lib file. Then Linker -> Input-> Additional Dependencies, put .lib file name (without path)

Upvotes: 3

doctorlove
doctorlove

Reputation: 19282

If you right click on your project, and pick settings, there's a linker | input under the configuration properties.

Name you lib in the "Additional Dependencies" section. You might also need to state where it is in the "additional library directories" in the linker's general properties.

When you run the exe, the dll will need to be on the path or in the working directory.

Upvotes: 1

Related Questions