首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >x64和Win32配置之间的访问位置0xFFFFFF崩溃

x64和Win32配置之间的访问位置0xFFFFFF崩溃
EN

Stack Overflow用户
提问于 2015-06-15 10:22:45
回答 2查看 621关注 0票数 1

我编写您是因为我在代码中使用的库的DLL有问题。我一直在寻找类似的线程,这些线程与释放模式下的崩溃有关,但不是在调试模式下,但它们似乎不完全符合我所面临的问题。我已经准备了一个小例子来说明这个问题。我正在使用Visual 2010编译我的示例以及库。

问题是,当我在版本x64配置中编译和运行我的示例时,由于访问读取位置0xFFFFFFFFFFFFF,BRepOffsetAPI_MakePipe对象的创建会使应用程序崩溃,这是因为TKBRep.dll中出现了崩溃。还有一点令人费解的是,如果代码是在发行版Win32中编译的,那么一切都很好,结果是正确的。接下来,我描述了编译库和我编写的代码所遵循的过程。请注意,我创建的对象(即柱面、faces)是使用OCC类创建的。我目前使用的是6.8.0版本,但我在6.9.0版中也看到了同样的问题。因此,我倾向于认为问题出在我正在编写的代码中。

为Win32和x64配置安装OCC的过程。

  1. 下载OCC6.8.0 Windows安装程序并安装库。这将导致安装的Win32库和DLL。
  2. 在Visual 2013中打开OCC.sln并编译发行版x64配置中示例所需的包。这将在安装文件夹中的win64文件夹中创建库和DLL。

示例代码:

代码语言:javascript
运行
复制
void constructWires(gp_Pnt pointZero, gp_Pnt pointOne,
   TopoDS_Wire& circular, TopoDS_Wire& straight,
   TopoDS_Face& faceCircular)
{
   BRepBuilderAPI_MakeEdge edgeS(pointZero, pointOne);
   edgeS.Build(); edgeS.Check();

   BRepBuilderAPI_MakeWire wireS(edgeS.Edge());
   wireS.Build(); wireS.Check();

   straight = wireS.Wire();

   gp_Vec vec(pointZero.X() - pointOne.X(), pointZero.Y() - pointOne.Y(), pointZero.Z() - pointOne.Z());
   gp_Dir dir = vec.Normalized();

   gp_Ax2 ax(pointZero, dir);
   Handle(Geom_Circle) circle = new Geom_Circle(ax, 50.0);

   BRepBuilderAPI_MakeEdge edgeC(circle);
   edgeC.Build(); edgeC.Check();

   BRepBuilderAPI_MakeWire wireC(edgeC.Edge());
   wireC.Build(); wireC.Check();

   circular = wireC.Wire();

   // Face One creation
   gp_Pln plane(pointZero, dir);
   BRepBuilderAPI_MakeFace faceCreated(plane, circular, Standard_True);
   faceCreated.Build(); faceCreated.Check();

   faceCircular = faceCreated.Face();
}

void buildSolid(TopoDS_Wire& circ, TopoDS_Wire& straight, TopoDS_Solid& solid, TopoDS_Face faceToSweep)
{
   //BRepTools::Write(straight, "straight.brep");
   //BRepTools::Write(circ, "circ.brep");

   // In this example, the shape is a cylinder but the class
   // BRepOffsetAPI_MakePipe because the wire representing the 
   // axis of the cylinder might be composed of different edges
   // properly alinged.

   // This line generates the TKBRep.dll failure trying to access
   // 0xFFFFFFFFFF location.
   BRepOffsetAPI_MakePipe shell(straight, faceToSweep);

   shell.Build();
   shell.Check();

   //shell.MakeSolid();
   TopExp_Explorer solidInS(shell.Shape(), TopAbs_SOLID);

   if (!solidInS.More())
   {
      std::cout << "Error when creating solid!" << std::endl;
      return;
   }

   solid = TopoDS::Solid( solidInS.Current() ) ;
   BRepTools::Write(solid, "solid.brep");
}

void cutFace(TopoDS_Shape solid, TopoDS_Shape face, TopoDS_Shape& shape)
{
   BRepTools::Write(face, "faceInCut.brep");
   BRepTools::Write(solid, "solidInCut.brep");

   TopoDS_Shape faceToCut(face);

   TopoDS_Shape solidToCut(solid);
   BRepAlgoAPI_Cut cut(faceToCut, solidToCut);
   cut.Build(); cut.Check();

   shape = cut.Shape();
}

TopoDS_Face constructSquareFace()
{

   gp_Pnt pOne(-100.0, 75.0, 0.0);
   gp_Pnt pTwo(-100.0, -75.0, 0.0);

   gp_Pnt pThree(200.0, -75.0, 0.0);
   gp_Pnt pFour(200.0, 75.0, 0.0);

   BRepBuilderAPI_MakeEdge edgeOne(pOne, pTwo);
   BRepBuilderAPI_MakeEdge edgeTwo(pTwo, pThree);
   BRepBuilderAPI_MakeEdge edgeThree(pThree, pFour);
   BRepBuilderAPI_MakeEdge edgeFour(pFour, pOne);

   BRepBuilderAPI_MakeWire wire(edgeOne.Edge(), edgeTwo.Edge(), edgeThree.Edge(), edgeFour.Edge());
   wire.Build(); wire.Check();

   BRepBuilderAPI_MakeFace sqFace(wire.Wire(), Standard_True);
   sqFace.Build(); sqFace.Check();

   return sqFace.Face();

}

void testCrash(void)
{
   gp_Pnt pointZero(0.0, 0.0, 0.0);
   gp_Pnt pointOne(100.0, 0.0, 0.0);

   TopoDS_Wire circular;
   TopoDS_Wire straight;
   TopoDS_Face faceCircular;
   // This method creates a circular face which then will be swept 
   // along the straight wire which represents the axis of the cylinder.
   constructWires(pointZero, pointOne, circular, straight, faceCircular);

   TopoDS_Solid solid;
   // This method constructs the solid, i.e. cylinder, used to cut.
   buildSolid(circular, straight, solid, faceCircular);
   BRepTools::Write(solid, "solid.brep");

   // This is the face which will be cut.
   TopoDS_Face faceToCut = constructSquareFace();
   BRepTools::Write(faceToCut, "sqFace.brep");

   // Perform cut operation.
   TopoDS_Shape shape;
   cutFace(solid, faceToCut, shape);
   BRepTools::Write(shape, "shape.brep");

   std::cout << "Done!!" << std::endl;

}


    int _tmain(int argc, _TCHAR* argv[])
    {
       std::cout << "Started" << std::endl; 

       testCrash();
       std::cout << "Finished" << std::endl;
        return 0;
    }

在我看来,代码是正确的,函数的定义中没有任何模糊的参数声明。

谁能帮我指出正确的方向吗?

任何帮助都是非常感谢的。致以亲切的问候,

保罗

EN

回答 2

Stack Overflow用户

发布于 2015-06-17 13:02:28

我已经理解是什么触发了我的小应用程序崩溃。这与我如何编译OpenCasCade库有关。由于我正在为64位应用程序开发OCC代码,现在我将参考OCC的最新版本,即OCC6.9.0,它(至少对于Windows )的结果已经测试并通过了发布x64配置的认证。但是,正如我所说的,我在6.8.0版x64中看到了同样的问题。那时可能会有一个独特的解决办法。

安装OCC6.9.0时,将创建win64文件夹bin和lib,其中包含在发布模式下遵循的dll和库。如果我的示例是针对这些文件链接的,它不会崩溃,并且结果是正确的。

现在假设用户希望自己构建库。我所做的是:-打开命令提示符窗口并转到C:\OpenCASCADE6.9.0\opencascade-6.9.0\文件夹。-执行custom.bat和msvc.bat vc10 Debug win64

这将打开VC2010,可以选择构建配置。在解决方案资源管理器中,可以选择构建一些项目。例如,在我的项目中,我感兴趣的是构建除“绘图”文件夹中的项目之外的所有项目。我以Debug模式构建项目,并执行我的示例,将其链接到新的DLL和Libs文件(现在分别分组在bind 64\ in 10\bind和\libd中)。在调试模式下,正如我前面所说的,它工作得很好。另一方面,当在发布模式下构建相同的项目并执行应用程序时,它会崩溃。

造成我的错误的原因是,当我手工编译发布模式的代码时,以及当我从安装中获得版本dll和lib时,构建设置是不同的。

目前,我将依赖已安装的DLL和Libs。如果我有更多的细节,我会张贴在这里。

亲切的问候

附注:很抱歉给出了所有细节。我知道你们中的大多数人都很清楚。

票数 1
EN

Stack Overflow用户

发布于 2015-06-17 15:30:51

问题是我的Visual 2010。正如发行说明中正确说明的那样,为了正确编译库,需要SP1 for VS2010。这就是我在我的VS2010中缺少的东西。我现在已经为SP1安装了VS2010,并测试了我的应用程序,它运行良好。

你好,保罗

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

https://stackoverflow.com/questions/30842759

复制
相关文章

相似问题

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