0

Good Afternoon, so I have a question about including the aux_klib library in my Kernel Mode Driver, for some reason I get the same error for all aux_klib functions.

Error   1   error LNK2019: unresolved external symbol AuxKlibInitialize referenced in function "unsigned char __cdecl Main(struct MainInfo*)" (?MainInfo@@YAEPEAU__MainInfo@@@Z)

I did #pragma comment(lib, "aux_klib.lib") in my project and no luck, also the driver is coded in cpp. I also added the lib to my project and made sure it was x64 as that is the projects build architecture. I also tried including the function via extern "C" with out the header and just the lib but no luck, I also added all the library paths to the linker settings and what not. Any ideas are welcome!

  • for research this kind of error you need add linker option [/VERBOSE](https://msdn.microsoft.com/en-us/library/wdsk6as6.aspx) or how minimum `/VERBOSE:LIB` and view in output - are `aux_klib.lib` used by linker. *AuxKlibInitialize* exist in x64 version of *aux_klib.lib* – RbMm May 06 '17 at 11:14
  • I added /VERBOSE:LIB to my command lines options and its still the same linker error no added output, also I opened aux_klib.lib x64 in IDA and looked at the exports and they all seem to be there. – Opedn33 May 06 '17 at 15:59
  • 1
    this option of course not fix error, it for diagnostic. `no added output` - what you mean - are no any messages is printed by link ?! not believe. you use msvc for build ? use `/VERBOSE` and look for linker output - are he search for *aux_klib.lib* may be you used */nodefaultlib* option. in this case `#pragma comment(lib, "aux_klib.lib")` will be have no effect. you need direct add *aux_klib.lib* to linker input – RbMm May 06 '17 at 16:03
  • did as you said got rid of the /nodefaultlib and still same error no extra output http://prntscr.com/f4ttcc http://prntscr.com/f4ttgy http://prntscr.com/f4ttxt – Opedn33 May 06 '17 at 16:15
  • but are you add `/VERBOSE` ? in msvc - *Properties -> Linker -> General -> Show Progress* – RbMm May 06 '17 at 16:19
  • Still same result. – Opedn33 May 06 '17 at 16:25
  • in this case don't know what is going wrong , but when you really set /VERBOSE linker option - linker **must** print many additional information – RbMm May 06 '17 at 16:28
  • you can also remove *Properties -> Linker -> General -> Suppress Startup Bunner* - for view linker actual command line - are /VERBOSE exist in it ? – RbMm May 06 '17 at 16:30
  • http://prntscr.com/f4u0nn also supress startup banner is off, nothing changed xD – Opedn33 May 06 '17 at 16:33
  • don't know why linker output not shown for you. when i remove `/NOLOGO` and set `/VERBOSE` - i view many linker messages - `Linking...Microsoft (R) Incremental Linker Version .. Searching libraries..Finished searching libraries..` etc. why this not shown for you - hard to say – RbMm May 06 '17 at 16:41

2 Answers2

2
Properties->Linker->Input->Additional Dependencies add "AUX_KLIB.LIB"

This worked for me

0

I had the same problem with linking Aux_klib.lib, so I set /VERBOSE:Lib.

Right click on the project -> Properties -> Linker -> General -> Show Progress

As I understand it, For Libraries Searched /VERBOSE:Lib shows the libraries search and I've noticed that Aux_klib.lib is not in that search. And I noticed another thing in the output, /NODEFAULTLIB is passed in the command line as well.

As @RbMm says,

are he search for aux_klib.lib may be you used /nodefaultlib option. in this case #pragma comment(lib, "aux_klib.lib") will be have no effect.

So I changed Ignore All Default Libraries

Right click on the project -> Properties -> Linker -> Input -> Ignore All Default Libraries

to No and everything linked and compiled perfectly.

TL;DR

In short, try to change Ignore All Default Libraries under Linker to No and use #pragma comment(lib, "aux_klib.lib").

Mixone
  • 1,327
  • 1
  • 13
  • 24
Oriel Cochavi
  • 345
  • 1
  • 4
  • 12