Golang OpenGL Error PlatformError: X11: The DISPLAY environment variable is missing panic: NotInitialized:...
I just cannot seem to get opengl with golang to work. I wanted to try out golang but it has been such a pain to even set up, and now I can't get something I copy pasted off of this website. Here is the code I am using: (from the website). I did these two commands before running it (using wsl on windows):
go get github.com/go-gl/gl/v4.1-core/gl
go get github.com/go-gl/glfw/v3.2/glfw
And this is the full error I am getting:
2018/11/21 13:43:33 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized
goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.2/glfw.acceptError(0x0, 0x0, 0x0, 0x1, 0xc000099ee0)
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:173 +0x1d1
github.com/go-gl/glfw/v3.2/glfw.panicError()
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:184 +0x32
github.com/go-gl/glfw/v3.2/glfw.WindowHint(0x20003, 0x0)
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/window.go:235 +0x38
main.initGlfw(0x4ded35)
/home/oriont/dev/super g/main.go:71 +0x54
main.main()
/home/oriont/dev/super g/main.go:45 +0x2b
exit status 2
And if you are curious, my go env:
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oriont/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oriont/dev"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.11"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.11/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build854283259=/tmp/go-build -gno-record-gcc-switches"
Any help would be appreciated, thanks!
EDIT:
Now I am getting a new error, after reinstalling go and removing a failed attempt at sdl2 (from apt-get remove).
(OLD) This is the new error:
# _/home/oriont/dev/super_g
/usr/lib/go-1.11/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lXrandr
collect2: error: ld returned 1 exit status
I have all of the same code still. Also, I did try to run 'go build' but it just threw the exact same error as 'go run main.go'.
EDIT 2:
I reinstalled go 1.11.2 and installed the libglfw3 and libglfw3-dev packages on sudo apt-get install. Now, I have the same old error.
bash ubuntu go opengl
add a comment |
I just cannot seem to get opengl with golang to work. I wanted to try out golang but it has been such a pain to even set up, and now I can't get something I copy pasted off of this website. Here is the code I am using: (from the website). I did these two commands before running it (using wsl on windows):
go get github.com/go-gl/gl/v4.1-core/gl
go get github.com/go-gl/glfw/v3.2/glfw
And this is the full error I am getting:
2018/11/21 13:43:33 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized
goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.2/glfw.acceptError(0x0, 0x0, 0x0, 0x1, 0xc000099ee0)
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:173 +0x1d1
github.com/go-gl/glfw/v3.2/glfw.panicError()
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:184 +0x32
github.com/go-gl/glfw/v3.2/glfw.WindowHint(0x20003, 0x0)
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/window.go:235 +0x38
main.initGlfw(0x4ded35)
/home/oriont/dev/super g/main.go:71 +0x54
main.main()
/home/oriont/dev/super g/main.go:45 +0x2b
exit status 2
And if you are curious, my go env:
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oriont/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oriont/dev"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.11"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.11/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build854283259=/tmp/go-build -gno-record-gcc-switches"
Any help would be appreciated, thanks!
EDIT:
Now I am getting a new error, after reinstalling go and removing a failed attempt at sdl2 (from apt-get remove).
(OLD) This is the new error:
# _/home/oriont/dev/super_g
/usr/lib/go-1.11/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lXrandr
collect2: error: ld returned 1 exit status
I have all of the same code still. Also, I did try to run 'go build' but it just threw the exact same error as 'go run main.go'.
EDIT 2:
I reinstalled go 1.11.2 and installed the libglfw3 and libglfw3-dev packages on sudo apt-get install. Now, I have the same old error.
bash ubuntu go opengl
1
First try to 'echo $DISPLAY' to check if the variable is there, then try 'export DISPLAY', then run your program.
– Seaskyways
Nov 21 '18 at 22:24
1
When I run 'echo $DISPLAY', a blank line shows up. I tried 'export DISPLAY' and ran my program, and I got the same error. After that, I echoed it again and it was still a blank line.
– oriont
Nov 21 '18 at 22:31
1
Are you running as root or using su ? How are you building your program ?
– Seaskyways
Nov 21 '18 at 22:40
1
I am using 'go run main.go', with main.go containing all my code. I just tried 'sudo go run main.go' with the same result.
– oriont
Nov 21 '18 at 22:50
1
Try go build, then execute the resulting executable
– Seaskyways
Nov 21 '18 at 23:07
add a comment |
I just cannot seem to get opengl with golang to work. I wanted to try out golang but it has been such a pain to even set up, and now I can't get something I copy pasted off of this website. Here is the code I am using: (from the website). I did these two commands before running it (using wsl on windows):
go get github.com/go-gl/gl/v4.1-core/gl
go get github.com/go-gl/glfw/v3.2/glfw
And this is the full error I am getting:
2018/11/21 13:43:33 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized
goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.2/glfw.acceptError(0x0, 0x0, 0x0, 0x1, 0xc000099ee0)
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:173 +0x1d1
github.com/go-gl/glfw/v3.2/glfw.panicError()
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:184 +0x32
github.com/go-gl/glfw/v3.2/glfw.WindowHint(0x20003, 0x0)
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/window.go:235 +0x38
main.initGlfw(0x4ded35)
/home/oriont/dev/super g/main.go:71 +0x54
main.main()
/home/oriont/dev/super g/main.go:45 +0x2b
exit status 2
And if you are curious, my go env:
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oriont/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oriont/dev"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.11"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.11/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build854283259=/tmp/go-build -gno-record-gcc-switches"
Any help would be appreciated, thanks!
EDIT:
Now I am getting a new error, after reinstalling go and removing a failed attempt at sdl2 (from apt-get remove).
(OLD) This is the new error:
# _/home/oriont/dev/super_g
/usr/lib/go-1.11/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lXrandr
collect2: error: ld returned 1 exit status
I have all of the same code still. Also, I did try to run 'go build' but it just threw the exact same error as 'go run main.go'.
EDIT 2:
I reinstalled go 1.11.2 and installed the libglfw3 and libglfw3-dev packages on sudo apt-get install. Now, I have the same old error.
bash ubuntu go opengl
I just cannot seem to get opengl with golang to work. I wanted to try out golang but it has been such a pain to even set up, and now I can't get something I copy pasted off of this website. Here is the code I am using: (from the website). I did these two commands before running it (using wsl on windows):
go get github.com/go-gl/gl/v4.1-core/gl
go get github.com/go-gl/glfw/v3.2/glfw
And this is the full error I am getting:
2018/11/21 13:43:33 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized
goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.2/glfw.acceptError(0x0, 0x0, 0x0, 0x1, 0xc000099ee0)
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:173 +0x1d1
github.com/go-gl/glfw/v3.2/glfw.panicError()
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:184 +0x32
github.com/go-gl/glfw/v3.2/glfw.WindowHint(0x20003, 0x0)
/home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/window.go:235 +0x38
main.initGlfw(0x4ded35)
/home/oriont/dev/super g/main.go:71 +0x54
main.main()
/home/oriont/dev/super g/main.go:45 +0x2b
exit status 2
And if you are curious, my go env:
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oriont/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oriont/dev"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.11"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.11/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build854283259=/tmp/go-build -gno-record-gcc-switches"
Any help would be appreciated, thanks!
EDIT:
Now I am getting a new error, after reinstalling go and removing a failed attempt at sdl2 (from apt-get remove).
(OLD) This is the new error:
# _/home/oriont/dev/super_g
/usr/lib/go-1.11/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lXrandr
collect2: error: ld returned 1 exit status
I have all of the same code still. Also, I did try to run 'go build' but it just threw the exact same error as 'go run main.go'.
EDIT 2:
I reinstalled go 1.11.2 and installed the libglfw3 and libglfw3-dev packages on sudo apt-get install. Now, I have the same old error.
bash ubuntu go opengl
bash ubuntu go opengl
edited Nov 23 '18 at 19:55
oriont
asked Nov 21 '18 at 21:52
oriontoriont
15810
15810
1
First try to 'echo $DISPLAY' to check if the variable is there, then try 'export DISPLAY', then run your program.
– Seaskyways
Nov 21 '18 at 22:24
1
When I run 'echo $DISPLAY', a blank line shows up. I tried 'export DISPLAY' and ran my program, and I got the same error. After that, I echoed it again and it was still a blank line.
– oriont
Nov 21 '18 at 22:31
1
Are you running as root or using su ? How are you building your program ?
– Seaskyways
Nov 21 '18 at 22:40
1
I am using 'go run main.go', with main.go containing all my code. I just tried 'sudo go run main.go' with the same result.
– oriont
Nov 21 '18 at 22:50
1
Try go build, then execute the resulting executable
– Seaskyways
Nov 21 '18 at 23:07
add a comment |
1
First try to 'echo $DISPLAY' to check if the variable is there, then try 'export DISPLAY', then run your program.
– Seaskyways
Nov 21 '18 at 22:24
1
When I run 'echo $DISPLAY', a blank line shows up. I tried 'export DISPLAY' and ran my program, and I got the same error. After that, I echoed it again and it was still a blank line.
– oriont
Nov 21 '18 at 22:31
1
Are you running as root or using su ? How are you building your program ?
– Seaskyways
Nov 21 '18 at 22:40
1
I am using 'go run main.go', with main.go containing all my code. I just tried 'sudo go run main.go' with the same result.
– oriont
Nov 21 '18 at 22:50
1
Try go build, then execute the resulting executable
– Seaskyways
Nov 21 '18 at 23:07
1
1
First try to 'echo $DISPLAY' to check if the variable is there, then try 'export DISPLAY', then run your program.
– Seaskyways
Nov 21 '18 at 22:24
First try to 'echo $DISPLAY' to check if the variable is there, then try 'export DISPLAY', then run your program.
– Seaskyways
Nov 21 '18 at 22:24
1
1
When I run 'echo $DISPLAY', a blank line shows up. I tried 'export DISPLAY' and ran my program, and I got the same error. After that, I echoed it again and it was still a blank line.
– oriont
Nov 21 '18 at 22:31
When I run 'echo $DISPLAY', a blank line shows up. I tried 'export DISPLAY' and ran my program, and I got the same error. After that, I echoed it again and it was still a blank line.
– oriont
Nov 21 '18 at 22:31
1
1
Are you running as root or using su ? How are you building your program ?
– Seaskyways
Nov 21 '18 at 22:40
Are you running as root or using su ? How are you building your program ?
– Seaskyways
Nov 21 '18 at 22:40
1
1
I am using 'go run main.go', with main.go containing all my code. I just tried 'sudo go run main.go' with the same result.
– oriont
Nov 21 '18 at 22:50
I am using 'go run main.go', with main.go containing all my code. I just tried 'sudo go run main.go' with the same result.
– oriont
Nov 21 '18 at 22:50
1
1
Try go build, then execute the resulting executable
– Seaskyways
Nov 21 '18 at 23:07
Try go build, then execute the resulting executable
– Seaskyways
Nov 21 '18 at 23:07
add a comment |
1 Answer
1
active
oldest
votes
My solution is to literally install GoLang and TDM-GCC on windows, and do it through the command prompt INSTEAD OF BASH.
You didn't mention you were using Windows Subsystem for Linux. This is important information. That is a stripped down "Linux" which only supports command line programs, not GUI programs. To run a Linux GUI program, you need to run a full installation of Linux, not just WSL.
– Michael Hampton
Nov 22 '18 at 12:53
I have realised that now, thanks
– oriont
Nov 23 '18 at 19:55
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420975%2fgolang-opengl-error-platformerror-x11-the-display-environment-variable-is-miss%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
My solution is to literally install GoLang and TDM-GCC on windows, and do it through the command prompt INSTEAD OF BASH.
You didn't mention you were using Windows Subsystem for Linux. This is important information. That is a stripped down "Linux" which only supports command line programs, not GUI programs. To run a Linux GUI program, you need to run a full installation of Linux, not just WSL.
– Michael Hampton
Nov 22 '18 at 12:53
I have realised that now, thanks
– oriont
Nov 23 '18 at 19:55
add a comment |
My solution is to literally install GoLang and TDM-GCC on windows, and do it through the command prompt INSTEAD OF BASH.
You didn't mention you were using Windows Subsystem for Linux. This is important information. That is a stripped down "Linux" which only supports command line programs, not GUI programs. To run a Linux GUI program, you need to run a full installation of Linux, not just WSL.
– Michael Hampton
Nov 22 '18 at 12:53
I have realised that now, thanks
– oriont
Nov 23 '18 at 19:55
add a comment |
My solution is to literally install GoLang and TDM-GCC on windows, and do it through the command prompt INSTEAD OF BASH.
My solution is to literally install GoLang and TDM-GCC on windows, and do it through the command prompt INSTEAD OF BASH.
edited Nov 22 '18 at 12:12
Seaskyways
1,45921633
1,45921633
answered Nov 22 '18 at 0:33
oriontoriont
15810
15810
You didn't mention you were using Windows Subsystem for Linux. This is important information. That is a stripped down "Linux" which only supports command line programs, not GUI programs. To run a Linux GUI program, you need to run a full installation of Linux, not just WSL.
– Michael Hampton
Nov 22 '18 at 12:53
I have realised that now, thanks
– oriont
Nov 23 '18 at 19:55
add a comment |
You didn't mention you were using Windows Subsystem for Linux. This is important information. That is a stripped down "Linux" which only supports command line programs, not GUI programs. To run a Linux GUI program, you need to run a full installation of Linux, not just WSL.
– Michael Hampton
Nov 22 '18 at 12:53
I have realised that now, thanks
– oriont
Nov 23 '18 at 19:55
You didn't mention you were using Windows Subsystem for Linux. This is important information. That is a stripped down "Linux" which only supports command line programs, not GUI programs. To run a Linux GUI program, you need to run a full installation of Linux, not just WSL.
– Michael Hampton
Nov 22 '18 at 12:53
You didn't mention you were using Windows Subsystem for Linux. This is important information. That is a stripped down "Linux" which only supports command line programs, not GUI programs. To run a Linux GUI program, you need to run a full installation of Linux, not just WSL.
– Michael Hampton
Nov 22 '18 at 12:53
I have realised that now, thanks
– oriont
Nov 23 '18 at 19:55
I have realised that now, thanks
– oriont
Nov 23 '18 at 19:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420975%2fgolang-opengl-error-platformerror-x11-the-display-environment-variable-is-miss%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
First try to 'echo $DISPLAY' to check if the variable is there, then try 'export DISPLAY', then run your program.
– Seaskyways
Nov 21 '18 at 22:24
1
When I run 'echo $DISPLAY', a blank line shows up. I tried 'export DISPLAY' and ran my program, and I got the same error. After that, I echoed it again and it was still a blank line.
– oriont
Nov 21 '18 at 22:31
1
Are you running as root or using su ? How are you building your program ?
– Seaskyways
Nov 21 '18 at 22:40
1
I am using 'go run main.go', with main.go containing all my code. I just tried 'sudo go run main.go' with the same result.
– oriont
Nov 21 '18 at 22:50
1
Try go build, then execute the resulting executable
– Seaskyways
Nov 21 '18 at 23:07