Building CUDA (nvcc) code in UE4 Build System
Hi, so I have had no trouble building cuda static libraries in separate projects and then copying over the static library and headers into UE4 project and then linking it up. The directions in this link worked no problem: http://www.sciement.com/tech-blog/c/cuda_in_ue4/ (google translate)
Now I would like to instead include my cuda code directly into my plugin and build it with the rest of the system. I tried naively adding my code and adding the cuda build customizations to my project and flagging the CU kernel file as using cuda.
This results in several errors. Typical linking errors to unresolved symbols in the cuda object. Trying to clean results in new errors as well related to cuda.
I am sure my naive approach is missing much considering ue's build ecosystem. I am still learning the UE4 build system and any guidance would be appreciated. If I was in linux I could just script around this having decades of experience there but for Windows I feel woefully inadequate.
Ultimately, I am trying to avoid needing to open two separate .sln files and have two separate VS instances running when working, then having to build and copy the separate cuda static lib and headers. Instead I want to have one VS instance, click one build button and not manually copy things. Any guidance would be much appreciated.
I am guessing this is going to have to do with Build.cs, anyway to use the nvcc compiler for the cu file or something?
I looked at: https://answers.unrealengine.com/questions/411431/prepost-build-step-in-ubt.html https://answers.unrealengine.com/questions/844018/view.html but don't completely understand all this yet. Also, the whole can't add nvcc or cuda tags due to reputation is annoying.
Edit: Adding another thought here. Could I take my standalone vs project that is creating the static libraries currently and somehow import this into my UE4 project, then add like some pre-build instructions to compile and use this project?
I solved this ages ago for myself so I might as well post the answer. What I did in the end which worked a treat was create a project for my cuda code inside of the main UE4 solution I was working in. This project used the cuda compiler etc and compiled the libraries to some place relevant in my greater UE4 solution. I compiled the libraries and added them to my version control for convenience.
Then if someone else cloned my code, IF, they wanted to edit the cuda code all they needed to do was add the project.
answered Feb 23 '19 at 05:33 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here