Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

This does not compile... #7

Open
GordonBGood opened this issue Dec 3, 2024 · 11 comments
Open

This does not compile... #7

GordonBGood opened this issue Dec 3, 2024 · 11 comments

Comments

@GordonBGood
Copy link

The main webview repo directory no longer contains a webview.h file to be downloaded and used, but even if the new location of "core/include/webview" is used so it successfully downloads, it isn't complete for C code as there is no definition for the key webkit API functions for C although they appear in the header file; thus, the compilation completes successfully but the linking cannot because of these missing references...

@phildremi
Copy link

I believe this repository is obsolete? Maybe a notice could be added to redirect users to the C examples instead.
CC @SteffenL: It might be worth archiving the repo to make it immediately clear that this won't be maintained.

image

Also linking webview/webview#1225 for future reference.

@petabyt
Copy link
Collaborator

petabyt commented Dec 3, 2024

It's been a long time since I touched this, but it looks like the webview files have been moved, the source file is now core/src/webview.cc and the new headers are core/include/webview/webview.h

@SteffenL
Copy link

SteffenL commented Dec 3, 2024

webview.h was split into separate files in current master.

An amalgamated webview.h file can be generated (see readme) until the next release offers one (or use v0.12.0 for now). I'm inclined toward archiving this repository because it hasn't been updated along with the changes in the core library.

Although it shouldn't be difficult to update the code here, note that CMake can generate Makefiles if needed so that we don't have to focus too much on that.

This could of course still be an example for setting up a project with handwritten Makefiles, but I'm not personally invested in maintaining this.

For these reasons I would not object to the idea of archiving this repo. @petabyt, what's your stance on that?

@GordonBGood
Copy link
Author

@phildremi, it does indeed look like this repository is obsolete, although it does give a hint in the Makefile as to what one needs to do: the webview library needs to be compiled with a C++ compiler, which can then be linked with the sample C files. Since it is only adds more confusion for the most part, I think it should likely be archived as you suggest, with better documentation in the main webview repository as to how to use C code, both with and without CMake...

@petabyt, When this used to work, it looks like the old version of the webview.h file that was "wget"ed must have been all-inclusive as containing both the headers and the implementation for the webview API functions. Thus, it wouldn't be easy to fix this other than by using the technique that @SteffenL suggested in the 1225# issue for the main repo. In short, it wouldn't be enough just to correct the locations of the C headers, but a separate compilation of the C++ webview library needs to be done...

@petabyt
Copy link
Collaborator

petabyt commented Dec 3, 2024

The whole point of this repo as I remember it was to show a minimal example for how to compile webview and an example into a binary with incremental compilation. At the time the webview repo only had single line commands with examples that included webview.h, which took 2-3 seconds to compile.

If this or a similar example can be moved into the webview repo I think we can delete/archive this.

@SteffenL
Copy link

SteffenL commented Dec 3, 2024

The main repo's readme file has a minimal example for C and CMake, and supports incremental builds out of the box.

The minimal example in the readme doesn't set up any bindings (maybe it should) but a more elaborate example is available in the repo.

If we update the main repo's readme example to include a call to webview_bind() then I believe it would essentially be the same as the example in this repo.

@SteffenL
Copy link

SteffenL commented Dec 3, 2024

@GordonBGood That could be a good addition under the "Non-CMake Usage" section of the main repo's readme.

@phildremi
Copy link

I'm not invested in a decision either way. I simply figured it would be pragmatic to focus on examples/docs in the core repo. As for the docs, I'm happy to improve the README. But is a "DIY" build something that needs to be supported officially? As Steffen mentioned, it's expected to build the library with a C++ compiler and the C API is the "official" way to use it [from C].

Obviously, users are free to build as they please. But anything that isn't tested via CI would be difficult to support, IMHO.

@GordonBGood
Copy link
Author

@petabyt,

The whole point of this repo as I remember it was to show a minimal example for how to compile webview and an example into a binary with incremental compilation...

I think that was a good goal, but just hasn't kept up to the changes in the main repository in splitting the header file. I think that showing a minimal way to compile might still be a good goal...

@SteffenL,

If we update the main repo's readme example to include a call to webview_bind() then I believe it would essentially be the same as the example in this repo.

At first I thought that this suggestion along with increasing the "Non-CMake Usage" addition you suggest above would be enough, but then I thought about the case where users would want to use a completely new project (like this repo) that doesn't include the main repository, in which case (with or without a Make file) would need to be something as follows:

git clone https://github.com/webview/webview.git subprojects/webview
g++ -c subprojects/webview/core/src/webview.cc -O2 --std=c++11 -Isubprojects/webview/core/include $(pkg-config --cflags gtk4 webkitgtk-6.0) -DWEBVIEW_STATIC -o webview.o
gcc main.c webview.o --std=c99 -O2 -Isubprojects/webview/core/include $(pkg-config --cflags --libs gtk4 webkitgtk-6.0) -ldl -lstdc++ -o basic_example

for a static build and as follows for a shared build:

git clone https://github.com/webview/webview.git subprojects/webview
mkdir build
g++ --shared -fPIC subprojects/webview/core/src/webview.cc -O2 --std=c++11 -Isubprojects/webview/core/include $(pkg-config --cflags --libs gtk4 webkitgtk-6.0) -ldl -DWEBVIEW_BUILD_SHARED -o build/libwebview.so
gcc main.c -O2 --std=c99 -Isubprojects/webview/core/include -DWEBVIEW_SHARED build/libwebview.so -o build/main

with only the last command of each needing to be executed for an "incremental build" after the library has been built.

Note that the above two method both work for the current master "webview.h" split file without amalgamating, so amalgamation isn't a requirement...

Of course, this can be done with and without the CMake/Make build processes, and could be filled out with the equivalent methods for all (three?) of the supported platforms. Eventually it would be nice if this were extended to be able to call webviews for mobile apps on Android and iOS as well.

If this were done, this becomes an independent example of how a new C or C++ project could use the main webview library repo, and perhaps the information in the main repo README becomes redundant and could just link here.

@SteffenL
Copy link

SteffenL commented Dec 5, 2024

The readme file should be clear about its requirements and have all the information needed to customize and build it, but preferably without concerning itself too much with compiler details and all the different build systems that exist out there.

My wish is for that to be enough for anyone to use their basic knowledge on compiling code with their preferred compiler and build system.

CMake was picked as a first-class supported build system to improve convenience for everyone (library developers and consumers) as it's one of the most widely used build systems. Since it can generate Makefiles, Visual Studio solutions and what-not, I would still prefer to not refer people anywhere else (i.e. different repos).

I would either make adjustments to this repo in order to make it clear that it's a minimal example specifically for Make, or simply archive it.

@petabyt
Copy link
Collaborator

petabyt commented Dec 5, 2024

I'll archive it. I stopped using webview years ago and won't be using it again or working on it. Feel free to delete it too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants