smasherprog / screen_capture_lite

cross platform screen/window capturing library
MIT License
638 stars 156 forks source link

Unresolved external symbol __imp__DwmGetWindowAttribute@16 when using .lib file on Windows. #67

Closed SASUPERNOVA closed 5 years ago

SASUPERNOVA commented 5 years ago

I have exported the library on a Windows machine, but when I try to use it, I get the following error: Error LNK2019 unresolved external symbol __imp__DwmGetWindowAttribute@16 referenced in function "struct SL::Screen_Capture::WindowDimensions __cdecl SL::Screen_Capture::GetWindowRect(struct HWND__ *)" (?GetWindowRect@Screen_Capture@SL@@YA?AUWindowDimensions@12@PAUHWND__@@@Z)

Steps to reproduce:

  1. Run cmake CMakeLists.txt to produce Visual Studio project.
  2. Open screen_capture_lite.sln (Using Visual Studio 2017).
  3. Right click on screen_capture_lite.vcxproj, and select Build.
  4. Create a new Console Application in Visual Studio.
  5. Add the include folder and the .lib file to the project directory of the Console Application.
  6. In Project Properties, add the include folder in C/C++>>General>>Additional Include Directories, and the .lib file in Linker>>Input>>Additional Dependencies.
  7. Add code that uses the library in main.cpp (I copied the createwindowgrabber() function, removing some parts like the call to setMouseChangeInterval() and invoked createwindowgrabber() in main(). I will post full code if deemed helpful).
  8. Attempt to compile.
SASUPERNOVA commented 5 years ago

Silly mistake on my part. I had to add the lib file in Linker>>General>>Additional Library Directories instead of Linker>>Input>>Additional Dependencies. After that, attemting to compile gives other linker errors though. I will open a new issue if it doesn't seem to be solvable.

SASUPERNOVA commented 5 years ago

Found out that the above procedure was pointless. All that has to be done was add Dwmapi.lib to Linker>>Input>>Additional Dependencies. Everything works properly now.

smasherprog commented 5 years ago

No problem. That library is added when you build using cmake

smasherprog commented 5 years ago

cmake build .