zhiwei-c / Monte-Carlo-Path-Tracing

A simple Monte Carlo path tracer based on assignment 7 of GAMES101 originally, accelerated by C++ multithreading or CUDA.
81 stars 7 forks source link

关于项目的编译 #2

Closed Reed-yang closed 10 months ago

Reed-yang commented 10 months ago

使用MSVC 和 CUDA 12.2编译时报了很多语法错误,节选如下。重新调试、安装VS以及CUDA,尝试Clang编译等均有错,求助0.0

[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(818): error : identifier "ReadConductorIor" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             ReadConductorIor(bsdf_node, &eta, &k);
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(826): error : identifier "ReadDielectricIor" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             const float int_ior = ReadDielectricIor(bsdf_node, {"int_ior", "intIOR"}, 1.5046f);
[build]                                   ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(830): error : identifier "ReadTexture" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]                 id_roughness = ReadTexture(bsdf_node, {"alpha", "alpha_u", "alphaU"}, 0.1f);
[build]                                ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(832): error : identifier "ReadTexture" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]                 id_roughness = ReadTexture(bsdf_node, std::vector<std::string>{}, 0.001f);
[build]                                ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(833): error : identifier "ReadTexture" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             const uint32_t id_diffuse_reflectance = ReadTexture(
[build]                                                     ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(846): error : identifier "ReadTexture" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             uint32_t id_reflectance = ReadTexture(bsdf_node, std::vector<std::string>{}, 0.5f);
[build]                                       ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(852): error : identifier "id_bsdf_mp_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]         id_bsdf_mp_[id] = id_bsdf;
[build]         ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(856): error : name followed by "::" must be a class or namespace name [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]     void ConfigParser::ReadShape(pugi::xml_node shape_node)
[build]          ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(859): error : identifier "info_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]         const uint32_t index = info_.instance_info_buffer.size();
[build]                                ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(899): error : identifier "id_texture_mp_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             id_texture_mp_[texture_id] = info_.texture_info_buffer.size();
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(906): error : identifier "id_bsdf_mp_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             id_bsdf_mp_[id] = id_bsdf;
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(910): error : identifier "ReadBsdf" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             id_bsdf = ReadBsdf(shape_node.child("bsdf"), "", kInvalidId, kInvalidId, false);
[build]                       ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(918): error : identifier "id_bsdf_mp_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]                 if (id_bsdf_mp_.count(bsdf_id))
[build]                     ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(927): error : identifier "ReadBsdf" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]                 id_bsdf = ReadBsdf(pugi::xml_node(), "", kInvalidId, kInvalidId, false);
[build]                           ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(937): error : identifier "CreateCube" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             CreateCube(to_world, id_bsdf);
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(942): error : identifier "CreateRectangle" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             CreateRectangle(to_world, id_bsdf);
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(947): error : identifier "CreateSphere" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             CreateSphere(mitsuba_parser::ReadVec3(shape_node, {"center"}, Vec3(0)),
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(954): error : identifier "CreateDisk" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             CreateDisk(to_world, id_bsdf);
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(967): error : identifier "config_file_directory_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             CreateMeshes(config_file_directory_ + filename, index_shape, to_world, flip_texcoords,
[build]                          ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(967): error : identifier "CreateMeshes" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             CreateMeshes(config_file_directory_ + filename, index_shape, to_world, flip_texcoords,
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(979): error : name followed by "::" must be a class or namespace name [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]     void ConfigParser::ReadEmitter(pugi::xml_node emitter_node)
[build]          ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(986): error : identifier "ReadTexture" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             const uint32_t id_radiance = ReadTexture(emitter_node, {"radiance"}, 1.0f);
[build]                                          ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(987): error : identifier "info_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             info_.env_map = new EnvMap(id_radiance, 1.0f, Mat4());
[build]             ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(994): error : identifier "info_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             int width_target = static_cast<int>(info_.camera.width() * 360 / info_.camera.fov_x());
[build]                                                 ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(995): error : identifier "config_file_directory_" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             const uint32_t id_radiance = ReadBitmap(config_file_directory_ + filename,
[build]                                                     ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(995): error : identifier "ReadBitmap" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]             const uint32_t id_radiance = ReadBitmap(config_file_directory_ + filename,
[build]                                          ^
[build]   
[build] D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu(1016): error : identifier "LocationDate" is undefined [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[build]                 LocationDate location_date;
[build]                 ^
[build]   
[build]   Error limit reached.
[build]   100 errors detected in the compilation of "D:/CodeLib/Graphics/Monte-Carlo-Path-Tracing/src/utils/config_parser.cu".
[build]   Compilation terminated.
[build]   config_parser.cu
[build] D:\VS\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.2.targets(799,9): error MSB3721: 命令“"D:\PATH\cuda\v12.2\bin\nvcc.exe"  --use-local-env -ccbin "D:\VS\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64" -x cu -rdc=true  -I"D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\extern\ArHosekSkyModel" -I"D:\PATH\vcpkg\installed\x64-windows\include" -I"D:\PATH\vcpkg\installed\x64-windows\include\miniz" -ID:\PATH\cuda\v12.2\include     --keep-dir x64\Debug  -maxrregcount=0   --machine 64 --compile -cudart static -std=c++17 --generate-code=arch=compute_52,code=[compute_52,sm_52] -Xcompiler="/EHsc /wd 4819 -Zi -Ob0" -g  -D_WINDOWS -DENABLE_CUDA -DENABLE_VIEWER -D"CMAKE_INTDIR=\"Debug\"" -D_MBCS -DWIN32 -D_WINDOWS -DENABLE_CUDA -DENABLE_VIEWER -D"CMAKE_INTDIR=\"Debug\"" -Xcompiler "/EHsc /W1 /nologo /Od /FS /Zi /RTC1 /MDd /GR" -Xcompiler "/FdRayTracer.dir\Debug\vc143.pdb" -o RayTracer.dir\Debug\config_parser.obj "D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\src\utils\config_parser.cu"”已退出,返回代码为 4。 [D:\CodeLib\Graphics\Monte-Carlo-Path-Tracing\build\RayTracer.vcxproj]
[proc] 命令“"C:\Program Files\CMake\bin\cmake.EXE" --build d:/CodeLib/Graphics/Monte-Carlo-Path-Tracing/build --config Debug --target ALL_BUILD -j 18 --”已退出,代码为 1
[driver] 生成完毕: 00:00:20.702
[build] 生成已完成,退出代码为 1
zhiwei-c commented 10 months ago

我使用 CUDA 12.3 和 Visual Studio 2022 附带的 MSVC 编译项目没有问题,您可以尝试一下。

Reed-yang commented 10 months ago

我使用 CUDA 12.3 和 Visual Studio 2022 附带的 MSVC 编译项目没有问题,您可以尝试一下。

使用与您完全相同的平台后仍然报有同样的错误,而且观察数百个"语法错误"猜测应该是工具问题,能否提供您项目中所使用的CMakesettings.json 以便我进行进一步调试0.0

zhiwei-c commented 10 months ago

图片

我使用 scoop 安装了 CMake、ninja 和 vcpkg,使用 vscode 配合 c++及 cmake 插件生成了项目,产生的 CMakesettings.json 文件内容如图。

Reed-yang commented 10 months ago

完全一致仍然无法生成😭放弃了

zhiwei-c commented 10 months ago

确实不知道是什么原因。 我这边是可以编译通过的。

Reed-yang commented 10 months ago

鉴于CMake的可读性和迁移性,实在是无法找出问题所在,恳请您拨冗写一份Xmake版的配置文件,也顺便向您推荐在项目中尝试使用xmake,感谢!