Shane Bishop
Shane Bishop

Reputation: 4750

Unresolved external symbol errors for functions defined in tdh.h

I am getting the following linker errors when I compile my C Windows program:

(Link target) ->
  libossec.lib(read_win_trace_log.obj) : error LNK2001: unresolved external symbol TdhFormatProperty [C:\path\to\project.vcxproj]
  libossec.lib(read_win_trace_log.obj) : error LNK2001: unresolved external symbol TdhGetPropertySize [C:\path\to\project.vcxproj]
  libossec.lib(read_win_trace_log.obj) : error LNK2001: unresolved external symbol TdhGetEventInformation [C:\path\to\project.vcxproj]
  libossec.lib(read_win_trace_log.obj) : error LNK2001: unresolved external symbol TdhGetEventMapInformation [C:\path\to\project.vcxproj]
  libossec.lib(read_win_trace_log.obj) : error LNK2001: unresolved external symbol TdhGetProperty [C:\path\to\project.vcxproj]
  C:\Users\Administrator\src\lich\lichsrc\x64\Release\lich.exe : fatal error LNK1120: 5 unresolved externals [C:\path\to\project.vcxproj]

If necessary I can include my source code, but it is very large (the file is over 600 lines long).

I include tdh.h in my read_win_trace_log.c. I checked, and there are function prototypes for each of these functions in the tdh.h system header. So these linker errors shouldn't be because of any implicit function prototypes.

I looked at the tdh.h source code, and it already wraps everything in extern "C", so the code should be callable from my C code.

I compile using the Visual Studio compiler, but from the command line using a manually maintained .vcxproj file.

Is it possible I am missing a .lib or .dll that I need to link to build successfully?

Upvotes: 1

Views: 221

Answers (1)

Jabberwocky
Jabberwocky

Reputation: 50776

As documented here, in order to use the the functions in the tdh.h header, you need to link against the tdh.lib library.

Use the Project>Properties command and add tdh.lib as shown below:

enter image description here

Upvotes: 1

Related Questions