Open yayi2456 opened 4 years ago
I have same problem with simple code blow.
package garia2
// typedef int (*intFunc) ();
//
// int
// bridge_int_func(intFunc f)
// {
// return f();
// }
//
// int fortytwo()
// {
// return 42;
// }
import "C"
import (
"fmt"
"os"
"github.com/lxn/walk"
"github.com/lxn/walk/declarative"
)
type toolMainWindow struct {
*walk.MainWindow
}
// Start main
func Start() {
f := C.intFunc(C.fortytwo)
fmt.Println(int(C.bridge_int_func(f)))
var edit *walk.LineEdit // main
mw := &toolMainWindow{}
MW := declarative.MainWindow{
AssignTo: &mw.MainWindow,
Title: "Tools Ver:2019100801",
MinSize: declarative.Size{Width: 150, Height: 200},
Size: declarative.Size{Width: 500, Height: 250},
Layout: declarative.VBox{},
Children: []declarative.Widget{
declarative.LineEdit{
AssignTo: &edit,
},
declarative.PushButton{
Text: "Test1",
OnClicked: func() {
path := edit.Text()
if len(path) > 0 {
walk.MsgBox(mw, "Test1", "Test1 Over",
walk.MsgBoxIconError)
} else {
walk.MsgBox(mw, "Test1", "Test1 Over",
walk.MsgBoxIconError)
}
},
},
},
}
if _, err := MW.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
UPDATE:
I found that as long as I import a package looks like github.com/username/reponame
in the example clipboard, TTM_ADDTOOL failed occured.
for example:
//this is ok in clipboard
import (
"fmt"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
but if I import another github.com/username/reponame
to the file,which looks like:
//TTM_ADDTOOL failed in clipboard
import (
"fmt"
"github.com/myname/myrepo"//added
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
TTM_ADDTOOL failed occured.
You have to use rsrc tool to generate rsrc.syso file from the clipboard.exe.manifest file. Put a clipboard.exe.manifest in the directory will work without cgo but will get TTM_ADDTOOL error when build with cgo
I'm running the example 'clipborad' with my cgo code, a
C.Type
variable and aprint
statement to print the address of the variable, added to get variables calculated in C.Although I used the
go build -tags walk_use_cgo
command to build my code, the following errors would occur when I ran the executable program.Same error occured when I run other walk programs with cgo code in. I did not modify the manifest file
clipboard.exe.manifest
.Why does this happen?What can I do to fix it? Thank you for your reply.