【问题标题】:Failing to compile MonoGame on Boo compiler在 Boo 编译器上编译 MonoGame 失败
【发布时间】:2014-03-20 19:39:16
【问题描述】:

SharpDevelop 编译正常,但尝试通过 booc 编译不起作用。

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 ,Windows cmd 工具中使用的命令。

谢谢。艾丽莎。

【问题讨论】:

    标签: monogame boo


    【解决方案1】:

    Sharpdevelop 很可能已经为您将库引用到编译器。这意味着,当您手动调用 booc 命令行编译器时,您必须告诉编译器 MonoGame 库的确切位置。我还没有能够检查自己,但我确实快速浏览了命令行和 Boo 源代码,我认为您必须执行以下操作:

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

    这将告诉编译器在哪里寻找额外的库。 接下来你应该做的是添加你想要的库,例如:

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

    将这两个额外的编译器选项添加到您的命令行中,我认为它应该可以工作。 我自己并没有真正编译这个,因为我发现它相当乏味。相反,我决定在 Boo 中创建自己的构建脚本,以便编译我的 Boo 程序。这样我仍然必须添加库路径并引用库,如下面的 sn-p:

    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
    

    我已将其中两个构建脚本放在herehere。不过,这对你来说可能有点矫枉过正。

    【讨论】:

    • 我使用了以下命令:booc -lib:"C:\Workplace\Switch\bin\Debug" Program.boo,因为 Debug 文件夹包含所有需要的 dll,但使用 -r 会破坏它。我收到以下错误:BCE0021:找不到命名空间“Switch.Helpers”。您如何包含自己的 boo 文件?
    • 我不知道开关是什么。如果它是一个预先编译的库,你应该让它以与 MonoGame 相同的方式工作。如果它是一个或多个源 (.boo) 文件,您当然也应该包含这些源文件。您可以使用 -srcdir 选项添加包含源文件的文件夹。 -srcdir:DIR | Adds DIR as a directory where sources can be found
    • Switch 只是我正在开发的游戏的名称。 booc -lib:"D:\Workplace\Switch\Switch\bin\Debug" -srcdir:"D:\Workplace\Switch\Switch" -r:Microsoft.Xna.Framework.dll,Microsoft.Xna.Framework.Game .dll Program.boo Boo 编译器版本 0.9.4.9 (CLR 2.0.50727.8000) 致命错误:找不到程序集:“Microsoft.Xna.Framework.dll”。仍然无法编译>_
    猜你喜欢
    • 2013-03-07
    • 1970-01-01
    • 2021-10-07
    • 1970-01-01
    • 1970-01-01
    • 2016-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多