James King
James King

Reputation: 88

Unable to resolve symbols when importing my development haxelib

I get the error src/shader/Shader.hx:3: characters 7-19 : Type not found : gfx.Vector2f.

build.hxml:

-cp src
-lib cc_gfx
-main shader.Shader
-lua out/main.lua

haxelib.json:

{
  "name": "cc_gfx",
  "license": "MIT",
  "description": "Bindings to the gfx library for ComputerCraft.",
  "version": "0.0.1",
  "classPath": "src",
  "releasenote": "Initial release.",
  "contributors": ["James King"]
}

Shader.hx:

package shader;

import gfx.Vector2f;

class Shader {
    static public function main() {
        var v = new Vector2f(1, 1);
    }
}

Vector.hx:

package gfx;

public class Vector2f {
    var x : Float;
    var y : Float;

    Vector2f(x : Float, y : Float) {
        this.x = x;
        this.y = y;
    }
}

Upvotes: 2

Views: 77

Answers (1)

Gama11
Gama11

Reputation: 34128

This is actually not related to the files being in a Haxelib.

src/shader/Shader.hx:3: characters 8-20 : Type not found : gfx.Vector2f

import gfx.Vector2f; is trying to import a module that doesn't exist, it's actually named Vector (since the file name is Vector.hx). The module name doesn't have to match the class name, but then the import needs to be adjusted to import gfx.Vector;. Or just change the file name to Vector2f.hx.


After that is fixed, the compiler will report two more errors, since the code in Vector has some syntax issues:

src/gfx/Vector.hx:3: characters 1-7 : Unexpected public

Types in Haxe are public by default, so there's no public modifier allowed. After that:

src/gfx/Vector.hx:6: characters 5-13 : Unexpected Vector2f

That's not how you declare a constructor in Haxe. Vector2f(x:Float, y:Float) should be replaced with public function new(x:Float, y:Float).

Upvotes: 1

Related Questions