2011-04-23 56 views
0

我可以修改和编译AS3的SDK使用的strictgecho.c示例没问题。Flash Alchemy内置的.swc函数库太小且缺少函数

对于自己的应用程序,我编译使用g ++几十个成功的文件和链接:

g++ -swc -o myApp.swc glue.o demo.o obj1.o obj2.o obj3.o 

我得到一个myApp.swc,但它是错误的只有80K(大小一样简单stringecho例子) 。

当任何Flash IDE检查,不同于具有

cmodule.stringecho.AlchemyBlock 
cmodule.stringecho.AlchemyBreakPoint 
... 

这myApp.swc的stringecho.swc具有

cmodule.AlchemyBlock 
cmodule.AlchemyBreakPoint 
... 

而且具有我定义的无胶的功能。实质上,我不能在AS3项目中使用它。

我的glue.c代码如下。基本上,我创建一个演示对象并调用它的函数。演示类封装了所有其他对象文件。

#include "demo.h" 
#include "AS3.h" 
    AS3_Val InitSystem(void* self, AS3_Val args) 
    { 
     demo = new demo9(); 
     return 0; 
    } 

    AS3_Val LoadSceneFile(void* self, AS3_Val args) 
    { 
     demo->loadScene("scene.txt"); 
     return 0; 
    } 

... 

    int main() 
    { 
     AS3_Val InitSystemMethod = AS3_Function(NULL, InitSystem); 
     AS3_Val LoadSceneFileMethod = AS3_Function(NULL, LoadSceneFile); 
     AS3_Val getAlchemyScreenMethod = AS3_Function(NULL, getAlchemyScreen); 
     AS3_Val setMouseStateMethod = AS3_Function(NULL, setMouseState); 
     AS3_Val rasterizeMethod = AS3_Function(NULL, rasterize); 

     AS3_Val result = AS3_Object("InitSystem: AS3ValType,LoadSceneFile: AS3ValType,getAlchemyScreen:AS3ValType,setMouseState:AS3ValType,rasterize:AS3ValType" 
            ,InitSystemMethod, 
            LoadSceneFileMethod, 
            getAlchemyScreenMethod, 
            setMouseStateMethod, 
            rasterizeMethod); 

     AS3_Release(InitSystemMethod); 
     AS3_Release(LoadSceneFileMethod); 
     AS3_Release(getAlchemyScreenMethod); 
     AS3_Release(setMouseStateMethod); 
     AS3_Release(rasterizeMethod); 

     AS3_LibInit(result); 

     return 0; 
    } 

回答

1

读这个blog post

小故事是,链接很多.o文件将无法正常工作。您需要将它们'一起'放到一个库(.a)文件中。然后,您可以针对该库编译胶水代码。根据你的例子,它会是这样的:

ar rc mylib.a demo.o obj1.o obj2.o obj3.o 
ranlib mylib.a 
g++ -swc -o myApp.swc glue.c mylib.a 
+0

对您有帮助吗?如果是这样,请接受我的回答作为答案 – paleozogt 2011-05-20 15:04:47