-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot cross-compile a project using go-webui #42
Comments
After much digging, there was some progress. Turns out, Linux cross-compilation does not tolerate using upper case in LDFLAGS, since while Windows filesystems might not be case-sensitive, Linux filesystems which the MinGW libraries are installed to are. Editing |
...which is solved by adding |
What is your goal? Statically linked against libwebui? Or dynamically linked? I'm cross-compiling with a statically linked libwebui-2-static.a without any issues using ming32-64. I haven't tried dynamically linked yet (although that should work just fine too). |
I don't know if it's the correct way to cross-compile, but I'm having a similar problem, I'm trying to compile from Linux to Windows with the following command that I constructed from this thread:
but i'm getting these errors, seems to be the same as OP stated here:
and the list is pretty big too. |
That is not required. There's no C++ involved unless you're doing some C++ FFI in your Go code.
You haven't told the linker that you want to link against libwebui and where your Windows copy of the libwebui library is located. You will typically need to tell the linker manually like so (using static linking as per your example):
NOTE that libwebui also depends on COM on Windows and you will need to explicitly tell the linker to link against ole32.dll for COM like so:
|
Description
Let me start by saying that I'm not sure this is actually a bug, but if anything, it's something insufficiently documented...
Assume a naive example project I plan to build for Windows while running under Linux. Simply running the setup.sh script as described in README produces no useful results:
I'm trying to patch the library in by making a local copy as described here:
At this point,
go build
produces a native binary that runs. Which is nice, but cross-compilation is mission critical (and the reason I picked Go for this project in the first place), so...$ GOOS=windows GOARCH=amd64 go build .... imports github.com/webui-dev/go-webui/v2: build constraints exclude all Go files in ...
Not big surprise here, because that's only supposed to work on projects not making use of
cgo
. Ok, let's try it with explicitly invokingcgo
...$ GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CXX=x86_64-w32-mingw32-g++ CC=x86_64-w64-mingw32-gcc go build -v ... /usr/lib/go-1.22/pkg/tool/linux_amd64/link: running x86_64-w64-mingw32-gcc failed: exit status 1 /usr/bin/x86_64-w64-mingw32-ld: cannot find -lWs2_32: No such file or directory /usr/bin/x86_64-w64-mingw32-ld: cannot find -lOle32: No such file or directory /usr/bin/x86_64-w64-mingw32-ld: cannot find -lAdvapi32: No such file or directory /usr/bin/x86_64-w64-mingw32-ld: cannot find -lShell32: No such file or directory /usr/bin/x86_64-w64-mingw32-ld: cannot find -lUser32: No such file or directory
Now this is quite cryptic, and googling does not appear to produce any clues on what could possibly be wrong. Initially I assumed I just had a misconfigured
mingw32
or something, but then I tryxgo
(https://github.com/techknowlogick/xgo) which is supposed, in theory, to take care of everything for me, and carries everything inside a docker image:Notice the identical error message. Which suggests the problem is somewhere in go-webui...
Expected Behavior
I do expect cross-compilation to work or a statement that it isn't supported to be present in the documentation.
Reproduction Steps
No response
Error Logs
No response
Possible Solution
No response
Version
2.4.3
Environment Details (OS name, version, etc.)
The text was updated successfully, but these errors were encountered: