I am trying to statically compile a go application using Qt and run it on a computer without Go or Qt installed.
At the top of my main.go I have:
// #cgo LDFLAGS: -static -L/Users/$USER/Qt/5.7.0_static_osx/lib -lgb
//go:generate genqrc ui
I have static compiled my application using:
go generate && go build -a -installsuffix cgo
The go generate compiles the .qml files into the binary while as I understand it go build -a -installsuffix cgo statically compiles all the .go and .a files from Qt.
I am using go version go1.8 darwin/amd64 and I have 5.7.0_static_osx Qt in my /Users/$USER/Qt folder and in the /lib folder I have all the .a files
I am using OSX 10.11.6 (El Capitan)
Now the issue is when I move it to another mac I get the error:
/Users/$USER/Downloads/PACKAGED.app/Contents/Resources
AppSettings.plist
MainMenu.nib
appIcon.icns
PACKAGEDAPP
script
dyld: Library not loaded: /usr/local/opt/qt5/lib/QtWidgets.framework/Versions/5/QtWidgets
Referenced from: /Users/$USER/Downloads/PACKAGED.app/Contents/Resources/./encryptoclient
Reason: Incompatible library version: encryptoclient requires version 5.7.0 or later, but QtWidgets provides version 5.4.0
/Users/$USER/Downloads/PACKAGED.app/Contents/Resources/script: line 5: 9987 Trace/BPT trap: 5 ./encryptoclient
Which makes me think that Qt wasn't statically compiled, is this so? And if so, what do I need to do to compile properly?
P.S (FYI) Its in a .app because I have wrapped it in a Platypus app to make moving and running on other computer an easy 'double-click' off the USB stick
Related
In the OpenBLAS root directory on a linux system, with emcc sdk already loaded by (in the emsdk directory, source ./emsdk_env.sh)
I was trying to use emcc to compile OpenBLAS by
make CC=emcc NOFORTRAN=1 HOSTCC=emcc BINARY=64 libs,
but it complained about cpuid.S.
I understand that it was a assembly file, so instead, I also tried to use clang:
make CC="clang --target=wasm32" NOFORTRAN=1 HOSTCC=clang BINARY=64 libs.
Then I got an error saying:
fatal error: error in backend: 64-bit WebAssembly (wasm64) is not
currently supported.
Does this mean that, one cannot use OpenBLAS to create a .a lib for static linking for Webassembly x64 usage? Has anybody got luck on similar usage? Thanks in advance!
I am using clang version 10.0.0, emcc version 1.39.13, and openBLAS latest code (0.3.9.dev.a).
I'm trying to cross compile (from Arch Linux to Windows) a go binary with the openal library statically linked.
I use MinGW to cross compile to Windows and to MinGW package I have install and intend to use to link the static libary is mingw-w64-openal.
My build command looks like this:
CC='i686-w64-mingw32-gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -lssp' GOOS=windows CGO_ENABLED=1 GOARCH=386 go build --ldflags '--extldflags "-static"' -v -o bin/game.exe -tags='deploy' game.go
The .go files (linked below) that is using the library has the following cgo code to lookup the static library for MinGW to use:
#cgo windows LDFLAGS: /usr/i686-w64-mingw32/lib/libOpenAL32.dll.a
I get no errors during compilation but when I try run the binary file on windows I get the typical The program can't start because OpenAL32.dll is missing error. I want a completely portable executable so redistributing the .dll with the executable won't do.
The go openal package that I've modified to compile to windows:
https://github.com/golang/mobile/blob/master/exp/audio/al/al_notandroid.go
https://github.com/golang/mobile/blob/master/exp/audio/al/alc_notandroid.go
Following my earlier question, now I'm getting this error when trying to perform all the same steps from this article, since I've upgraded from Go 1.6.1 to Go 1.7.1 (I cannot go back to Go 1.6.1 because the linker crashes when tries to compile some shared libraries).
What I did:
Installed go in ~/.go/go (this is later referred to as GOROOT).
Compiled libstd.so:
GOROOT=~/.go/go GOPATH=~/tests go install -buildmode=shared -linkshared std
Compiled calc library:
GOROOT=~/.go/go GOPATH=~/tests go install -a -x -buildmode=shared -linkshared calc
Tried to compile app:
GOROOT=~/.go/go GOPATH=~/tests go build -a -x -linkshared -o app cashier
and received this error:
~/.go/go/pkg/tool/linux_amd64/link: cannot implicitly include runtime/cgo in a shared library
I tried to repeat the steps with CGO_ENABLED=0 prepended to the environment, but nothing would build this way. Giving me this error:
imports runtime/cgo: C source files not allowed when not using cgo or SWIG: gcc_fatalf.c gcc_linux_amd64.c gcc_mmap.c gcc_util.c
Is this a known bug? Is making shared libraries meant to be supported?
The only way I've been able to make working DLLs is to use buildmode=c-archive and write C stubs for all the go functions I want to export. But I was working on Windows for this, I haven't had to mess with this on Linux. It is a path to investigate.
I have an application coded in c# using the Mono Framework and GTK# for UI.Im trying to create a static bundle for MacOSX (including gtk# and mono runtime)
I just bundled Mono with my exe file using
mkbundle --static hello.exe -o --deps hello2.exe
I got the exe file but when i drag it and put it on the terminal i get System.DllNotFound Exception:glibsharpglue-2
I understand that i need to include the gtk# libraries.But i dont know how to do that with a statically linked mono runtime.Is there an option to do that using mkbundle.All i need to get is a final standalone package ready to run on Mac.
Please help me out.
UPDATE:
The shell script I'm currently using with Platypus to make the .app package
export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:$DYLD_FALLBACK_LIBRARY_PATH:/usr/lib"
exec /Library/Frameworks/Mono.framework/Versions/Current/bin/mono myapp.exe
Im currently using the option provided in platypus to include myapp.exe file.How can i include the dlls required for GTK? Please help me out.
The error is from not finding the GTK shared object libraries (SO/dylib).
Using mkbundle:
If using 32-bit Mono you will need to assign the arch type for AS and CC. By default, clang will compile and link x86_64 which may not match your installed Mono's arch type.
export AS="as -arch i386"
export CC="cc -arch i386 -framework CoreFoundation -lobjc -liconv"
mkbundle gtkdesigner.exe --deps -o gtkdemo
The resulting executable will still require Mono (and any dependant shared objects/dylibs) to be installed.
Or adding --static to statically link to mono libs and thus invoking the LGPL of Mono (you will need to distribute your original CIL images so the user can upgrade the version of Mono that is running your app, unless you have a license from Xamarin)
mkbundle --static gtkdesigner.exe --deps -o gtkdemo
The resulting executable will not require Mono to be installed, but any dependant shared objects/dylibs will still be required.
GTK/GTK# based applications:
A GTK# based application will still require the GTK shared objects/dylibs to be installed and accessible by the resulting executable (i.e. gtkdemo in this case):
Thus if you try to run ./gtkdemo it will need to find shared libraries such as libc.dylib, libgtksharpglue-2.so, etc, etc... otherwise the error you are getting will be shown.
Set the dylib library path to your GTK libraries, not the C# CIL binding library (GTK#), but the native shared object libraries. Since you have Mono installed on OS-X, it also installs its own version of GTK that can be found at /Library/Frameworks/Mono.framework/Versions/Current/lib. If you are installing your own version GTK to a different location just change the path to that location. You also will be to include the location of the OS's std C library.
export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:/usr/lib"
./gtkdemo
Note: You can package this gtkdemo application into a normal OS-X app by using a packager tool such as http://sveinbjorn.org/platypus. Package all the GTK libraries and any other required so/dylibs into the app and provide a shell script that assigns the DYLIB path in order to find those app based GTK libs. Then you can distribute the self-contained app and the end-user just double-clicks it to run you GTK-based app.
Since gkt# is an open-source library why not download the code?
You would need to install git and do:
git clone https://github.com/mono/gtk-sharp
Then, you can reference those donwloaded gtk-sharp projects directly in your solution.
Note: i believe you still need the native OSXs gtk libraries since gtk-sharp is a wrapper of those libs.
I am trying to cross-compile a project for the iOS (which is written in windows) and is based on openCV. And then I am trying to use these cross-compiled openCV libs for a specific application (called testApp).
I was first able to successfully cross-compile openCV for the iOS. Then I used these libraries to created another library called testLib.a which was consumed by an application testApp (which also used some openCV functionality).
The testLib.a compiled successfully but, for the testApp I had to add dependency to both testLib.a and the openCV libs (.a files). When I try to compile testApp, I get the following error -
ld: duplicate symbol cv::split(cv::Mat const&, cv::Mat*) in
/Users/suri/Projects/testLib/lib/Debug/libopencv_core.a(convert.o) and
/Users/suri/Projects/testApp/libs/testLib.a(convert.o) for
architecture i386
I can see that this error is probably coming because the openCV libs are added by open testLib as well as testApp. My question is should I try and reorganize the project or is there some other way to fix this issue?
I tried to find where the "split" function might actually be used in testLib but it does not seem to be called. Also, I have checked and every .h in the testLib as well as testApp and they all have a "ifndef" macro.