0

I downloaded webview and added this cmakelists file:

cmake_minimum_required(VERSION 3.17)
project(webview)

set(CMAKE_CXX_STANDARD 17)

include_directories(script/microsoft.web.webview2.1.0.664.37/build/native/include)

add_library(webview SHARED IMPORTED)
set_target_properties(webview PROPERTIES
        IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/dll/x64/webview.dll"
        IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/dll/x64/webview.lib" # not sure if this path is correct
        LINKER_LANGUAGE C
        )

add_library(WebView2Loader SHARED IMPORTED)
set_target_properties(WebView2Loader PROPERTIES
        IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/dll/x64/WebView2Loader.dll"
        IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/dll/x64/WebView2Loader.lib" # not sure if this path is correct
        LINKER_LANGUAGE C
        )


add_executable(webview_test main.cc)
target_link_libraries(webview_test PRIVATE webview WebView2Loader)

which results in this error:

====================[ Build | webviewt | Debug ]================================
cmake.exe --build webview\cmake-build-debug --target webview_test
Scanning dependencies of target webview_test
[ 50%] Building CXX object CMakeFiles/webview_test.dir/main.cc.obj
main.cc
NMAKE : fatal error U1073: don't know how to make 'webview-NOTFOUND'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64\nmake.exe"' : return code '0x2'

Does anyone know what the actual issue is here?

I'm trying to build the basic demo provided with the webview dll.

I've played around with various configs, and it either says it doesn't know how to make library, or it can't find a non-existent webview.lib.

I spoke to someone who said you need a lib in order to link with cmake - however there's no provided lib. Would I have to generate my own?

usually you say:

Heres the headers for the code and heres the static lib for linking while compiling the executable

I would think for a DLL itd be:

Here's the headers for the code and btw don't link anything its loaded at runtime

So why is a .lib necessary? All the knowledge I need is available in the headers - and everything links at runtime.

Tobi Akinyemi
  • 804
  • 1
  • 8
  • 24
  • 1
    A `.lib` is a static library, a `.dll` is a shared (dynamic) one. If you're missing the `.lib` and don't have a `.dll` maybe it's a build dependency you need to figure out how to generate. I'm not sure why you'd have both unless the `.lib` is some kind of stub that loads in the `.dll` somehow, or you get to pick if you want a static link or a dynamic one. – tadman Feb 11 '21 at 00:09
  • @tad On Windows you usually have an import library (.lib) when linking against a DLL. It is used by the linker to resolve imports and construct the respective import tables that go into the PE image. This is called compile-time dynamic linking and by far the most common way to link against DLL's on Windows. – IInspectable Feb 11 '21 at 06:50
  • When link with the IMPORTED library, the suffix `-NOTFOUND` in the error message usually means that required property with library location is not set. But your code sets both required properties, `IMPORTED_LOCATION` and `IMPORTED_IMPLIB`. Are you sure that the error message **corresponds** to the code you show? – Tsyvarev Feb 11 '21 at 07:10
  • @Tsyvarev `NMAKE : fatal error U1073: don't know how to make '..\dll\x64\webview.lib'` – Tobi Akinyemi Feb 12 '21 at 18:30
  • 1
    The error message means that you **incorrectly** specified the path to the `webview.lib`. We don't know where this file is located **on your machine**, so we cannot help you. – Tsyvarev Feb 12 '21 at 18:37
  • @Tsyvarev If you read the quesiton, I said it doesn't exist – Tobi Akinyemi Feb 12 '21 at 18:41
  • You cannot use the library without `.lib` file. See e.g. [that question](https://stackoverflow.com/questions/9360280/how-to-make-a-lib-file-when-have-a-dll-file-and-a-header-file) about the ways how to obtain it from `.dll`. – Tsyvarev Feb 12 '21 at 19:19

0 Answers0