PhysX in Visual Studio 2015

I’m attempting to upgrade our engine based on PhysX 3.2.2 in VS 2010 to use VS 2015, and I cannot link against the SDK libraries. I’ve had success in the past linking PhysX 3.2.5 in VS 2013, but have not had the same luck here. In a desperate attempt, I tried building PhysX 3.3 from GitHub, but the SDK fails to build with a handful of linker errors I’m not sure I can fix on my own.

Has anyone had any success integrating PhysX into a project built with VC14? Ideally, I’d like the 3.2.2 or 3.2.5 binaries compiled in VS 2015 with /MD, but if that’s not possible, I’d settle for some help getting 3.3 to compile.

I’m on the same road, disable /WX and you have to include to remove the “abs” error then you have the debug lib compiled but I still have one error for the release about nvcuda.

Debug builds fine for me, but the other configs all give “LNK2019: Unresolved External Symbol” for calls to NpScene::multiQuery on lines 440, 453, and 467 in PhysX::NpBatchQuery.cpp.

You right, the nvcuda is a warning :

1>LINK : warning LNK4199: /DELAYLOAD:nvcuda.dll ignored; no imports found from nvcuda.dll
1>NpBatchQuery.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physx::NpSceneQueries::multiQuery<struct physx::PxRaycastHit>(struct physx::MultiQueryInput const &,struct physx::PxHitCallback<struct physx::PxRaycastHit> &,class physx::PxFlags<enum physx::PxHitFlag::Enum,unsigned short>,struct physx::PxQueryCache const *,struct physx::PxQueryFilterData const &,class physx::PxQueryFilterCallback *,struct physx::BatchQueryFilterData *)const " (??$multiQuery@UPxRaycastHit@physx@@@NpSceneQueries@physx@@QBE_NABUMultiQueryInput@1@AAU?$PxHitCallback@UPxRaycastHit@physx@@@1@V?$PxFlags@W4Enum@PxHitFlag@physx@@G@1@PBUPxQueryCache@1@ABUPxQueryFilterData@1@PAVPxQueryFilterCallback@1@PAUBatchQueryFilterData@1@@Z) referenced in function "public: virtual void __thiscall physx::NpBatchQuery::execute(void)" (?execute@NpBatchQuery@physx@@UAEXXZ)
1>NpBatchQuery.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physx::NpSceneQueries::multiQuery<struct physx::PxOverlapHit>(struct physx::MultiQueryInput const &,struct physx::PxHitCallback<struct physx::PxOverlapHit> &,class physx::PxFlags<enum physx::PxHitFlag::Enum,unsigned short>,struct physx::PxQueryCache const *,struct physx::PxQueryFilterData const &,class physx::PxQueryFilterCallback *,struct physx::BatchQueryFilterData *)const " (??$multiQuery@UPxOverlapHit@physx@@@NpSceneQueries@physx@@QBE_NABUMultiQueryInput@1@AAU?$PxHitCallback@UPxOverlapHit@physx@@@1@V?$PxFlags@W4Enum@PxHitFlag@physx@@G@1@PBUPxQueryCache@1@ABUPxQueryFilterData@1@PAVPxQueryFilterCallback@1@PAUBatchQueryFilterData@1@@Z) referenced in function "public: virtual void __thiscall physx::NpBatchQuery::execute(void)" (?execute@NpBatchQuery@physx@@UAEXXZ)
1>NpBatchQuery.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physx::NpSceneQueries::multiQuery<struct physx::PxSweepHit>(struct physx::MultiQueryInput const &,struct physx::PxHitCallback<struct physx::PxSweepHit> &,class physx::PxFlags<enum physx::PxHitFlag::Enum,unsigned short>,struct physx::PxQueryCache const *,struct physx::PxQueryFilterData const &,class physx::PxQueryFilterCallback *,struct physx::BatchQueryFilterData *)const " (??$multiQuery@UPxSweepHit@physx@@@NpSceneQueries@physx@@QBE_NABUMultiQueryInput@1@AAU?$PxHitCallback@UPxSweepHit@physx@@@1@V?$PxFlags@W4Enum@PxHitFlag@physx@@G@1@PBUPxQueryCache@1@ABUPxQueryFilterData@1@PAVPxQueryFilterCallback@1@PAUBatchQueryFilterData@1@@Z) referenced in function "public: virtual void __thiscall physx::NpBatchQuery::execute(void)" (?execute@NpBatchQuery@physx@@UAEXXZ)
1>./../../../bin/vc12win32\PhysX3_x86.dll : fatal error LNK1120: 3 unresolved externals

You can get it to compile in vs2015. Just change all <math.h> to and find the comment

“// explicit instantiations for multiQuery to fix link errors on android”

then enable the block underneath it.

Thanks! Worked for me.

However, I also had to add the /Wv:18 flag because I was getting warnings and errors like this:

Warning	C4577	'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc (compiling source file ..\..\PhysXVehicle\src\PxVehicleSDK.cpp)	PhysXVehicle	C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath	50
Error	C2220	warning treated as error - no 'object' file generated (compiling source file ..\..\PhysXVehicle\src\PhysXMetaData\src\PxVehicleAutoGeneratedMetaDataObjects.cpp)	PhysXVehicle	C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath	50