lzqsd / OptixRenderer

An optix-based GPU path tracer
MIT License
89 stars 33 forks source link

Link Error after cmake #2

Open LeoDarcy opened 3 years ago

LeoDarcy commented 3 years ago

Hi, I have link error when I build solution in Visual Studio 2017. It may be caused by different versions of Optix, DevIL or CUDA. (I find the code won't work with Optix 7.0 or higher). How can I solve this problem and what is the version of Optix and Devil you suggest? My environment is: Windows 10, Optix 6.0, DevIL 1.8.0, CUDA10.1. The error message is following:

1>Camera.obj : error LNK2019: 无法解析的外部符号 imp_rtVariableSet3fv,该符号在函数 "public: void cdecl optix::VariableObj::setFloat(struct optix::float3)" (?setFloat@VariableObj@optix@@QEAAXUfloat3@2@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtVariableSet3fv 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtVariableSetObject,该符号在函数 "public: void cdecl optix::VariableObj::setBuffer(class optix::Handle)" (?setBuffer@VariableObj@optix@@QEAAXV?$Handle@VBufferObj@optix@@@2@@Z) 中被引用 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtVariableGetContext,该符号在函数 "public: virtual class optix::Handle cdecl optix::VariableObj::getContext(void)const " (?getContext@VariableObj@optix@@UEBA?AV?$Handle@VContextObj@optix@@@2@XZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtVariableGetContext 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtContextDestroy,该符号在函数 "public: virtual void cdecl optix::ContextObj::destroy(void)" (?destroy@ContextObj@optix@@UEAAXXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtContextDestroy 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtContextValidate,该符号在函数 "public: virtual void cdecl optix::ContextObj::validate(void)" (?validate@ContextObj@optix@@UEAAXXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtContextValidate 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtContextGetErrorString,该符号在函数 "public: static class optix::Exception cdecl optix::Exception::makeException(enum RTresult,struct RTcontext_api *)" (?makeException@Exception@optix@@SA?AV12@W4RTresult@@PEAURTcontext_api@@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtContextGetErrorString 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtContextDeclareVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::ContextObj::declareVariable(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?declareVariable@ContextObj@optix@@UEAA?AV?$Handle@VVariableObj@optix@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtContextDeclareVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtContextQueryVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::ContextObj::queryVariable(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)const " (?queryVariable@ContextObj@optix@@UEBA?AV?$Handle@VVariableObj@optix@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtContextQueryVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtContextRemoveVariable,该符号在函数 "public: virtual void cdecl optix::ContextObj::removeVariable(class optix::Handle)" (?removeVariable@ContextObj@optix@@UEAAXV?$Handle@VVariableObj@optix@@@2@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtContextRemoveVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtContextGetVariableCount,该符号在函数 "public: virtual unsigned int cdecl optix::ContextObj::getVariableCount(void)const " (?getVariableCount@ContextObj@optix@@UEBAIXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtContextGetVariableCount 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtContextGetVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::ContextObj::getVariable(unsigned int)const " (?getVariable@ContextObj@optix@@UEBA?AV?$Handle@VVariableObj@optix@@@2@I@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtContextGetVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramCreateFromPTXFile,该符号在函数 "public: class optix::Handle cdecl optix::ContextObj::createProgramFromPTXFile(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?createProgramFromPTXFile@ContextObj@optix@@QEAA?AV?$Handle@VProgramObj@optix@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramCreateFromPTXFile 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramDestroy,该符号在函数 "public: virtual void cdecl optix::ProgramObj::destroy(void)" (?destroy@ProgramObj@optix@@UEAAXXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramDestroy 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramValidate,该符号在函数 "public: virtual void cdecl optix::ProgramObj::validate(void)" (?validate@ProgramObj@optix@@UEAAXXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramValidate 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramGetContext,该符号在函数 "public: virtual class optix::Handle cdecl optix::ProgramObj::getContext(void)const " (?getContext@ProgramObj@optix@@UEBA?AV?$Handle@VContextObj@optix@@@2@XZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramGetContext 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramDeclareVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::ProgramObj::declareVariable(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?declareVariable@ProgramObj@optix@@UEAA?AV?$Handle@VVariableObj@optix@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramDeclareVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramQueryVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::ProgramObj::queryVariable(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)const " (?queryVariable@ProgramObj@optix@@UEBA?AV?$Handle@VVariableObj@optix@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramQueryVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramRemoveVariable,该符号在函数 "public: virtual void cdecl optix::ProgramObj::removeVariable(class optix::Handle)" (?removeVariable@ProgramObj@optix@@UEAAXV?$Handle@VVariableObj@optix@@@2@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramRemoveVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramGetVariableCount,该符号在函数 "public: virtual unsigned int cdecl optix::ProgramObj::getVariableCount(void)const " (?getVariableCount@ProgramObj@optix@@UEBAIXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramGetVariableCount 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtProgramGetVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::ProgramObj::getVariable(unsigned int)const " (?getVariable@ProgramObj@optix@@UEBA?AV?$Handle@VVariableObj@optix@@@2@I@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtProgramGetVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceCreate,该符号在函数 "public: class optix::Handle cdecl optix::ContextObj::createGeometryInstance(void)" (?createGeometryInstance@ContextObj@optix@@QEAA?AV?$Handle@VGeometryInstanceObj@optix@@@2@XZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceCreate 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceDestroy,该符号在函数 "public: virtual void cdecl optix::GeometryInstanceObj::destroy(void)" (?destroy@GeometryInstanceObj@optix@@UEAAXXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceDestroy 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceValidate,该符号在函数 "public: virtual void cdecl optix::GeometryInstanceObj::validate(void)" (?validate@GeometryInstanceObj@optix@@UEAAXXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceValidate 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceGetContext,该符号在函数 "public: virtual class optix::Handle cdecl optix::GeometryInstanceObj::getContext(void)const " (?getContext@GeometryInstanceObj@optix@@UEBA?AV?$Handle@VContextObj@optix@@@2@XZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceGetContext 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceSetGeometry,该符号在函数 "public: void cdecl optix::GeometryInstanceObj::setGeometry(class optix::Handle)" (?setGeometry@GeometryInstanceObj@optix@@QEAAXV?$Handle@VGeometryObj@optix@@@2@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceSetGeometry 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceSetMaterialCount,该符号在函数 "public: void cdecl optix::GeometryInstanceObj::setMaterialCount(unsigned int)" (?setMaterialCount@GeometryInstanceObj@optix@@QEAAXI@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceSetMaterialCount 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceSetMaterial,该符号在函数 "public: void cdecl optix::GeometryInstanceObj::setMaterial(unsigned int,class optix::Handle)" (?setMaterial@GeometryInstanceObj@optix@@QEAAXIV?$Handle@VMaterialObj@optix@@@2@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceSetMaterial 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceDeclareVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::GeometryInstanceObj::declareVariable(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?declareVariable@GeometryInstanceObj@optix@@UEAA?AV?$Handle@VVariableObj@optix@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceDeclareVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceQueryVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::GeometryInstanceObj::queryVariable(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)const " (?queryVariable@GeometryInstanceObj@optix@@UEBA?AV?$Handle@VVariableObj@optix@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceQueryVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceRemoveVariable,该符号在函数 "public: virtual void cdecl optix::GeometryInstanceObj::removeVariable(class optix::Handle)" (?removeVariable@GeometryInstanceObj@optix@@UEAAXV?$Handle@VVariableObj@optix@@@2@@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceRemoveVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceGetVariableCount,该符号在函数 "public: virtual unsigned int cdecl optix::GeometryInstanceObj::getVariableCount(void)const " (?getVariableCount@GeometryInstanceObj@optix@@UEBAIXZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceGetVariableCount 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryInstanceGetVariable,该符号在函数 "public: virtual class optix::Handle cdecl optix::GeometryInstanceObj::getVariable(unsigned int)const " (?getVariable@GeometryInstanceObj@optix@@UEBA?AV?$Handle@VVariableObj@optix@@@2@I@Z) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryInstanceGetVariable 1>OptiXMesh.obj : error LNK2019: 无法解析的外部符号 imp_rtGeometryCreate,该符号在函数 "public: class optix::Handle cdecl optix::ContextObj::createGeometry(void)" (?createGeometry@ContextObj@optix@@QEAA?AV?$Handle@VGeometryObj@optix@@@2@XZ) 中被引用 1>sutil.obj : error LNK2001: 无法解析的外部符号 imp_rtGeometryCreate

lzqsd commented 3 years ago

Hi,

I recommend to use Optix version lower or equal to 6. Optix 7 is quite different and I haven't got time to move the renderer to Optix 7 yet.

Best, Zhengqin

bring728 commented 2 years ago

I used optix 6.0, but I also get the same link error. here is my cmake configuration : opencv 4.5.1 devil 1.8 cuda 11.2 VS2019 image

Even if I check the additional library link value in the project properties, it seems to be okay, but I keep getting an error in the sutil project.

image

When building, set optixrenderer as the startup project and set the configuration to Release. Is this correct?


It's easy to build on ubuntu. Maybe I should do it on ubuntu..!

maluonei commented 2 years ago

I got the same problem on windows10 when compiling. I used optix5.1.1 CUDA11.0 devil 1.8 vs2017. Is there anyone succeed on win10?

StringWeaver commented 2 years ago

I have the same link problem too. Has anybody successfully run it on windows? @lzqsd

lzqsd commented 2 years ago

I never tried to build on windows. Sorry about that. I only tried ubuntu.

StringWeaver commented 2 years ago

@lzqsd I switched to Ubuntu and it can be compiled successfully. But I got a segment fault mentioned in #6, could you let me know the OpenCV and CUDA version that you are using?

lzqsd commented 2 years ago

It works well for me with CUDA 10.2. I think OpenCV does not matter, as it is only used to read images.

bytedwang commented 2 years ago

I solved the problem by using a linux machine:

Debian GNU/Linux 8.10 (jessie)
nvcc: release 10.0, V10.0.130
Driver Version: 450.142.00
GPU: Tesla V100
optix 5.1.1
opencv 3.4.3
cmake version 3.24.0-rc2
GNU Make 4.0
gcc (Debian 4.9.2-10+deb8u1) 4.9.2

I think this can never be compiled on a Windows machine because I find that some linux functions are used, like realpath. And maybe it's better to mention this in readme @lzqsd. I found the realpath error after trying 2 cuda versions, 3 VC versions, and 4 optix versions lol.

xiao2021 commented 6 months ago

I just want to use the application on Windows. Could you please share a copy of the files you compiled on Linux? Thank you very much. My email: xmhmail2020@163.com