It's the first time I prepare a pretty complex application in C++ (Visual Studio 2010) and I have serious linking problems which gave me a solid headache (maybe cause I've never got what it's all about).
这是我第一次在c++ (Visual Studio 2010)中准备一个相当复杂的应用程序,并且我有严重的链接问题,这让我很头疼(可能是因为我从来没有得到过它的全部)。
I'm implementing fluid flow simulator using: - NVidia PhysX (SDK 3.2.3) - glew (1.9) - freeglut (2.8.1) - gltools library (addon to OpenGL Superbible 5th)
我正在使用:- NVidia PhysX (SDK 3.2.3) - glew (1.9) - freeglut (2.8.1) - gltools库(addon to OpenGL Superbible 5)
I have no idea how to properly set Release/Debug and MD/MDd/MT/MTd options to get everything working.
我不知道如何适当地设置Release/Debug和MD/MDd/MT/MTd选项以使一切正常工作。
- I can compile freeglut with MD/MDd/MT/MTd and also with Relese/Release-Static/Debug/Debug-Static solution configurations
- 我可以用MD/MDd/MT/MTd编译freeglut,也可以使用Relese/Release-Static/Debug/Debug- static解决方案配置。
- I can compile gltools with MD/MDd/MT/MTd and also with Relese/Debug
- 我可以用MD/MDd/MT/MTd和Relese/Debug来编译gltools。
- PhysX is precompiled lib and dll files (I have no idea what options were used in compiling process)
- PhysX是预编译的lib和dll文件(我不知道在编译过程中使用了什么选项)
- Same is about glew
- 同样是关于glew
I tried a lot of configurations but all the time i get compilation errors like
我尝试了很多配置,但一直都有编译错误。
defaultlib 'MSVCRT' conflicts with use of other libs;
or
或
fatal error C1189: #error : Exactly one of NDEBUG and _DEBUG needs to be defined by preprocessor
I read that It's all about setting mentioned configuration in a right way, but I actually can't do it.
我读到,它是关于以正确的方式设置提到的配置,但实际上我做不到。
What should be right configuration (and why?) and which libraries should I link with lib files and which with dll? Im kind of newbie with C++ so please try to explain it clearly.
什么应该是正确的配置(以及为什么?)以及哪些库应该与lib文件链接,哪些应该与dll链接?我对c++很熟悉,所以请试着解释清楚。
That's 'include part' of my application (It was pretty similar and it worked before i accidentally broke it):
这是我的应用程序的一部分(它非常相似,而且在我不小心把它弄断之前它是工作的):
//#define WIN32
#include <windows.h> // Must have for Windows platform builds
#include <GLTools.h>
#include <GLFrustum.h>
#include <GLBatch.h>
#include <GLMatrixStack.h>
#include <GLShaderManager.h>
#include <GLGeometryTransform.h>
#include <StopWatch.h>
//#define GLEW_STATIC
#include <GL\glew.h> // OpenGL Extension "autoloader"
//#define FREEGLUT_STATIC
#include <GL\freeglut.h>
//#include <GL\gl.h> // Microsoft OpenGL headers (version 1.1 by themselves)
#include <math.h>
#include <stdio.h>
#include <iostream>
using namespace std;
#include <PxPhysicsAPI.h>
#include <extensions/PxExtensionsAPI.h>
#include <extensions/PxDefaultErrorCallback.h>
#include <extensions/PxDefaultAllocator.h>
#include <extensions/PxDefaultSimulationFilterShader.h>
#include <extensions/PxDefaultCpuDispatcher.h>
#include <extensions/PxShapeExt.h>
#include <foundation/PxMat33.h>
#include <pxtask/PxCudaContextManager.h>
#include <physxprofilesdk\PxProfileZoneManager.h>
#include <extensions/PxSimpleFactory.h>
#pragma comment(lib, "PhysX3_x86.lib")
#pragma comment(lib, "PhysX3Common_x86.lib")
#pragma comment(lib, "PxTask.lib")
#pragma comment(lib, "PhysX3Extensions.lib")
#pragma comment(lib, "PhysXProfileSDK")
I'm not sure if last lanes are necessary if everything is set well (found it somewhere in google and it worked).
如果一切都很好(在谷歌的某个地方找到了),我不确定最后的通道是否必要。
If you need more information or more detailed error log with some configuration, just tell me and I'll provide it.
如果您需要更多的信息或更详细的错误日志和一些配置,请告诉我,我将提供它。
Thanks in advance!
提前谢谢!
EDIT:
编辑:
Debug /MDd
调试/ MDd
PxTask.lib(CudaWrapper.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultSimulationFilterShader.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtSimpleFactory.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultCpuDispatcher.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultErrorCallback.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtRigidBodyExt.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtCpuWorkerThread.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysXProfileSDK.lib(PxProfileEventImpl.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>main.obj : error LNK2019: unresolved external symbol _glewInit@0 referenced in function "void __cdecl init(void)" (?init@@YAXXZ)
1>C:\dev\SPHFluids\SPHFluids\Debug\SPHFluids.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
Release /MDd
发布/ MDd
PxTask.lib(CudaWrapper.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultSimulationFilterShader.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultErrorCallback.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultCpuDispatcher.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtSimpleFactory.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtCpuWorkerThread.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtRigidBodyExt.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysXProfileSDK.lib(PxProfileEventImpl.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>main.obj : error LNK2001: unresolved external symbol _glewInit@0
1>C:\dev\SPHFluids\SPHFluids\Release\SPHFluids.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
Release /MTd
发布/ MTd
PxTask.lib(CudaWrapper.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultSimulationFilterShader.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultErrorCallback.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtDefaultCpuDispatcher.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtSimpleFactory.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtCpuWorkerThread.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysX3Extensions.lib(ExtRigidBodyExt.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>PhysXProfileSDK.lib(PxProfileEventImpl.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fwrite already defined in LIBCMTD.lib(fwrite.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgfree.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgmalloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fgetc already defined in LIBCMTD.lib(fgetc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fprintf already defined in LIBCMTD.lib(fprintf.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: ___iob_func already defined in LIBCMTD.lib(_file.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>main.obj : error LNK2001: unresolved external symbol _glewInit@0
1>C:\dev\SPHFluids\SPHFluids\Release\SPHFluids.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
Everything without d (/MD /MT):
无d (/MD /MT):
c:\dev\soft\physx-3.2.3_pc_sdk_core\include\foundation\pxpreprocessor.h(318): fatal error C1189: #error : Exactly one of NDEBUG and _DEBUG needs to be defined by preprocessor
and it's only one configuration of lib files. I can compile gltools and freeglut other way or set #define GLEW_STATIC or #define FREEGLUT_STATIC other way... It's just too many options for a newbie. :)
它只是lib文件的一个配置。我可以用其他方式编译gltools和freeglut,或者设置#define GLEW_STATIC或#define FREEGLUT_STATIC…对新手来说,选择太多了。:)
One more:
一个:
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>main.obj : error LNK2001: unresolved external symbol "class physx::PxFlags<enum physx::PxFilterFlag::Enum,unsigned short> __cdecl physx::PxDefaultSimulationFilterShader(unsigned int,struct physx::PxFilterData,unsigned int,struct physx::PxFilterData,class physx::PxFlags<enum physx::PxPairFlag::Enum,unsigned short> &,void const *,unsigned int)" (?PxDefaultSimulationFilterShader@physx@@YA?AV?$PxFlags@W4Enum@PxFilterFlag@physx@@G@1@IUPxFilterData@1@I0AAV?$PxFlags@W4Enum@PxPairFlag@physx@@G@1@PBXI@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall physx::PxDefaultErrorCallback::~PxDefaultErrorCallback(void)" (??1PxDefaultErrorCallback@physx@@UAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall physx::PxDefaultErrorCallback::PxDefaultErrorCallback(void)" (??0PxDefaultErrorCallback@physx@@QAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: static class physx::PxProfileZoneManager & __cdecl physx::PxProfileZoneManager::createProfileZoneManager(class physx::PxFoundation *)" (?createProfileZoneManager@PxProfileZoneManager@physx@@SAAAV12@PAVPxFoundation@2@@Z)
1>main.obj : error LNK2001: unresolved external symbol "class physx::pxtask::CudaContextManager * __cdecl physx::pxtask::createCudaContextManager(class physx::PxFoundation &,class physx::pxtask::CudaContextManagerDesc const &,class physx::PxProfileZoneManager *)" (?createCudaContextManager@pxtask@physx@@YAPAVCudaContextManager@12@AAVPxFoundation@2@ABVCudaContextManagerDesc@12@PAVPxProfileZoneManager@2@@Z)
1>main.obj : error LNK2001: unresolved external symbol "class physx::PxDefaultCpuDispatcher * __cdecl physx::PxDefaultCpuDispatcherCreate(unsigned int,unsigned int *)" (?PxDefaultCpuDispatcherCreate@physx@@YAPAVPxDefaultCpuDispatcher@1@IPAI@Z)
1>main.obj : error LNK2001: unresolved external symbol __imp__PxCreateFoundation
1>main.obj : error LNK2001: unresolved external symbol _glewInit@0
1>main.obj : error LNK2001: unresolved external symbol _PxCreatePlane
1>main.obj : error LNK2001: unresolved external symbol __imp__PxRegisterArticulations
1>main.obj : error LNK2001: unresolved external symbol __imp__PxRegisterHeightFields
1>main.obj : error LNK2001: unresolved external symbol __imp__PxCreateBasePhysics
1>C:\dev\SPHFluids\SPHFluids\Release\SPHFluids.exe : fatal error LNK1120: 12 unresolved externals
1>
1>Build FAILED.
It's with all these PhysX pragmas commented.
这是所有这些PhysX pragmas的评论。
2 个解决方案
#1
0
one thing that may point you towards the solution is that physx 3.2.3 lib files are built with /MT option as indicated in their documentation (this is a part of the physx zip in the documentation folder) :
有一件事可能会让您觉得解决方案是,physx 3.2.3 lib文件是用/MT选项构建的,正如他们的文档中所示(这是文档文件夹中physx zip的一部分):
"Note The static libraries we provide with the Windows binary distribution are linked against the Multi-Threaded static C Run-Time (CRT) libraries. This means that your application must also use the same CRT flavor. If you need to use a different CRT version, you must upgrade to our source license. The source distribution can simply be recompiled using different CRT settings. " So if you are planning to link against these, you must use the /MT flag for all your other libraries as well.
注意,我们提供的静态库与Windows二进制发行版是链接在多线程的静态C运行时(CRT)库上的。这意味着应用程序也必须使用相同的CRT风格。如果您需要使用不同的CRT版本,您必须升级到我们的源许可证。可以使用不同的CRT设置重新编译源分布。因此,如果您打算链接这些内容,那么您还必须使用/MT标志为所有其他的库。
#2
0
Add a #define NDEBUG
in the file where you include physics headers. This will remove your NDEBUG issue.
在包含物理头的文件中添加#define NDEBUG。这将删除您的NDEBUG问题。
#1
0
one thing that may point you towards the solution is that physx 3.2.3 lib files are built with /MT option as indicated in their documentation (this is a part of the physx zip in the documentation folder) :
有一件事可能会让您觉得解决方案是,physx 3.2.3 lib文件是用/MT选项构建的,正如他们的文档中所示(这是文档文件夹中physx zip的一部分):
"Note The static libraries we provide with the Windows binary distribution are linked against the Multi-Threaded static C Run-Time (CRT) libraries. This means that your application must also use the same CRT flavor. If you need to use a different CRT version, you must upgrade to our source license. The source distribution can simply be recompiled using different CRT settings. " So if you are planning to link against these, you must use the /MT flag for all your other libraries as well.
注意,我们提供的静态库与Windows二进制发行版是链接在多线程的静态C运行时(CRT)库上的。这意味着应用程序也必须使用相同的CRT风格。如果您需要使用不同的CRT版本,您必须升级到我们的源许可证。可以使用不同的CRT设置重新编译源分布。因此,如果您打算链接这些内容,那么您还必须使用/MT标志为所有其他的库。
#2
0
Add a #define NDEBUG
in the file where you include physics headers. This will remove your NDEBUG issue.
在包含物理头的文件中添加#define NDEBUG。这将删除您的NDEBUG问题。