首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >静态库中断生成

静态库中断生成
EN

Stack Overflow用户
提问于 2011-08-16 17:07:45
回答 1查看 493关注 0票数 0

我用xcode编译了一个静态库,使“iOS设备”成为目标,并将其链接到一个单调的应用程序。当我构建和运行应用程序时,我立即得到一个错误:

Mono.Debugger.Soft.VMDisconnectedException:抛出了“Mono.Debugger.Soft.VMDisconnectedException”类型的异常。在Mono.Debugger.Soft.Connection.SendReceive (CommandSet command_set,Int32命令,Mono.Debugger.Soft.PacketWriter数据包) 0x00000 in :0 at Mono.Debugger.Soft.Connection.VM_GetVersion () 0x00000 in :0 at Mono.Debugger.Soft.Connection.Connect () 0x00000 in :0 at Mono.Debugger.Soft.VirtualMachine.connect () 0x00000 in :0 at Mono.Debugger.Soft.VirtualMachine.connect (System.Net.Sockets.Socket dbg_sock,System.Net.Sockets.Socket con_sock) 0x00000 in :0

并且没有应用程序输出。签或不签库似乎并不重要,我尝试过各种版本,甚至在编译器之间切换设置(我最后使用的编译器是股票GCC 4.2编译器)。Whm

当我为模拟器构建库并将其链接到应用程序在设备上运行时,它实际上在设备上运行,但一旦函数被p/调用,应用程序就退出,我得到系统输出解释pinvoke无法解析。

它不运行的原因可能是由于构建设置或其他什么原因,因为它在模拟器上运行,它可能是JIT与AOT的问题。

编辑:

这是事物的C#方面:

代码语言:javascript
复制
        [DllImport("__Internal")]
        private static extern int CreateWorld(b2Vec2 grav, OnIOSContact startContact, ContactOver endContact);

    delegate bool OnIOSContact(MyCollisionEvent ev);
    delegate bool ContactOver(MyCollisionEvent ev);

    [MonoTouch.MonoPInvokeCallback(typeof(OnIOSContact))]
    static bool StatContactStart(MyCollisionEvent ev){...}

    [MonoTouch.MonoPInvokeCallback(typeof(ContactOver))]
    static bool StatContactEnd(MyCollisionEvent ev){...}


    [StructLayout(LayoutKind.Sequential, Size=8),Serializable]
    struct MyCollisionEvent
    {
        public IntPtr ActorA;
        public IntPtr ActorB;
    }




    [StructLayout(LayoutKind.Sequential, Size=8),Serializable]
    public struct b2Vec2
    {
        public b2Vec2(float _x, float _y)
        {
            x = _x;
            y = _y;
        }
        public float x;
        public float y;
    }

它背后的C代码:

代码语言:javascript
复制
       extern "C"
       int CreateWorld(b2Vec2 gravity, bool (*startContact)(Contact), bool (*endContact)(Contact))

 //contact struct to match MyCollisionEvent in C# code
 typedef struct
 {
     b2Body *bodyA;
     b2Body *bodyB;
 }Contact;

/// A 2D column vector.
struct b2Vec2
{
    /// Default constructor does nothing (for performance).
    b2Vec2() {}

    /// Construct using coordinates.
    b2Vec2(float32 x, float32 y) : x(x), y(y) {}

    /// Set this vector to all zeros.
    void SetZero() { x = 0.0f; y = 0.0f; }

    /// Set this vector to some specified coordinates.
    void Set(float32 x_, float32 y_) { x = x_; y = y_; }

    /// Negate this vector.
    b2Vec2 operator -() const { b2Vec2 v; v.Set(-x, -y); return v; }

    /// Read from and indexed element.
    float32 operator () (int32 i) const
    {
        return (&x)[i];
    }

    /// Write to an indexed element.
    float32& operator () (int32 i)
    {
        return (&x)[i];
    }

    /// Add a vector to this vector.
    void operator += (const b2Vec2& v)
    {
        x += v.x; y += v.y;
    }

    /// Subtract a vector from this vector.
    void operator -= (const b2Vec2& v)
    {
        x -= v.x; y -= v.y;
    }

    /// Multiply this vector by a scalar.
    void operator *= (float32 a)
    {
        x *= a; y *= a;
    }

    /// Get the length of this vector (the norm).
    float32 Length() const
    {
        return b2Sqrt(x * x + y * y);
    }

    /// Get the length squared. For performance, use this instead of
    /// b2Vec2::Length (if possible).
    float32 LengthSquared() const
    {
        return x * x + y * y;
    }

    /// Convert this vector into a unit vector. Returns the length.
    float32 Normalize()
    {
        float32 length = Length();
        if (length < b2_epsilon)
        {
            return 0.0f;
        }
        float32 invLength = 1.0f / length;
        x *= invLength;
        y *= invLength;

        return length;
    }

    /// Does this vector contain finite coordinates?
    bool IsValid() const
    {
        return b2IsValid(x) && b2IsValid(y);
    }

    float32 x, y;
};

编辑2:

当我第一次写这篇文章时,我应该提到这一点,但我已经能够让这个应用程序在设备上运行几次。通常情况下,它涉及到用稍微不同的构建设置(例如签名库)来修改项目/库,但是我还无法识别需要采取的步骤,这些步骤导致了这些成功的构建……

每次运行时,它都会崩溃(因为不相关的but ),但是即使是对代码的轻微修改(比如注释一行)也会导致同样的错误再次弹出。即使恢复行也不会使错误消失。

EN

回答 1

Stack Overflow用户

发布于 2011-08-17 12:17:42

我看不出有什么明显的。尝试分而治之的方法。

  • 使用任何方法参数删除代码;然后
  • 删除一个(接另一个)参数(例如,第一个b2Vec2,然后回调……)

直到你到达一个(坚实的,永不崩溃的)工作点。这将产生一个更小的测试用例来检查:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7082088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档