nvpro-samples / optix_advanced_samples

426 stars 87 forks source link

Builds fine on VS2015, but not VS2017 nor VS2019 #7

Closed elbrandt closed 5 years ago

elbrandt commented 5 years ago

CMake runs successfully for VS2017 and VS2019 targets, however, building the solutions in 2017 or 2019 both error with failure to generate PTX files. Is there a workaround or will this be fixed at some point in the future? Thanks.

dogod621 commented 5 years ago

Since VS 2017, they change the folder structure, please follow this post to modify CUDA_HOST_COMPILER in Cmake: https://devtalk.nvidia.com/default/topic/1049059/optix-6-0-0-build-error-with-vs2017-cuda-10-0/

dogod621 commented 5 years ago

You can build original OptiX SDK samples first, if build pass, then try this one

elbrandt commented 5 years ago

Thank you, this fixes the problem perfectly.

Is there (or will there be a way) to fix this 'automatically' in CMakeLists.txt files? (I am not a CMake expert). I ask because our own project uses the same PTX generation method as these samples, and we'd like to make the cmake process as painless as possible for our team members and users.

droettger commented 5 years ago

That is a problem inside the FindCUDA.cmake file present in the OptiX SDK and the OptiX Advanced Samples . It existed before CMake added it as well and now it's outdated. The one shipping with CMake (I'm using CMake 3.12.4 at this time) contains the proper distinction of the MSVS compiler folder location and sets the CUDA_HOST_COMPILER variable correctly. Means simply rename or delete the FindCUDA.cmake inside the OptiX examples and it should work out of the box. ( I have not tested that with even newer CMake versions.)

elbrandt commented 5 years ago

Thanks @droettger Very good information. I am using CMake 3.14.1 so I will try your advice of removing FindCUDA.cmake in the examples.

dogod621 commented 5 years ago

@elbrandt @droettger NO~ Just delete them is not working. These FindCUDA is different. I manually merge these FindCUDAs by my self, this version works for me https://github.com/dogod621/FindCUDA_for_OptiX

VS project create via cmake-3.14's FindCUDA cannot correct compile original sutil tools of OptiX SDK. It will cause LNK2019 errors:

1>------ 已開始建置: 專案: sutil_sdk, 組態: Debug x64 ------
1>   正在建立程式庫 E:/OptiXSamples/build/lib/Debug/sutil_sdk.lib 和物件 E:/OptiXSamples/build/lib/Debug/sutil_sdk.exp
1>sutil.obj : error LNK2019: 無法解析的外部符號 nvrtcGetErrorString 在函式 "void __cdecl getPtxFromCuString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *,char const *,char const * *)" (?getPtxFromCuString@@YAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD11PEAPEBD@Z) 中被參考
1>sutil.obj : error LNK2019: 無法解析的外部符號 nvrtcCreateProgram 在函式 "void __cdecl getPtxFromCuString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *,char const *,char const * *)" (?getPtxFromCuString@@YAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD11PEAPEBD@Z) 中被參考
1>sutil.obj : error LNK2019: 無法解析的外部符號 nvrtcDestroyProgram 在函式 "void __cdecl getPtxFromCuString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *,char const *,char const * *)" (?getPtxFromCuString@@YAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD11PEAPEBD@Z) 中被參考
1>sutil.obj : error LNK2019: 無法解析的外部符號 nvrtcCompileProgram 在函式 "void __cdecl getPtxFromCuString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *,char const *,char const * *)" (?getPtxFromCuString@@YAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD11PEAPEBD@Z) 中被參考
1>sutil.obj : error LNK2019: 無法解析的外部符號 nvrtcGetPTXSize 在函式 "void __cdecl getPtxFromCuString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *,char const *,char const * *)" (?getPtxFromCuString@@YAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD11PEAPEBD@Z) 中被參考
1>sutil.obj : error LNK2019: 無法解析的外部符號 nvrtcGetPTX 在函式 "void __cdecl getPtxFromCuString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *,char const *,char const * *)" (?getPtxFromCuString@@YAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD11PEAPEBD@Z) 中被參考
1>sutil.obj : error LNK2019: 無法解析的外部符號 nvrtcGetProgramLogSize 在函式 "void __cdecl getPtxFromCuString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *,char const *,char const * *)" (?getPtxFromCuString@@YAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD11PEAPEBD@Z) 中被參考
1>sutil.obj : error LNK2019: 無法解析的外部符號 nvrtcGetProgramLog 在函式 "void __cdecl getPtxFromCuString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *,char const *,char const * *)" (?getPtxFromCuString@@YAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD11PEAPEBD@Z) 中被參考
1>E:\OptiXSamples\build\bin\Debug\sutil_sdk.dll : fatal error LNK1120: 8 個無法解析的外部符號
1>專案 "sutil_sdk.vcxproj" 建置完成 -- 失敗。
========== 建置: 0 成功、1 失敗、34 最新、0 略過 ==========