sourcegraph / webloop

WebLoop: Scriptable, headless WebKit with a Go API. Like PhantomJS, but for Go.
https://sourcegraph.com/github.com/sourcegraph/webloop
BSD 3-Clause "New" or "Revised" License
1.37k stars 84 forks source link

Cannot build #16

Open mlb5000 opened 8 years ago

mlb5000 commented 8 years ago

I am running libgtk 3.12 in Ubuntu 14.04 and get the following when I do go get -tags gtk_3_12 github.com/sourcegraph/webloop/...

# github.com/sourcegraph/webloop/examples/angular-static-seo
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-587755410/000009.o: In function `removeClosure':
/tmp/go-build135241220/github.com/gotk3/gotk3/glib/_obj/_cgo_export.c:10: multiple definition of `removeClosure'
/tmp/go-link-587755410/000001.o:/tmp/go-build135241220/github.com/conformal/gotk3/glib/_obj/_cgo_export.c:10: first defined here
/tmp/go-link-587755410/000009.o: In function `goMarshal':
/tmp/go-build135241220/github.com/gotk3/gotk3/glib/_obj/_cgo_export.c:23: multiple definition of `goMarshal'
/tmp/go-link-587755410/000001.o:/tmp/go-build135241220/github.com/conformal/gotk3/glib/_obj/_cgo_export.c:23: first defined here
collect2: error: ld returned 1 exit status

# github.com/sourcegraph/webloop/cmd/static-reverse-proxy
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-852559976/000009.o: In function `removeClosure':
/tmp/go-build135241220/github.com/gotk3/gotk3/glib/_obj/_cgo_export.c:10: multiple definition of `removeClosure'
/tmp/go-link-852559976/000001.o:/tmp/go-build135241220/github.com/conformal/gotk3/glib/_obj/_cgo_export.c:10: first defined here
/tmp/go-link-852559976/000009.o: In function `goMarshal':
/tmp/go-build135241220/github.com/gotk3/gotk3/glib/_obj/_cgo_export.c:23: multiple definition of `goMarshal'
/tmp/go-link-852559976/000001.o:/tmp/go-build135241220/github.com/conformal/gotk3/glib/_obj/_cgo_export.c:23: first defined here
collect2: error: ld returned 1 exit status
mlb5000 commented 8 years ago

And if I just run go get github.com/sourcegraph/webloop/... I get

# github.com/gotk3/gotk3/gtk
could not determine kind of name for C.gtk_application_get_actions_for_accel
could not determine kind of name for C.gtk_application_get_menu_by_id
could not determine kind of name for C.gtk_application_prefers_app_menu

Do you have a recommended Linux configuration for this?

alexandervantrijffel commented 8 years ago

Same issue here on Ubuntu 15.10, I receive the gcc errors when I run go get github.com/sourcegraph/webloop/...

paultag commented 8 years ago

This will be fixed if https://github.com/sourcegraph/go-webkit2/pull/32 gets merged

mikluko commented 7 years ago

sourcegraph/go-webkit2#32 is merged by now and I'm able to successfully build go-webkit2. But building webloop throws same error:

$ go install -tags gtk_3_14 github.com/sourcegraph/webloop/...
# github.com/sourcegraph/webloop/cmd/static-reverse-proxy
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-934973757/000009.o: In function `removeClosure':
/tmp/go-build/github.com/gotk3/gotk3/glib/_obj/_cgo_export.c:18: multiple definition of `removeClosure'
/tmp/go-link-934973757/000001.o:/tmp/go-build/github.com/conformal/gotk3/glib/_obj/_cgo_export.c:18: first defined here
/tmp/go-link-934973757/000009.o: In function `goMarshal':
/tmp/go-build/github.com/gotk3/gotk3/glib/_obj/_cgo_export.c:35: multiple definition of `goMarshal'
/tmp/go-link-934973757/000001.o:/tmp/go-build/github.com/conformal/gotk3/glib/_obj/_cgo_export.c:35: first defined here
collect2: error: ld returned 1 exit status

# github.com/sourcegraph/webloop/examples/angular-static-seo
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-099896313/000009.o: In function `removeClosure':
/tmp/go-build/github.com/gotk3/gotk3/glib/_obj/_cgo_export.c:18: multiple definition of `removeClosure'
/tmp/go-link-099896313/000001.o:/tmp/go-build/github.com/conformal/gotk3/glib/_obj/_cgo_export.c:18: first defined here
/tmp/go-link-099896313/000009.o: In function `goMarshal':
/tmp/go-build/github.com/gotk3/gotk3/glib/_obj/_cgo_export.c:35: multiple definition of `goMarshal'
/tmp/go-link-099896313/000001.o:/tmp/go-build/github.com/conformal/gotk3/glib/_obj/_cgo_export.c:35: first defined here
collect2: error: ld returned 1 exit status

Running Debian 8.6 (Wheezy)

mikluko commented 7 years ago

~Probably related to upstream: gotk3/gotk3#116~

mikluko commented 7 years ago

I found that old gotk3 path is used in webloop while newer one is used in go-webkit2. So two copies of gotk3 were built causing this 'multiple definition' error. Build passes successfully once import path is fixed.

diff --git a/example_test.go b/example_test.go
index e93d5c1..20e2e8a 100644
--- a/example_test.go
+++ b/example_test.go
@@ -5,7 +5,7 @@ import (
        "os"
        "runtime"

-       "github.com/conformal/gotk3/gtk"
+       "github.com/gotk3/gotk3/gtk"
        "github.com/sourcegraph/webloop"
 )

diff --git a/static_renderer.go b/static_renderer.go
index 3ecb797..720c86c 100644
--- a/static_renderer.go
+++ b/static_renderer.go
@@ -8,7 +8,7 @@ import (
        "sync"
        "time"

-       "github.com/conformal/gotk3/gtk"
+       "github.com/gotk3/gotk3/gtk"
 )

 // StaticRenderer generates and returns static HTML based on a snapshot of a Web
diff --git a/webloop.go b/webloop.go
index a326681..4a65fdf 100644
--- a/webloop.go
+++ b/webloop.go
@@ -3,7 +3,7 @@ package webloop
 import (
        "errors"

-       "github.com/conformal/gotk3/glib"
+       "github.com/gotk3/gotk3/glib"
        "github.com/sourcegraph/go-webkit2/webkit2"
        "github.com/sqs/gojs"
 )
diff --git a/webloop_test.go b/webloop_test.go
index 4646897..a8100a1 100644
--- a/webloop_test.go
+++ b/webloop_test.go
@@ -7,7 +7,7 @@ import (
        "runtime"
        "testing"

-       "github.com/conformal/gotk3/gtk"
+       "github.com/gotk3/gotk3/gtk"
 )

 func init() {
xeoncross commented 7 years ago

Note, OSX needs both of these packages

brew install gtk+ gtk+3

And the missing-from-brew javascriptcoregtk as well:

# pkg-config --cflags javascriptcoregtk-3.0
Package javascriptcoregtk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `javascriptcoregtk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'javascriptcoregtk-3.0' found
pkg-config: exit status 1
ghost commented 7 years ago

Thanks @akabos and @canuckfan772 Finally got it working. I had to apt-get install libwebkit2gtk-4.0-dev instead of libwebkit2gtk-3.0-dev. Fixed import paths. And finally was able to build using tags as suggested in https://github.com/gotk3/gotk3/issues/152.