0

I am working on creating a kernel driver for Windows 10 (x64) using Visual Studio 2019 with their KMDF template, but I ran into the following error.

Severity    Code    Description Project File    Line    Suppression State
Error   LNK1120 1 unresolved externals  Assisted    C:\Users\me\source\repos\Assisted\x64\Release\Assisted.sys  1   
Error   LNK2001 unresolved external symbol _fltused Assisted    C:\Users\me\source\repos\Assisted\Driver.obj    1   

After looking this up I found this on it Example but I am still not sure how to fix this. I have made drivers in the past with the same template, and I have never gotten this error before. I also found This regarding this issue but it was posted over a decade ago so I don't know how to use his 2010 Vs fix in the 2019 version or even know if it will even work.

Edit: I was suggested to use the following "fix" however this does not work either because I now get an error saying its already defined in my obj file.

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2005 _fltused already defined in Driver.obj  AssistedC:\Users\me\source\repos\Assisted\Moufilter.obj 1   
Error   LNK1169 one or more multiply defined symbols found  Assisted    C:\Users\me\source\repos\Assisted\x64\Release\Assisted.sys  1   
  • Please don't post errors from "Error List", post them from "Output". – 273K Apr 30 '23 at 03:38
  • Make sure that all objects and user libraries that participate in the link are compiled with the same /M[TD] option. – 273K Apr 30 '23 at 03:40
  • @273K Not sure what that means people often don't like images, so I just copied both errors and thats out they are copied. Also what do you mean by the same /M[TD] option what is that and where would I specify that? – IgnoreExeption Apr 30 '23 at 04:26
  • @273K Ok I found it which option should my driver have out of the 4? Also what should other dll's and static libraries use because by default those use ``/MD`` but I have no idea about what drivers use. – IgnoreExeption Apr 30 '23 at 07:25
  • https://stackoverflow.com/a/1583220/6401656 – RbMm Apr 30 '23 at 09:18
  • @RbMm Nope that does not work either when I try to include that code, I get new errors specified in my updated post. – IgnoreExeption Apr 30 '23 at 10:05
  • where you declare `_fltused` ? in header and include it to several files ?! – RbMm Apr 30 '23 at 11:12
  • @RbMm Yes, I tried all possible permutations of adding it to my header files and every possibility caused errors. – IgnoreExeption Apr 30 '23 at 20:18
  • this is not true. try think yourself - if you include definition only to single file - let be Driver.c - from where it in Moufilter.c ? – RbMm Apr 30 '23 at 21:39
  • @RbMm I dont understand what you are trying to say. It does not matter where I define it or how many files, I define it in I still get errors. I tried defining it in headers and in the C files. I have tried doing each individually and then tried combinations of adding that statement and I still get errors no matter what I do. I tried numerous configuration but I always get errors. – IgnoreExeption Apr 30 '23 at 22:28
  • symbol can not be defined in obj if you not define it src file, from which this obj was build. create asm output and look – RbMm Apr 30 '23 at 23:40
  • @RbMm No the issue is when I add the code specified in that fix it says that variable is already defined. I already tried to add the code to my src driver file along with others without any luck. I also doubt I will be able to find the issue looking at the assembly. There must be a simple fix for this otherwise everyone would have this issue because all I did was start up a new project from Visual Studio's built in kernel template. – IgnoreExeption May 01 '23 at 00:49
  • no, you need use [/FAs](https://learn.microsoft.com/en-us/cpp/build/reference/fa-fa-listing-file?view=msvc-170) for understand how and where this symbol defined – RbMm May 01 '23 at 01:04
  • @RbMm Alright I read that article, but my driver does not create asm files. That being said I looked through my project's properties and inside of C/C++ I found that ``Assembler Output`` is set to No Listing by default and the ``Use Unicode For Assembler Listing`` setting is blank. What exactly should I change these default settings to in order to fix my error? – IgnoreExeption May 01 '23 at 04:24

0 Answers0