ImVexed / muon

GPU based Electron on a diet
MIT License
2.89k stars 65 forks source link

tutorial doesn't launch app on macOS #55

Open shakfu opened 2 years ago

shakfu commented 2 years ago

I went to the end of the tutorial and complete building the executable successfully, but the executable fails with an Reason: image not found error, basically failing to link to the dylib even though it is copied to the folder in which it resides:

$ pwd
$HOME/Downloads/src/muon/examples/create-react-app

create-react-app $ ls
README.md                    libglib-2.0.dylib@
b0x.yml                      libgmodule-2.0.0.dylib
cra-go*                      libgmodule-2.0.dylib@
go.mod                       libgobject-2.0.0.dylib
go.sum                       libgobject-2.0.dylib@
libAppCore.dylib             libgstreamer-full-1.0.dylib
libUltralight.dylib          libgthread-2.0.0.dylib
libUltralightCore.dylib      libgthread-2.0.dylib@
libWebCore.dylib             main.go
libgio-2.0.0.dylib           public/
libgio-2.0.dylib@            webfiles/
libglib-2.0.0.dylib

create-react-app $ ./cra-go
dyld: Library not loaded: @rpath/libUltralightCore.dylib
  Referenced from: $HOME/Downloads/src/muon/examples/create-react-app/./cra-go
  Reason: image not found
Abort trap: 6

create-react-app $ otool -L cra-go
cra-go:
    @rpath/libUltralightCore.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libWebCore.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libUltralight.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libAppCore.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1677.104.0)
    /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 59306.140.5)

create-react-app $ otool -L libUltralightCore.dylib
libUltralightCore.dylib:
    @rpath/libUltralightCore.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

I resolved this by the following

$ export DYLD_LIBRARY_PATH=$PWD

but running ./cra-go after that produces no error but does nothing

Any idea what the issue is?

ImVexed commented 2 years ago

Does using go build -ldflags "-r ." have any effect?

shakfu commented 2 years ago

Thanks for your advice.

After deleting cra-go and running go build -ldflags "-r ." I get the cra-go as above: running it does nothing. or it runs and then closes (without explicit errors).

is there any way to switch on logging in cra-go?

sha0urya commented 1 year ago

To enable logging in your Go program (cra-go in this case), you can use the log package in Go to print information to the console or write it to a file. Here's a simple example of how you can integrate logging in your

Go code: -

  1. Import the log package at the beginning of your Go file:

Go code :-

import ( "log" )

  1. Add logging statements at relevant places in your code. For example, you can use log.Println:

Go code :-

func main() { log.Println("Starting cra-go...") // Your existing code... log.Println("Exiting cra-go.") }

  1. Run your program, and you should see log statements printed to the console.

If the program runs and then closes without explicit errors, adding logging statements can help you trace the execution flow and identify where it might be encountering issues. You can include log statements in functions, loops, or any part of your code that you suspect might be causing the problem.

After adding logging, re-run your program and check the console output for any log messages. These messages can provide insights into the program's behavior and help you identify the root cause of the issue.

I hope that this will work in your case.