NVIDIAGameWorks / PhysX-3.4

NVIDIA PhysX SDK 3.4
https://www.nvidia.com/
2.35k stars 273 forks source link

Error unresolved external symbol __libm_sse2_sincosf_ when compiled with /MD #68

Closed SephirothFFKH closed 6 years ago

SephirothFFKH commented 6 years ago

Hi, My application is dynamically linked at run-time therefore I am compiling all PhysX libraries with /MD but, I am getting this error when compiling my application with PhysX integration:

2>PhysX3ExtensionsPROFILE.lib(ExtD6Joint.obj) : error LNK2001: unresolved external symbol __libm_sse2_sincosf_
2>PhysX3ExtensionsPROFILE.lib(ExtFixedJoint.obj) : error LNK2001: unresolved external symbol __libm_sse2_sincosf_
2>PhysX3ExtensionsPROFILE.lib(ExtPrismaticJoint.obj) : error LNK2001: unresolved external symbol __libm_sse2_sincosf_
2>PhysX3ExtensionsPROFILE.lib(ExtRevoluteJoint.obj) : error LNK2001: unresolved external symbol __libm_sse2_sincosf_
2>PhysX3VehiclePROFILE.lib(PxVehicleUpdate.obj) : error LNK2019: unresolved external symbol __libm_sse2_sincosf_ referenced in function "unsigned int __cdecl physx::PxVehicleModifyWheelContacts(class physx::PxVehicleWheels const &,unsigned int,float,float,class physx::PxContactModifyPair &)" (?PxVehicleModifyWheelContacts@physx@@YAIAEBVPxVehicleWheels@1@IMMAEAVPxContactModifyPair@1@@Z)

But, from what I could find it seem I would need Intel's libm.lib but, I can't get this library since it's not freely available. I would be very grateful if you could give me some pointers on what I am doing wrong in my integration or if there is any alternative to fix this issue.

Thank you very much

AlesBorovicka commented 6 years ago

Hi, What compiler did you used? We do not require any additional libraries, regular VC11,VC12,VC14,VC15 should work out of the box. PhysX projects are set to use /MT, but internally we compile even with /MD without any issues. Regards, Ales

SephirothFFKH commented 6 years ago

Hi, Thanks for the quick response! I am using Microsoft Visual Studio 2017 Version 15.7.3 with Microsoft (R) C/C++ Optimizing Compiler Version 19.14.26430 for x64 It's true that patches for VC15 have been causing so many compatibility issues with many of my other applications and could very well be the culprit.

Thanks

AlesBorovicka commented 6 years ago

I will try to update VS2017 to see if I can reproduce the issue, will let you know.

SephirothFFKH commented 6 years ago

Thank you I am currently downloading the VC++ 2015.3 v140 toolset for Visual Studio 2017 to see if that works better.

AlesBorovicka commented 6 years ago

That wont work, you need at least 15.5.1, there was a bug in the compiler: /Disable support for VS2017 prior version 15.5.1 for windows platform, because of a compiler bug: https://developercommunity.visualstudio.com/content/problem/66047/possible-compiler-bug.html /

SephirothFFKH commented 6 years ago

Thanks for the heads up! So I'll be waiting for your results then.

AlesBorovicka commented 6 years ago

Seems to be working fine for me with latest VS2017 15.7.1 Professional, but my compiler is this version: Microsoft (R) C/C++ Optimizing Compiler Version 19.14.26428.1 for x64

No idea what the issue could be, I would try to different VS or reinstall VS2017, maybe you also have installed some preview version? PhysX does not need any additional libraries, it should compile with VS2017 just fine.

SephirothFFKH commented 6 years ago

Hi, the issue is fixed! I think I have miss-explained my issue, I am also absolutely able to compile PhysX with VC15 without any error the issue happens when I compile my application with PhysX integration. At first I thought I made a mistake with the integration but, then I tried to compile another application, UE4, with my VC15 compiled libraries (details to get source code here: https://www.unrealengine.com/en-US/ue4-on-github) you must put the PhysX and PxShared source code in Engine\Source\ThirdParty\PhysX rename the .lib to _x64.lib and put them in Engine\Source\ThirdParty\PhysX\Lib\Win64\VS2015 and the *.dll in Engine\Binaries\ThirdParty\PhysX\Win64\VS2015 and compiling their engine threw the exact same libm error as my application.

Then, I stumbled on this page https://blogs.msdn.microsoft.com/vcblog/2017/11/02/visual-studio-build-tools-now-include-the-vs2017-and-vs2015-msvc-toolsets/ which made me realize that Microsoft naming scheme is so confusing and that the "VC++ 2015.3 v140 toolset for desktop (x86,x64)" I was downloading earlier is actually the good old stable and tested VC14 but inside Visual Studio 2017 after installing that, I was able to open vc14win64 solutions and choose "no upgrade" on both drop-downs and changed the runtime linking to /MD and all the compiled libraries compiled in both my application and in UE4.

As a side note, I am moving my application to NvCloth but, I do have some old APEX assets but, I will probably be recreating them but, just in case, are the pre-compiled GPU APEX libraries only available in /MT and also I did try to compile APEX with both the new-found VC14 compiler and the VC15 compiler and it complies perfectly with /MT but with /MD i get these errors:

1>------ Build started: Project: APEX_Clothing, Configuration: profile x64 ------
1>   Creating library ./../../lib/vc14win64-PhysX_3.4/APEX_ClothingPROFILE_x64.lib and object ./../../lib/vc14win64-PhysX_3.4/APEX_ClothingPROFILE_x64.exp
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>ClothingPhysicalMeshParameters.obj : warning LNK4217: locally defined symbol free imported in function "private: void __cdecl nvidia::clothing::ClothingPhysicalMeshParameters::buildTree(void)" (?buildTree@ClothingPhysicalMeshParameters@clothing@nvidia@@AEAAXXZ)
1>ClothingPreviewParam.obj : warning LNK4049: locally defined symbol free imported
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4049: locally defined symbol free imported
1>ClothingDebugRenderParams.obj : warning LNK4049: locally defined symbol free imported
1>ClothingGraphicalLodParameters.obj : warning LNK4049: locally defined symbol free imported
1>ClothingMaterialLibraryParameters.obj : warning LNK4049: locally defined symbol free imported
1>ClothingModuleParameters.obj : warning LNK4049: locally defined symbol free imported
1>ClothingActorParam.obj : warning LNK4217: locally defined symbol free imported in function "void __cdecl `dynamic atexit destructor for 'private: static class physx::shdfnd::MutexT<class physx::shdfnd::RawAllocator> nvidia::clothing::ClothingActorParam::mBuiltFlagMutex''(void)" (??__F?mBuiltFlagMutex@ClothingActorParam@clothing@nvidia@@0V?$MutexT@VRawAllocator@shdfnd@physx@@@shdfnd@physx@@A@@YAXXZ)
1>ClothingAssetParameters.obj : warning LNK4049: locally defined symbol free imported
1>ClothingCookedParam.obj : warning LNK4049: locally defined symbol free imported
1>ClothingCookedPhysX3Param.obj : warning LNK4049: locally defined symbol free imported
1>ClothingPhysicalMeshParameters.obj : warning LNK4217: locally defined symbol malloc imported in function "private: void __cdecl nvidia::clothing::ClothingPhysicalMeshParameters::buildTree(void)" (?buildTree@ClothingPhysicalMeshParameters@clothing@nvidia@@AEAAXXZ)
1>ClothingPreviewParam.obj : warning LNK4049: locally defined symbol malloc imported
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4049: locally defined symbol malloc imported
1>ClothingDebugRenderParams.obj : warning LNK4049: locally defined symbol malloc imported
1>ClothingGraphicalLodParameters.obj : warning LNK4049: locally defined symbol malloc imported
1>ClothingMaterialLibraryParameters.obj : warning LNK4049: locally defined symbol malloc imported
1>ClothingModuleParameters.obj : warning LNK4049: locally defined symbol malloc imported
1>ClothingActorParam.obj : warning LNK4217: locally defined symbol malloc imported in function "void __cdecl `dynamic initializer for 'private: static class physx::shdfnd::MutexT<class physx::shdfnd::RawAllocator> nvidia::clothing::ClothingActorParam::mBuiltFlagMutex''(void)" (??__E?mBuiltFlagMutex@ClothingActorParam@clothing@nvidia@@0V?$MutexT@VRawAllocator@shdfnd@physx@@@shdfnd@physx@@A@@YAXXZ)
1>ClothingAssetParameters.obj : warning LNK4049: locally defined symbol malloc imported
1>ClothingCookedParam.obj : warning LNK4049: locally defined symbol malloc imported
1>ClothingCookedPhysX3Param.obj : warning LNK4049: locally defined symbol malloc imported
1>ApexCommonPROFILE.lib(ApexSubdivider.obj) : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ApexCommonPROFILE.lib(ApexSDKHelpers.obj) : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ApexCommonPROFILE.lib(ApexSharedUtils.obj) : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ApexCommonPROFILE.lib(ApexMeshHash.obj) : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ApexCommonPROFILE.lib(ApexQuadricSimplifier.obj) : warning LNK4049: locally defined symbol __std_type_info_name imported
1>Simulation.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ApexCommonPROFILE.lib(ApexRWLockable.obj) : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ApexCommonPROFILE.lib(ApexContext.obj) : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ApexCommonPROFILE.lib(ApexActor.obj) : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ExtClothFabricCooker.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ExtClothGeodesicTetherCooker.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ExtClothMeshQuadifier.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ExtClothSimpleTetherCooker.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ModuleClothingImpl.obj : warning LNK4217: locally defined symbol __std_type_info_name imported in function "public: virtual class NvParameterized::Interface * __cdecl nvidia::clothing::ClothingActorParamFactory::finish(class NvParameterized::Traits *,void *,void *,int *)" (?finish@ClothingActorParamFactory@clothing@nvidia@@UEAAPEAVInterface@NvParameterized@@PEAVTraits@5@PEAX1PEAH@Z)
1>SwInterCollision.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>SwSolver.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>Cooking.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ClothingPhysicalMeshImpl.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ClothingRenderProxyImpl.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ClothingScene.obj : warning LNK4217: locally defined symbol __std_type_info_name imported in function "public: void __cdecl nvidia::clothing::ClothingScene::setSceneRunning(bool)" (?setSceneRunning@ClothingScene@clothing@nvidia@@QEAAX_N@Z)
1>CookingAbstract.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ClothingActorImpl.obj : warning LNK4217: locally defined symbol __std_type_info_name imported in function "public: __cdecl nvidia::clothing::ClothingActorImpl::ClothingActorImpl(class NvParameterized::Interface const &,class nvidia::clothing::ClothingActorProxy *,class nvidia::clothing::ClothingPreviewProxy *,class nvidia::clothing::ClothingAssetImpl *,class nvidia::clothing::ClothingScene *)" (??0ClothingActorImpl@clothing@nvidia@@QEAA@AEBVInterface@NvParameterized@@PEAVClothingActorProxy@12@PEAVClothingPreviewProxy@12@PEAVClothingAssetImpl@12@PEAVClothingScene@12@@Z)
1>ClothingAssetAuthoringImpl.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ClothingAssetImpl.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ClothingCollisionImpl.obj : warning LNK4049: locally defined symbol __std_type_info_name imported
1>ClothingAssetImpl.obj : warning LNK4217: locally defined symbol atoi imported in function "public: enum NvParameterized::ErrorType __cdecl NvParameterized::Handle::set(class NvParameterized::Interface const *,char const *)" (?set@Handle@NvParameterized@@QEAA?AW4ErrorType@2@PEBVInterface@2@PEBD@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4217: locally defined symbol atoi imported in function "protected: virtual enum NvParameterized::ErrorType __cdecl NvParameterized::NvParameters::rawGetParamQuatArray(class NvParameterized::Handle const &,class physx::PxQuat *,int,int)const " (?rawGetParamQuatArray@NvParameters@NvParameterized@@MEBA?AW4ErrorType@2@AEBVHandle@2@PEAVPxQuat@physx@@HH@Z)
1>Cooking.obj : warning LNK4217: locally defined symbol fclose imported in function "private: void __cdecl nvidia::clothing::Cooking::dumpObj(char const *,unsigned int)const " (?dumpObj@Cooking@clothing@nvidia@@AEBAXPEBDI@Z)
1>Cooking.obj : warning LNK4217: locally defined symbol __stdio_common_vfprintf imported in function fprintf
1>Cooking.obj : warning LNK4049: locally defined symbol __stdio_common_vsprintf_s imported
1>ApexCommonPROFILE.lib(ApexSharedUtils.obj) : warning LNK4217: locally defined symbol memmove imported in function "private: void __cdecl physx::general_PxIOStream2::PxMemoryBufferBase<class physx::general_PxIOStream2::PxMemoryBufferAllocator>::growWriteBuffer(unsigned int)" (?growWriteBuffer@?$PxMemoryBufferBase@VPxMemoryBufferAllocator@general_PxIOStream2@physx@@@general_PxIOStream2@physx@@AEAAXI@Z)
1>ApexCommonPROFILE.lib(ApexSharedUtils.obj) : warning LNK4217: locally defined symbol qsort imported in function "void __cdecl nvidia::apex::boundsCalculateOverlaps(class physx::shdfnd::Array<struct nvidia::apex::IntPair,class physx::shdfnd::ReflectionAllocator<struct nvidia::apex::IntPair> > &,enum nvidia::apex::Bounds3Axes,struct nvidia::apex::BoundsRep const *,unsigned int,unsigned int,struct nvidia::apex::BoundsInteractions const &,bool)" (?boundsCalculateOverlaps@apex@nvidia@@YAXAEAV?$Array@UIntPair@apex@nvidia@@V?$ReflectionAllocator@UIntPair@apex@nvidia@@@shdfnd@physx@@@shdfnd@physx@@W4Bounds3Axes@12@PEBUBoundsRep@12@IIAEBUBoundsInteractions@12@_N@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4217: locally defined symbol strtol imported in function "short __cdecl physx::general_string_parsing2::PxAsc::strToI16(char const *,char const * *)" (?strToI16@PxAsc@general_string_parsing2@physx@@YAFPEBDPEAPEBD@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4217: locally defined symbol strtoul imported in function "unsigned short __cdecl physx::general_string_parsing2::PxAsc::strToU16(char const *,char const * *)" (?strToU16@PxAsc@general_string_parsing2@physx@@YAGPEBDPEAPEBD@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4217: locally defined symbol _strtoi64 imported in function "__int64 __cdecl physx::general_string_parsing2::PxAsc::strToI64(char const *,char const * *)" (?strToI64@PxAsc@general_string_parsing2@physx@@YA_JPEBDPEAPEBD@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4217: locally defined symbol _strtoui64 imported in function "unsigned __int64 __cdecl physx::general_string_parsing2::PxAsc::strToU64(char const *,char const * *)" (?strToU64@PxAsc@general_string_parsing2@physx@@YA_KPEBDPEAPEBD@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4217: locally defined symbol strchr imported in function "char const * __cdecl physx::general_string_parsing2::PxAsc::valueToStr(float,char *,unsigned int)" (?valueToStr@PxAsc@general_string_parsing2@physx@@YAPEBDMPEADI@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : warning LNK4217: locally defined symbol isdigit imported in function "double __cdecl physx::general_string_parsing2::PxAsc::strtod_fast(char const *)" (?strtod_fast@PxAsc@general_string_parsing2@physx@@YANPEBD@Z)
1>ClothingActorImpl.obj : error LNK2019: unresolved external symbol __imp__fpclass referenced in function "public: static bool __cdecl nvidia::clothing::ClothingActorImpl::isValidDesc(class NvParameterized::Interface const &)" (?isValidDesc@ClothingActorImpl@clothing@nvidia@@SA_NAEBVInterface@NvParameterized@@@Z)
1>ApexCommonPROFILE.lib(ApexSharedUtils.obj) : error LNK2001: unresolved external symbol __imp__fpclass
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : error LNK2001: unresolved external symbol __imp__fpclass
1>Cooking.obj : error LNK2019: unresolved external symbol __imp_fopen_s referenced in function "private: void __cdecl nvidia::clothing::Cooking::dumpObj(char const *,unsigned int)const " (?dumpObj@Cooking@clothing@nvidia@@AEBAXPEBDI@Z)
1>Cooking.obj : error LNK2019: unresolved external symbol __imp_asctime referenced in function "private: void __cdecl nvidia::clothing::Cooking::dumpObj(char const *,unsigned int)const " (?dumpObj@Cooking@clothing@nvidia@@AEBAXPEBDI@Z)
1>Cooking.obj : error LNK2019: unresolved external symbol __imp__localtime64 referenced in function "private: void __cdecl nvidia::clothing::Cooking::dumpObj(char const *,unsigned int)const " (?dumpObj@Cooking@clothing@nvidia@@AEBAXPEBDI@Z)
1>Cooking.obj : error LNK2019: unresolved external symbol __imp__time64 referenced in function "private: void __cdecl nvidia::clothing::Cooking::dumpObj(char const *,unsigned int)const " (?dumpObj@Cooking@clothing@nvidia@@AEBAXPEBDI@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : error LNK2019: unresolved external symbol __imp_realloc referenced in function "public: virtual void __cdecl NvParameterized::DefinitionImpl::addChild(class NvParameterized::Definition *)" (?addChild@DefinitionImpl@NvParameterized@@UEAAXPEAVDefinition@2@@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : error LNK2019: unresolved external symbol __imp_rand referenced in function "private: void __cdecl NvParameterized::NvParameters::initRandom(class NvParameterized::Handle &)" (?initRandom@NvParameters@NvParameterized@@AEAAXAEAVHandle@2@@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : error LNK2019: unresolved external symbol __imp_strtod referenced in function "double __cdecl physx::general_string_parsing2::PxAsc::strtod_fast(char const *)" (?strtod_fast@PxAsc@general_string_parsing2@physx@@YANPEBD@Z)
1>NvParameterizedPROFILE.lib(NvParameterized.obj) : error LNK2019: unresolved external symbol __imp_strncmp referenced in function "float __cdecl physx::general_string_parsing2::PxAsc::strToF32(char const *,char const * *)" (?strToF32@PxAsc@general_string_parsing2@physx@@YAMPEBDPEAPEBD@Z)
1>./../../bin/vc14win64-PhysX_3.4\APEX_ClothingPROFILE_x64.dll : fatal error LNK1120: 9 unresolved externals
1>Done building project "APEX_Clothing.vcxproj" -- FAILED.
2>------ Build started: Project: APEX_Loader, Configuration: profile x64 ------
2>   Creating library ./../../lib/vc14win64-PhysX_3.4/APEX_LoaderPROFILE_x64.lib and object ./../../lib/vc14win64-PhysX_3.4/APEX_LoaderPROFILE_x64.exp
2>APEX_Loader.vcxproj -> C:\PhysX-3.4-master\APEX_1.4\compiler\vc14win64-PhysX_3.4\./../../bin/vc14win64-PhysX_3.4\APEX_LoaderPROFILE_x64.dll
2>APEX_Loader.vcxproj -> ./../../bin/vc14win64-PhysX_3.4\/APEX_LoaderPROFILE_x64.dll.pdb (Full PDB)
========== Build: 1 succeeded, 1 failed, 11 up-to-date, 0 skipped ==========

But, I think I should just let APEX rest in peace and I will probably not use APEX since it's deprecated anyways so I think it's not a issue.

Thanks again for checking the PhysX issue for me!

SephirothFFKH commented 6 years ago

Disregard my comment about APEX not compiling. Adding msvcrt.lib and msvcmrt.lib to the dependencies and /NODEFAULTLIB:LIBCMT to command line option of APEX_Clothing fixes the issue and it compiles perfectly!

AlesBorovicka commented 6 years ago

Good, glad it works for you now. Will close the issue now.