2015-01-17 5 views
0

그래, 내 프로젝트를 컴파일하려고 할 때 약간의 문제가 있습니다.Box2D 및 dll "액세스 위반 위치 읽기"

다른 프로젝트에서 exe를 만들기 위해이 프로젝트를 사용하는 DLL을 만드는 프로젝트가 하나 있습니다. Box2D.lib에 대한 두 프로젝트 링크가 있습니다 (이 때문에 오류가 발생합니다.), 그렇다면 정적을 연결하는 올바른 방법은 무엇입니까? 라이브러리 dll과 exe에서 모두 사용하는 경우)

b2World의 비용 계산은 DLL 코드로 수행되지만 다음 클래스는 exe 부분에서 수행됩니다. 0x010B80C1에서

처리되지 않은 예외를 GamePlayground.exe에서 : 다음과 같이

b2BodyDef def; 

def.position = b2Vec2(10, 10); 
def.type = b2_dynamicBody; 

b2Body* body; 
body = world->CreateBody(&def); 

b2Vec2 sizeboxsim(10,10); 
b2PolygonShape shape; 
b2FixtureDef fixture; 
fixture.shape = &shape;//this where the program returns the error 

body->CreateFixture(&fixture); 

오류는가 0xc0000005 : 위치 0x41200000 읽기 액세스 위반. 다음과 같이

스택은 다음과 같습니다 당신이 def.position = b2Vec2(10, 10);와 코드가 충돌하지 않는 def.type = b2_dynamicBody;을 모두 제거하면

GamePlayground.exe!b2BlockAllocator::Allocate(int) 
GamePlayground.exe!b2PolygonShape::Clone(class b2BlockAllocator *) 
GamePlayground.exe!b2Fixture::Create(class b2BlockAllocator *,class b2Body *,struct b2FixtureDef const *) 
GamePlayground.exe!b2Body::CreateFixture(struct b2FixtureDef const *) 
GamePlayground.exe!testClass::testClass(b2World * world) 
GamePlayground.exe!PlaygroundGame::PlaygroundGame() 
GamePlayground.exe!main() 
[External Code] 
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] 

재미있는 thig입니다.

또한 동일한 코드가 dll에서 완료되면 메모가됩니다. exe 코드에서 호출해도 문제가 없습니다.

전체 코드는 https://github.com/Miniwoffer/Phoenix에 있으며, 컴파일하려면 boost, sfml 및 box2d가 필요합니다.

미리 감사드립니다.

답변

0

기본적으로 개체가 만들어지지 않은 것으로 보입니다. 바로() 오류가 발생, 내가 포인터에 모든 것을 변환했고, 힙에 생성 추가 있지만

b2PolygonShape shape; 
b2FixtureDef fixture(); 

그리고 시작

b2BodyDef def(); 
+0

을보십시오. 그래도 오류가 발생했습니다. – Miniwoffer

+0

어리석은 질문 일지 모르지만, 객체를 포인터로 변환 한 후에 &를 제거 했습니까? – maxpovver

+0

예, 그렇지 않으면 컴파일되지 않을 것이라고 생각합니다. – Miniwoffer