현재 프로그램에서 벡터를 사용하고 있으며 클래스를 사용하기 시작한 후에 만 나타나는 몇 가지 이상한 오류가 발생합니다.C++ 벡터 조작 오류
1>MyCloth.obj : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "public: unsigned int & __thiscall std::vector<unsigned int,class std::allocator<unsigned int> >::operator[](unsigned int)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected])
1>libcpmtd.lib(stdthrow.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>D:\Licenta\Project\IOPBTS\Debug\IOPBTS.exe : fatal error LNK1120: 1 unresolved externals
그리고 내 코드는 다음과 같습니다 :
오류는있는 CPP 파일에서
#undef vector
#include <vector>
void findPieceVertices(NxU32 selectedVertex);
bool checkVertexExistsInClothPieceElements(int vertex);
void findVertexTriangles(NxU32 vertex);
std::vector<NxU32> clothPieceElements;
:
bool MyCloth::checkVertexExistsInClothPieceElements(int vertex)
{
for(int i=0;i<clothPieceElements.size();i++)
if(clothPieceElements[i]==vertex)
return true;
return false;
}
void MyCloth::findVertexTriangles(NxU32 vertex)
{
NxMeshData data = mCloth->getMeshData();
NxU32* vertices = (NxU32*)data.indicesBegin;
NxU32 aux = 0;
for(int i=0;i<(mInitNumVertices-1)*3;i+=3)
{
if(*vertices == vertex || *(vertices+1) == vertex || *(vertices+2) == vertex)
{
if(!checkVertexExistsInClothPieceElements(*vertices))
clothPieceElements.push_back(*vertices);
if(!checkVertexExistsInClothPieceElements(*(vertices+1)))
clothPieceElements.push_back(*(vertices+1));
if(!checkVertexExistsInClothPieceElements(*(vertices+2)))
clothPieceElements.push_back(*(vertices+2));
}
vertices = vertices + 3;
}
}
헤더 파일
void MyCloth::findPieceVertices(NxU32 selectedVertex)
{
clothPieceElements.push_back(selectedVertex);
int i=0;
while(i<clothPieceElements.size())
{
findVertexTriangles(clothPieceElements[i]);
i++;
}
}
내가 뭘 잘못하고 있니? 인터넷에서 파일을 찾았습니다. 사용하는 파일은 릴리스 모드로 컴파일되었고, 그렇게해야합니다. 문제는, 만약 내가 릴리스 모드에서 컴파일하면 이러한 오류는 사라지지만, 내 프로그램은 VCC Directories-> Include 디렉토리에 추가 된 경로가 가리키는 매우 중요한 non-C 라이브러리를 찾지 못한다는 것입니다. ? 또한, 누군가가 나에게 디버그 또는 릴리스 모드에서 건물 사이의 차이를 말할 수 :이 오류가 발생하거나
편집을 무엇을 의미하는지 이유를
는 아는 사람 있나요?
기본적으로 릴리즈는 더 많은 최적화를 수행하므로 프로그램은 작고 빠르지 만 디버깅하기가 더 어렵습니다. 나는 디버그도 물건을 0xCECECE로 설정하고 항상 바이트를 더 할당함으로써 충돌하는 대신 포인터가 오버플로되는 것으로 생각한다.Proj 설정에서 릴리스 모드의 lib를 사용하려면 디버그를 릴리스로 변경 한 다음 거기에있는 포함을 설정하십시오. AFAIK 모든 libs 릴리스 및 디버그 작동합니다. – mwerschy
나는 당신이 올바른 런타임 라이브러리에 링크하지 않은 것 같아요 : 디버그 구성에 대한 디버그 하나 (일부 어설 션은 CrtDbgReport가 필요합니다) – Liviu
디버그 모드에서 항상 릴리스에 링크하면 안됩니까? 나는 그것이 멋지게 디버깅하지 않을 것이라고 생각할 것이다. – mwerschy