Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newbie! How to use #1

Open
kylepritchard opened this issue Sep 28, 2023 · 7 comments
Open

Newbie! How to use #1

kylepritchard opened this issue Sep 28, 2023 · 7 comments

Comments

@kylepritchard
Copy link

I am new to D and would like to convert an existing project which uses webview to D. I am wondering how to use this library, specifically linking. I have tried compiling webview to object file and linking but cannot get it to work. Do you have any basic guidelines?

@thechampagne
Copy link
Owner

In basic you can find working example that link to libweview.so.

@thechampagne
Copy link
Owner

If you want to link with object instead of library you need to place the object file in source directory and change

libs "webview"

to

sourceFiles "source/webview.o"
libs "stdc++" "gtk+-3.0" "webkit2gtk-4.0"

In dub.sdl.

@kylepritchard
Copy link
Author

I managed to get it working just before your reply. Using windows PC so was able to include the library locally and link through dub.

I am struggling with binding functions to the webview instance. Do you have any examples of how that can be done?

@thechampagne
Copy link
Owner

Do you mean how to use this function ?

void bind(string name, BindCallback fn, void* arg);

@kylepritchard
Copy link
Author

Yes, i cant ever seem to get the signature of the function correct and I believe a context is required whilst program is running according to webview docs

@thechampagne
Copy link
Owner

extern(C) void callBack(string seq, string req, void* arg)
{
 // code
}

w.bind("name", &callBack, null);

@gitgit3
Copy link

gitgit3 commented Jun 24, 2024

I didn't find this thread until after I got webview working. I did things differently. After downloading the webview project, I ran the build.sh in webview/script. This built webview.o as well as libwebview.so in the webview/build/ directory.

Then, since I an using dub.json, I appended the following property which allows the linker to find the lib:
"libs": ["$PACKAGE_DIR/libs/webview/build/library/libwebview.so"]

It seems like $PACKAGE_DIR is your project root where the dub.json file is located.

Hope that helps someone!

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

No branches or pull requests

3 participants