1

I have imported the fyne GUI , and now my GoLang compiler that there is an error imported the files because the build constraints.

I have tried cleaning out caches using commands from this post, which asks about VS Code in Windows, the same IDE and OS I am using:

build constraints exclude all Go files in

I made sure I had Gcc C compiler downloaded, which may have contributed to my problem.

I still got the following errors in my source code (with respective import statements)

// RecursivePlant.go package main // create Gui's import (

// "fmt"
"image"
"image/color"
"image/draw"
"image/png"
"math"
"os"
"time"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/widget"

)

"error while importing fyne.io/fyne/v2/app: build constraints exclude all Go files in C:\Users\geniu\go\pkg\mod\github.com\go-gl\gl@v0.0.0-20211210172815-726fda9656d6\v3.2-core\gl"

// RecursiveNoise.go package main

import ( "image" "image/color" "image/draw" "image/png" "math/rand" "os" "time" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/widget" )

"error while importing fyne.io/fyne/v2/app: build constraints exclude all Go files in C:\Users\geniu\go\pkg\mod\github.com\go-gl\gl@v0.0.0-20211210172815-726fda9656d6\v3.2-core\gl"

and the go.mod file:

module example.com/hello go 1.20 require fyne.io/fyne/v2 v2.3.5

with error message:

"error while importing fyne.io/fyne/v2/internal/painter/gl: build constraints exclude all Go files in C:\Users\geniu\go\pkg\mod\github.com\go-gl\gl@v0.0.0-20211210172815-726fda9656d6\v3.2-core\gl"

I have been studying up on build constraints but I am unclear on which constraint to use (based on operating system, compiler, development stage etc) and which files to but the build constraints in. I don't know which part of my go or fyne files have this problem.

  • Can you run `gcc` command on your cmd and say the output ? –  Jun 17 '23 at 11:26
  • COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe Target: mingw32 ...Build-2' Thread model: win32 gcc version 9.2.0 (MinGW.org GCC Build-2) – T. J. Foster Jun 17 '23 at 16:11
  • I had to abridge it a little bit – T. J. Foster Jun 17 '23 at 16:11
  • It looks like your gcc set up properly. Can you try this on your VScode terminal `CGO_ENABLED=1 go run main.go` replace `main.go` with your file name which one has main function then say the output if any. –  Jun 17 '23 at 17:12
  • Here is the output: PS C:\Users\geniu> CGO_ENABLED=1 go run RecursivePlant.go CGO_ENABLED=1 : The term 'CGO_ENABLED=1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + CGO_ENABLED=1 go run RecursivePlant.go + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (CGO_ENABLED=1:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException – T. J. Foster Jun 17 '23 at 22:59
  • The "build contraints" import errors are still there. Here is the result of putting it in the terminal. I did not put the instruction in the directory of my source code file. – T. J. Foster Jun 17 '23 at 23:02
  • Maybe there is a problem between gcc and VScode. I am not using Windows hence I can't say definite things. In my linux OS when I removed gcc and run an example code from fyne library, I got same error. You need run `CGO_ENABLED=1 go run main.go` from the directory where your file (which one has main function) located. Can you try it on the cmd ? not in the VScode. But before run that code please change the current directory to the directory which your file (which one has main function) including. –  Jun 17 '23 at 23:37
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/254128/discussion-between-t-j-foster-and-brokenarmor). – T. J. Foster Jun 18 '23 at 14:09

1 Answers1

0

You don’t need to “use” any constraints, it is all automatic Probably VSCode cannot find your C compiler. Typically this is because it is set up only on a different terminal (MSYS2 for example only configures it’s own window.

First try compiling from the place you set up the C compiler. Get that working (following our docs perhaps) then at leas you know the tools are all installed. https://developer.fyne.io/started/

andy.xyz
  • 2,567
  • 1
  • 13
  • 18
  • Where would "the place I set up the compiler" be. In my program files? I'm not sure exactly which file I need to put my source code into. Do I put it in the same directory as MinGW? MSYS2? – T. J. Foster Jun 18 '23 at 16:03
  • Nothing needs to be in the same folder… you just need to use the terminal in the setup docs to know if it’s working (follow the steps carefully). – andy.xyz Jun 19 '23 at 12:23
  • Once working you should just need to copy the environment variables over to your preferred console. Our docs don’t cover specifics for every configuration on Windows as sadly the OS can be a bit of a mess for development. – andy.xyz Jun 19 '23 at 12:23