g++: error: unrecognized command-line option '-mthreads'; did you mean '-pthread'?
vboehr opened this issue · 6 comments
Describe the bug:
As I try to compile a fyne app that contains c++ code using fyne-cross I get the error:
g++: error: unrecognized command-line option '-mthreads'; did you mean '-pthread'?
To Reproduce:
Steps to reproduce the behaviour:
in some repo that require c++
fyne-cross windows -arch=amd64
Device and debug info (please complete the following information):
- OS: Linux
- Version: Ubuntu
I tried to add c++ compiler as follows:
fyne-cross windows -arch=amd64 -env="CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CXX=/usr/bin/x86_64-w64-mingw32-g++"
but it does not work
I am not entirely sure to which extent C++ code even is supported within CGo. Have you gotten the code to compile and work correctly locally?
Yes it works locally. The repo that I am trying to compile is this one:
https://github.com/wetorrent/wetorrent
The c++ code that causes the error is:
https://github.com/anacrolix/go-libutp
g++: error: unrecognized command line option '-mthreads'; did you mean '-pthread'?
It even builds locally with no error.
@vboehr if you could provide a small example use go-libutp, I will give it a look. I think that you might also need to build your own image with Docker that add your C++ dependency cross compiled in it so that we can do the linking, but considering the error you are reporting, it seems that we are not setting the C++ compiler correctly to start with.
It might be of interest to have some sample Dockerfile showing how to do add your own native dependencies. Maybe an example section in the new fyne-cross-image repository?
Unfortunately x86_64-w64-mingw32-g++
is not available into the docker image so setting the CXX won't work.
As pointed out by @Bluebugs extending the windows docker image installing the g++-mingw-w64-x86-64
package along with any additional dependency could solve.
Alternatively you could give a try at the new docker images available for testing here: fyne-io/fyne-cross-images#1.