webview / webview

Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows).

Home Page:https://webview.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fatal error: JavaScriptCore/JavaScript.h: No such file or directory

InfernalAzazel opened this issue · comments

What OS are you using (uname -a, or Windows version)?

Linux hzh57001u 5.15.0-78-generic #85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

What programming language are you using (C/C++/Go/Rust)?

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

python 3.10

What did you expect to see and what you saw instead?

// webview_pybind.cpp

#include <pybind11/pybind11.h>
#include "webview.h"

namespace py = pybind11; 

PYBIND11_MODULE(webview, m) {

  m.doc() = "pybind11 binding for webview"; 

  py::class_<webview_t>(m, "WebView")
    .def("create", &webview_create, "webview_create")
    .def("destroy", &webview_destroy, "webview_destroy")
    .def("run", &webview_run, "webview_run")
    .def("terminate", &webview_terminate, "webview_terminate")
    .def("dispatch", &webview_dispatch, "webview_dispatch")
    .def("get_window", &webview_get_window, "webview_get_window")
    .def("set_title", &webview_set_title, "webview_set_title")
    .def("set_size", &webview_set_size, "webview_set_size")
    .def("navigate", &webview_navigate, "webview_navigate")
    .def("set_html", &webview_set_html, "webview_set_html")
    .def("init", &webview_init, "webview_init")
    .def("eval", &webview_eval, "webview_eval")
    .def("bind", &webview_bind, "webview_bind")
    .def("unbind", &webview_unbind, "webview_unbind")
    .def("return", &webview_return, "webview_return");

  // 返回库版本信息
  m.def("version", &webview_version, "webview_version");

}

compile

c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes)  webview_pybind.cpp -o webview$(python3-config --extension-suffix)

error

extittivns03@hzh57001u:/work/code/github/pywy$ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes)  webview_pybind.cpp -o webview$(python3-config --extension-suffix)
In file included from webview_pybind.cpp:4:
webview.h:508:10: fatal error: JavaScriptCore/JavaScript.h: No such file or directory
  508 | #include <JavaScriptCore/JavaScript.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I'm not going to comment the Python-specific parts because it's outside the scope of the core library, but it seems like you're missing the compiler and linker parameters for GTK and WebKitGTK.

See the project readme and in particular how these commands are used:

  • pkg-config --cflags gtk+-3.0 webkit2gtk-4.0
  • pkg-config --libs gtk+-3.0 webkit2gtk-4.0

I successfully made the modifications based on it

c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes)  webview_pybind.cpp -o webview$(python3-config --extension-suffix) $(pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0)

What OS are you using (uname -a, or Windows version)?

Linux hzh57001u 5.15.0-78-generic #85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

What programming language are you using (C/C++/Go/Rust)?

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin

python 3.10

What did you expect to see and what you saw instead?

// webview_pybind.cpp

#include <pybind11/pybind11.h>
#include "webview.h"

PYBIND11_MODULE(webview, m) {

  m.doc() = "pybind11 binding for webview"; 

  py::class_<webview_t>(m, "WebView")
    .def("create", &webview_create, "webview_create")
    .def("destroy", &webview_destroy, "webview_destroy")
    .def("run", &webview_run, "webview_run")
    .def("terminate", &webview_terminate, "webview_terminate")
    .def("dispatch", &webview_dispatch, "webview_dispatch")
    .def("get_window", &webview_get_window, "webview_get_window")
    .def("set_title", &webview_set_title, "webview_set_title")
    .def("set_size", &webview_set_size, "webview_set_size")
    .def("navigate", &webview_navigate, "webview_navigate")
    .def("set_html", &webview_set_html, "webview_set_html")
    .def("init", &webview_init, "webview_init")
    .def("eval", &webview_eval, "webview_eval")
    .def("bind", &webview_bind, "webview_bind")
    .def("unbind", &webview_unbind, "webview_unbind")
    .def("return", &webview_return, "webview_return");

  // 返回库版本信息
  m.def("version", &webview_version, "webview_version");

}

compile

c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes)  webview_pybind.cpp -o webview$(python3-config --extension-suffix)

error

extittivns03@hzh57001u:/work/code/github/pywy$ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes)  webview_pybind.cpp -o webview$(python3-config --extension-suffix)
In file included from webview_pybind.cpp:4:
webview.h:508:10: fatal error: JavaScriptCore/JavaScript.h: No such file or directory
  508 | #include <JavaScriptCore/JavaScript.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.