How to reference Microsoft.Boogie when compiling with Mono?

anirudh
using System;
using System.Collections.Generic;
using Microsoft.Boogie;

public class Trace
{
    public static void Main(string[] args)
{
    if (args.Length != 2){
        return;
    }
    Program program = new Program();
    List<string> defines = new List<string>();
    Parser.Parse(args[0], defines, out program);
    
    string[] lines = System.IO.File.ReadAllLines(args[1]);
    Dictionary< Block, List<Block> > adj = new Dictionary< Block, List<Block> >();
    
    foreach (Declaration D in program.TopLevelDeclarations){
        Implementation I = D as Implementation;
        if(I != null){
            foreach (Block B in I.Blocks){
                object cmd = B.TransferCmd;
                if(cmd is GotoCmd){
                    List<Block> target = cmd.labelTargets;
                    adj.insert(B, target);
                }
                else if(cmd is ReturnCmd){
                    adj.insert(B, null);
                }
            }
        }
    }
}
}

I am new to C# and I am stuck on how to iterate over program.TopLevelDeclarations.

Trying to iterate over a simple list works but when I try to include the Microsoft Boogie library, the compiler throws a few errors.

I am compiling my program using gmcs on Ubuntu 13.04 using the command:

gmcs -r:../../boogie/Binaries/Boogie.exe -r:../../boogie/Binaries/Core.dll Trace.cs

Which gives the following errors:

Missing method .ctor in assembly /home/boogie/Binaries/Core.dll, type System.Diagnostics.Contracts.ContractClassAttribute

Can`t find custom attr constructor image: /home/boogie/Binaries/Core.dll mtoken: 0x0a000463

  • Trace.cs(19,52): error CS0584: Internal compiler error: Could not load type System.Diagnostics.Contracts.ContractClassAttribute from assembly Core.

  • Trace.cs(19,36): error CS0266: Cannot implicitly convert type object to System.Collections.Generic.List<Microsoft.Boogie.Declaration>. An explicit conversion exists (are you missing a cast?)

  • Trace.cs(22,30): error CS0584: Internal compiler error: Could not import type Microsoft.Boogie.Implementation from Core, Version=2.2.30705.1126, Culture=neutral, PublicKeyToken=736440c9b414ea16

  • Trace.cs(22,30): error CS0266: Cannot implicitly convert type object to bool. An explicit conversion exists (are you missing a cast?)

  • Trace.cs(23,55): error CS0584: Internal compiler error: Could not import type Microsoft.Boogie.Implementation from Core, Version=2.2.30705.1126, Culture=neutral, PublicKeyToken=736440c9b414ea16

  • Trace.cs(23,33): error CS1579: foreach statement cannot operate on variables of type object because it does not contain a definition for GetEnumerator or is inaccessible

Compilation failed: 6 error(s), 0 warnings

Does anyone know how to fix this? Am I including the libraries incorrectly?

CodeCaster

I can't seem to find the source of Microsoft.Boogie.Declaration, but given the error messages it has a [ContractClass] attribute, which the compiler cannot find:

Trace.cs(19,52): error CS0584: Internal compiler error: Could not load type 'System.Diagnostics.Contracts.ContractClassAttribute' from assembly 'Core'.

Because of this the type Microsoft.Boogie.Declaration cannot be loaded, causing the List<Declaration> of program.TopLevelDeclarations to apparently be "stubbed" of some sort as an object. This in turn causes your code to fail, because you can't iterate over an object.

The ContractClassAttribute was added to mscorlib in .NET 4. You're using gmcs, which according to mono's CSharp Compiler manual page compiles against .NET 2.0.

I think you better compile using mcs, which is recommended there.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to reference Microsoft.Boogie when compiling with Mono?

From Dev

Undefined Reference when Compiling to Executable

From Dev

compiling z3 4.1 on OS X to use Boogie

From Dev

'undefined reference to' when compiling with g++

From Dev

Error "undefined reference to `sin'" when compiling (with -lm)

From Dev

Undefined reference to 'main' when compiling a module

From Dev

Undefined reference when compiling C code

From Dev

Undefined reference to main when compiling c++

From Dev

How to solve undefined reference cv:.... when compiling openCV application in Linux/Ubuntu?

From Dev

How to add reference to Mono.Android?

From Dev

Microsoft word how to reference a translation?

From Dev

Java VTD-XML cannot find symbol error. How do I properly reference package when compiling java?

From Dev

Java VTD-XML cannot find symbol error. How do I properly reference package when compiling java?

From Dev

undefined reference to `event_new' when compiling with libevent

From Dev

In C programming, what is `undefined reference`error, when compiling?

From Dev

GCJ throws error: "Undefined reference to main" when compiling

From Dev

undefined reference to `event_new' when compiling with libevent

From Dev

Mac + Mono + VB + LINQ = Not Compiling

From Dev

Mac + Mono + VB + LINQ = Not Compiling

From Dev

Compiling Mono (linux) with static glibc

From Dev

Error when compiling mono on windows: i686-pc-mingw32/bin/ld: cannot find -ldl

From Dev

how turn on the Microsoft HTML Object Library reference when using option explicit (excel-vba)?

From Dev

how turn on the Microsoft HTML Object Library reference when using option explicit (excel-vba)?

From Dev

How to add a missing assembly reference for xbuild? (Mono/Linux)

From Dev

How to add a missing assembly reference for xbuild? (Mono/Linux)

From Dev

How to specify path to fonts when compiling less

From Dev

How to exclude frameworks in Xcode when compiling to the simulator

From Dev

How to work with external libraries when cross compiling?

From Dev

C compiling - "undefined reference to"?

Related Related

  1. 1

    How to reference Microsoft.Boogie when compiling with Mono?

  2. 2

    Undefined Reference when Compiling to Executable

  3. 3

    compiling z3 4.1 on OS X to use Boogie

  4. 4

    'undefined reference to' when compiling with g++

  5. 5

    Error "undefined reference to `sin'" when compiling (with -lm)

  6. 6

    Undefined reference to 'main' when compiling a module

  7. 7

    Undefined reference when compiling C code

  8. 8

    Undefined reference to main when compiling c++

  9. 9

    How to solve undefined reference cv:.... when compiling openCV application in Linux/Ubuntu?

  10. 10

    How to add reference to Mono.Android?

  11. 11

    Microsoft word how to reference a translation?

  12. 12

    Java VTD-XML cannot find symbol error. How do I properly reference package when compiling java?

  13. 13

    Java VTD-XML cannot find symbol error. How do I properly reference package when compiling java?

  14. 14

    undefined reference to `event_new' when compiling with libevent

  15. 15

    In C programming, what is `undefined reference`error, when compiling?

  16. 16

    GCJ throws error: "Undefined reference to main" when compiling

  17. 17

    undefined reference to `event_new' when compiling with libevent

  18. 18

    Mac + Mono + VB + LINQ = Not Compiling

  19. 19

    Mac + Mono + VB + LINQ = Not Compiling

  20. 20

    Compiling Mono (linux) with static glibc

  21. 21

    Error when compiling mono on windows: i686-pc-mingw32/bin/ld: cannot find -ldl

  22. 22

    how turn on the Microsoft HTML Object Library reference when using option explicit (excel-vba)?

  23. 23

    how turn on the Microsoft HTML Object Library reference when using option explicit (excel-vba)?

  24. 24

    How to add a missing assembly reference for xbuild? (Mono/Linux)

  25. 25

    How to add a missing assembly reference for xbuild? (Mono/Linux)

  26. 26

    How to specify path to fonts when compiling less

  27. 27

    How to exclude frameworks in Xcode when compiling to the simulator

  28. 28

    How to work with external libraries when cross compiling?

  29. 29

    C compiling - "undefined reference to"?

HotTag

Archive