Sdl_ttf not found

Screenshot from 2020-09-03 12-40-49 Screenshot from 2020-09-03 12-41-12

it works in the 2017 tutorial by fransesc campoy, but i guess something changed.
I also tried
go-sdl2/ttf/sdl_ttf, and
only go-sdl2/ttf

The second one gives a different error:

As you can see in the repo, indeed "" should work.

If it doesn’t please tell us the error you get with that.

Please keep in mind, that in 3 years a lot of changes could have been made to the library, such that it is not compatible anymore with the tutorial you are referring to (but haven’t linked).

Also please post code in future and use the code formatting option of the forum software. Do not post screenshots!

1 Like
package main

import (


func main() {
	//first initialize sdl2
	if err := run(); err != nil {
		fmt.Fprintf(os.Stderr, "%v", err)

func run() error {
	err := sdl.Init(sdl.INIT_EVERYTHING)
	if err != nil {
		return fmt.Errorf("could not initialize SDL: %v", err)

	defer sdl.Quit()

	if err := ttf.Init(); err != nil {
		return fmt.Errorf("couldn't initialize ttf : %v", err)

	w, r, err := sdl.CreateWindowAndRenderer(800, 800, sdl.WINDOW_SHOWN)
	if err != nil {
		return fmt.Errorf("could not create window:%v", err)
	defer w.Destroy()

	_ = r


	return drawTitle()

func drawTitle() error {
	f, err := ttf.OpenFont("res/fonts/Flappy.ttf", 20)
	if err != nil {
		return fmt.Errorf("could not load font : %v", err)

	c := sdl.Color{R: 255, G: 100, B: 0, A: 255}
	s, err := f.RenderUTF8_Solid("Flappy Gopher", c)


this is the code. I dont know how I can show you the errors without screenshots. I’m still new to the forum. Here’s my full error. I have tried both Atom and VScode with the same error:

i wasnt sure I could add links. Here’s the youtube tutorial. Go to 8:50 :

Any help is highly appreciated.

Copy and paste them, or use a terminal and copy paste from there. I can’t help with pictures. They are hard to read for me. And more than often not even downloaded properly, as I’m living on small bandwidth and small screen most of the day.

I was only able to download the very first screenshot of yours, those thereafter are not accessible to me.

ahh understood…sorry

~/Golang/>Finished running tool: /usr/local/go/bin/go build -i -o /tmp/vscode-goCsoczl/go-code-check .

pkg-config --cflags – SDL2_ttf

Package SDL2_ttf was not found in the pkg-config search path.
Perhaps you should add the directory containing `SDL2_ttf.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘SDL2_ttf’ found
pkg-config: exit status 1

~/Golang/>Finished running tool: /usr/local/go/bin/go vet .

Looks like you are missing the libraries for sdl-ttf in your system.

You need to install them by the means of your systems package management

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.