I am new to windows and visual studio. I have to compile a code written in c++. It uses different libraries. I found the dll files for those lib开发者_StackOverflow中文版raries. I can compile the source without any problem but there are link problems. I do not know how to link dll files. I understood that I need .lib files for that. But some of the libraries required do not have any lib files provided. There are only dll files and dif files. How can I generate the required lib files by using Visual studio 2010 ultimate? I cannot find a program called lib.exe. Thank You.
You are indeed going to need lib.exe to turn the .def file into a .lib file that the linker needs. It is stored in the vc\bin directory of the visual studio directory, C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\lib.exe by default. The easiest way is to use the "Visual Studio Command Prompt", you'll find it in the Start menu, Microsoft Visual Studio 2010, Visual Studio Tools.
Next, run lib.exe with the /def:foo.def option to generate the .lib. Follow the vendor's instructions, if provided. And don't hesitate to contact them for support.
If you go to the project properties for the DLL and check Linker -> Advanced, there is an entry for 'Import Library'. You might have to set that to generate a lib file while building the DLL or if it is already set it should point you at the location of the lib file.
That said if you build the whole project using Visual Studio 2010, adding the dependent libraries in the project's Common Properties' Reference section should automatically trigger the necessary link statements.
This does require a lot of work, and usually it's easier to google for the source and/or libs for the DLL's you need, as it's a good idea to compile both libraries and your program with the same compiler (Makes deployment easier, so you aren't dependant on multiple vc runtimes).
You can use this guide to create the .lib files: http://support.microsoft.com/kb/131313
It is a process that takes time, as well as a lot of debugging (Depending on the size of the dll's as well as the complexity of the dll's interfaces)
Depending on your platform, the location is usually:
Windows 7 32-bit with 32-bit VS2010:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\
Windows 7 64-bit with 64-bit VS2010:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin`
Windows 7 64-bit with 32-bit VS2010:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\
However, if you start the Visual Studio Command Prompt, it should be in your path. (Look under Visual Studio Tools on your start-menu)
If you REALLY need to FIND lib.exe, I have a Python script that finds whatever you want in whatever semicolon-separated folder group.
import sys
import os
def select(a, b):
d = []
for c in a:
d.append(b(c))
return d
def multicheck(filename, folders_SEMICOLONSEPARATED):
folders = folders_SEMICOLONSEPARATED.split(";")
print("RESULTS:")
k = True
for f in folders:
try:
if filename.lower() in select(os.listdir(f), lambda k: k.lower()):
k = False
print(" " + os.path.join(f, filename))
except:
pass
if k:
print(" NONE")
if __name__ == "__main__":
multicheck(sys.argv[1], sys.argv[2])
In your case, use it like this (in VS Developer Command Prompt):
WHATEVER_YOU_CALL_IT.py lib.exe "%PATH%"
If you don't want to find it, just use it like this (in VS Developer Command Prompt):
LIB [options] [files]
精彩评论