Question

SharpDevelop compiles fine, but trying to compile through booc doesn't work.

Boo Compiler version 0.9.4.9 (CLR 2.0.50727.8000)
Program.boo(4,8): BCE0021: Namespace 'Microsoft.Xna.Framework' not found, maybe
you forgot to add an assembly reference?

booc -resource:"C:\test\" Program.boo , the command used in Windows cmd tool.

Thank you. Alisa.

Was it helpful?

Solution

Sharpdevelop most likely already references the libraries to the compiler for you. What that means is, when you manually invoke the booc command line compiler, you will have to tell the compiler where exactly the MonoGame library is. I haven't been able to check myself yet, but I did have a quick look at the command lines and the Boo source code, and I think you have to do the following:

-lib:C:/Path/To/MonoGame/Libraries

This will tell the compiler where to look for additional libraries. The next thing you should then do is add the libraries you want, eg:

-r:Microsoft.Xna.Framework.dll,Microsoft.Xna.Framework.Game.dll

Add these two additional compiler options to your command line and I think it should work. I haven't compiled this myself really, because I found it rather tedious. Instead, I decided to create my own build script in Boo itself in order to compile my Boo programs. That way I still had to add the library path and reference the libraries, as in the following snippet:

def CompileEngine() as bool:
"""Compiles the engine and puts it in ./lib/SpectralEngine.dll"""

    compiler                       = BooCompiler()
    compiler.Parameters.Pipeline   = CompileToFile()
    compiler.Parameters.OutputType = CompilerOutputType.Library
    compiler.Parameters.Ducky      = true
    compiler.Parameters.LibPaths.Add("./lib")
    compiler.Parameters.OutputAssembly = "./lib/SpectralEngine.dll"

    # Add libraries.
    compiler.Parameters.References.Add(compiler.Parameters.LoadAssembly("OpenTK.dll"))
    compiler.Parameters.References.Add(compiler.Parameters.LoadAssembly("NAudio.dll"))
    compiler.Parameters.References.Add(compiler.Parameters.LoadAssembly("Boo.Lang.dll"))
    compiler.Parameters.References.Add(compiler.Parameters.LoadAssembly("Boo.Lang.Parser.dll"))
    compiler.Parameters.References.Add(compiler.Parameters.LoadAssembly("Boo.Lang.Compiler.dll"))

    # Take all boo files from the Engine source directory.
    files = (Directory.GetFiles(Directory.GetCurrentDirectory() + """/src/Engine""", "*.boo", SearchOption.AllDirectories)
                .Where({file as string | return not file.Contains("Gwen")})) # Filter out old GWEN files.

    for file in files:
        print "Adding file: " + file
        compiler.Parameters.Input.Add(FileInput(file))

    print "Compiling to ./lib/SpectralEngine.dll"
    context = compiler.Run()

    if context.GeneratedAssembly is null:
        print "Failed to compile:\n" + join(e for e in context.Errors, "\n")
        return false
    else:
        return true

I've put two of these build scripts at here and here. It's perhaps a bit overkill for you, though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top