Closed ghost closed 5 years ago
The directory IS there. Must be something else i am doing wrong ? Rerun the downloader already.
x-MacBook-Pro:simpleDemo apple$ ls -al /Users/apple/workspace/go/src/github.com/go-flutter-desktop/go-flutter/example/simpleDemo
total 1768
drwxr-xr-x 10 apple staff 320 Mar 20 08:49 .
drwxr-xr-x 4 apple staff 128 Mar 20 08:49 ..
drwxr-xr-x 7 apple staff 224 Mar 20 08:49 .build
-rw-r--r-- 1 apple staff 16 Mar 20 08:49 .gitignore
drwxr-xr-x 7 apple staff 224 Mar 20 08:49 FlutterEmbedder.framework
drwxr-xr-x 3 apple staff 96 Mar 20 08:49 assets
-rw-r--r-- 1 apple staff 8638 Mar 20 08:49 engineDownloader.go
drwxr-xr-x 3 apple staff 96 Mar 20 08:49 flutter_project
-rw-r--r-- 1 apple staff 883280 Mar 20 08:49 icudtl.dat
-rw-r--r-- 1 apple staff 3197 Mar 20 08:49 main.go
Can you try
export CGO_LDFLAGS="-F. -Wl,-rpath,@executable_path"
instead of
export CGO_LDFLAGS="-F${PWD} -Wl,-rpath,@executable_path"
(In the /Users/apple/workspace/go/src/github.com/go-flutter-desktop/go-flutter/example/simpleDemo
dir)
@Drakirus thanks for your help.
I got the same result using export CGO_LDFLAGS="-F. -Wl,-rpath,@executable_path"
clang: error: no such file or directory: '"-F.'
I am trying to automate this to finally build a standard magefile we can all use. Using Makefile for now to workout the flow.
a usr only need to run:
my current Makefile
# github.com/go-flutter-desktop/go-flutter
NAME=go-flutter
BRANCH=master
LIB=github.com/go-flutter-desktop/$(NAME)
LIB_FSPATH=$(GOPATH)/src/$(LIB)
FLU_EX=example/simpleDemo
FLU_EX_FSPATH=$(LIB_FSPATH)/$(FLU_EX)
print:
@echo
@echo NAME : $(NAME)
@echo BRANCH : $(BRANCH)
@echo LIB : $(LIB)
@echo LIB_FSPATH : $(LIB_FSPATH)
@echo
@echo FLU_EX :$(FLU_EX)
@echo FLU_EX_FSPATH : $(FLU_EX_FSPATH)
@echo
dep-all: dep-os dep dep-modules
# get all deps
dep-os:
# dev tools
go get github.com/cortesi/devd/cmd/devd
dep:
## install on gopath
mkdir -p $(LIB_FSPATH)
cd $(LIB_FSPATH) && cd .. && rm -rf $(NAME) && git clone https://$(LIB).git
# THIS IS WHERE THE CODE IS.
cd $(LIB_FSPATH) && git checkout $(BRANCH)
dep-status:
cd $(LIB_FSPATH) && git status
dep-modules:
# nil
code:
cd $(LIB_FSPATH) && code .
clean:
# gopath
rm -rf $(LIB_FSPATH)
### Build
qlog:
# for debugging...
tail -f $(TMPDIR)/q
flu-dep:
# grab the go flutter embedder
# Its in the simpleDemo folder ( dumb, but anyway)
cd $(FLU_EX_FSPATH) && go run engineDownloader.go
flu-mob-run: flu-dep
flutter emulators --launch apple_ios_simulator
cd $(FLU_EX_FSPATH) && flutter run
#export CGO_LDFLAGS="-F${FLU_EX_FSPATH} -Wl,-rpath,@executable_path"
export CGO_LDFLAGS="-F. -Wl,-rpath,@executable_path"
flu-desk-run:
# pub get
cd $(FLU_EX_FSPATH)/flutter_project/demo && flutter packages get
# go into standad Flutter project and run special bundler
cd $(FLU_EX_FSPATH)/flutter_project/demo && flutter build bundle
# Get the libraries
# REQUIRED before every `go build`. The CGO compiler need to know where to look for the share library
#export CGO_LDFLAGS="-F${PWD} -Wl,-rpath,@executable_path"
# The share library must stay next to the generated binary.
go get -u -v $(LIB)
# Build the example project
cd $(FLU_EX_FSPATH) && go build -v main.go
Does it work when you aren't using Make?
ok let me try using a .sh down in the dir. will take a few minutes
Ok so i made a run.sh that i just copy into the Demo directory from the Makefile
Make file:
flu-desk-run:
# pub get
cd $(FLU_EX_FSPATH)/flutter_project/demo && flutter packages get
# go into standard Flutter project and run special bundler
cd $(FLU_EX_FSPATH)/flutter_project/demo && flutter build bundle
# The share library must stay next to the generated binary.
go get -u -v $(LIB)
# Build the example project
cp run.sh $(FLU_EX_FSPATH) && chmod +x $(FLU_EX_FSPATH)/run.sh
cd $(FLU_EX_FSPATH) && go build main.go
run.sh file:
export CGO_LDFLAGS="-F. -Wl,-rpath,@executable_path"
go build main.go
shell log:
x-MacBook-Pro:simpleDemo apple$ ./run.sh
# github.com/go-flutter-desktop/go-flutter/embedder
ld: framework not found FlutterEmbedder
clang: error: linker command failed with exit code 1 (use -v to see invocation)
x-MacBook-Pro:simpleDemo apple$ pwd
/Users/apple/workspace/go/src/github.com/go-flutter-desktop/go-flutter/example/simpleDemo
x-MacBook-Pro:simpleDemo apple$ ls -al
total 1776
drwxr-xr-x 11 apple staff 352 20 Mar 10:47 .
drwxr-xr-x 4 apple staff 128 20 Mar 08:49 ..
drwxr-xr-x 7 apple staff 224 20 Mar 08:49 .build
-rw-r--r-- 1 apple staff 16 20 Mar 08:49 .gitignore
drwxr-xr-x 7 apple staff 224 20 Mar 08:49 FlutterEmbedder.framework
drwxr-xr-x 3 apple staff 96 20 Mar 08:49 assets
-rw-r--r-- 1 apple staff 8638 20 Mar 08:49 engineDownloader.go
drwxr-xr-x 3 apple staff 96 20 Mar 08:49 flutter_project
-rw-r--r-- 1 apple staff 883280 20 Mar 08:49 icudtl.dat
-rw-r--r-- 1 apple staff 3197 20 Mar 08:49 main.go
-rwxr-xr-x 1 apple staff 72 20 Mar 10:47 run.sh
Clang's framework search paths seems to ignore CGO_LDFLAGS="-F${PWD}"
.
Just like #34 (Windows case).
A quick and dirty solution would be to throw FlutterEmbedder.framework
file into /usr/local/lib
.
(Since we use -rpath,@executable_path
, /usr/local/lib/FlutterEmbedder.framework
will not be use at runtime)
Edit: The clang: error: no such file or directory: '"-F.'
error is related to Make.
thanks !
SO i got it working with CGO_LDFLAGS="-F${PWD}". on mac after all.
Now i can make the Magefile :)
But i like your idea of making CGO use the /usr/local/lib How will this affect deployment ? This will mean that when we package an a Mac OS package it will rely on FlutterEmbedder.framework existing in /usr/local/lib ?
SO i got it working with CGO_LDFLAGS="-F${PWD}". on mac after all.
Please share with us how you managed to fix the issue!!
How will this affect deployment ? This will mean that when we package an a Mac OS package it will rely on FlutterEmbedder.framework existing in /usr/local/lib ?
Again, Since we use -rpath,@executable_path
, the FlutterEmbedder.framework
located in /usr/local/lib
will only be used at compiling-time (when linking to be more precise).
More info at https://wincent.com/wiki/%40executable_path%2C_%40load_path_and_%40rpath and https://github.com/go-flutter-desktop/go-flutter/issues/34#issuecomment-442375520
I will share :). Just gotta finish the Mage file so its cross platform.
But it would be good to do it right, so i need to know about packaging. If i use /usr/local/lib, then when packaged and distributed then that directory will need to be there with the FlutterEmbedder.framework there ?
no
ok thanks. Will get back to you if i get everything working.
I got it all working.
@GeertJohan @Drakirus DO you want the Mage file ?
actually closing this because its relating to another issue. Will open a new one
Flutter version
Golang errors (Optional)
Steps to Reproduce