skm
skm

Reputation: 5649

Search for the Library/Header file where a method is declared

I have to use the libraries provided by a camera manufacturer in my project. I am using Visual Studio 2015. I have incorporated all the header files suggested by VS 2015 after writing #include.

I have specified the path of include files and libraries in VS 2015 and it is able to find most of the methods.

Problem: When I compile my code, I get a following linker error :

Error LNK2019 unresolved external symbol "public: unsigned int __cdecl LvModule::GetInt32(unsigned int,int *)" (?GetInt32@LvModule@@QEAAIIPEAH@Z) referenced in function "public: void __cdecl CCamera::CloseCamera(void)" (?CloseCamera@CCamera@@QEAAXXZ) ImageProcessingSidd C:Path\ImageProcessing.obj 1

Question: How can I search in my system the header file/Library where the method GetInt32() has been defined. I have seen somebody before searching for header file by using some command like kgrab (not sure about the exact command)

Upvotes: 2

Views: 367

Answers (2)

abelenky
abelenky

Reputation: 64682

To search Libraries, you'll first want to open a "Visual Studio Command Prompt" (look in the Start Menu near where Visual Studio is installed)

As an initial demonstration, run the command on just one library to see what comes out:

dumpbin mfc120.lib /exports

(must be run from the directory that actually holds that library)

Then run the program dumpbin like this:

dumpbin *.lib /exports | findstr "LvModule::GetInt32"

Run the command in any directory where the missing library might be found.

That will search through all exported functions in the libraries in the current directory and find any reference to LvModule::GetInt32.

You'll have to continue your research from there to find out if it is exactly the missing function you need, but its a good starting point.


TL;DR: dumpbin is good for looking in libraries.


Why do I have to write your scripts for you?
Do you even program?

Program: SearchFor.bat %1

@echo off
@for /F "delims=;" %%a in ('dir \*.lib /B /S') do call :SearchText "%%a" %1
exit /B

:SearchText
dumpbin %1 /exports | findstr %2 > NUL
if NOT ERRORLEVEL 1 echo MATCH IN %1
exit /B

Run this as:

C:\>SearchFor LvModule::GetInt32

Upvotes: 1

Serge Ballesta
Serge Ballesta

Reputation: 148890

Well, my advice would be RTFM!

More seriously, MSDN documentation always gives the header and library where an API function lies, and so do all decent libraries.

I can see in the posted error LvModule and CCamera references. I assume they come from a library and that you know what library they come from. You should then identify to what product those references belong, and look where and how it is installed on your machine, and how the functions are documented.

Of course, you can also search for every lib and dll file on your disk and use dumpbin to identify what symbols they declare, but personnally I prefere first way.

Upvotes: 0

Related Questions