Use c++ classes from Unreal project in another c++ project?
Specifically, I would like to reference game project classes in a separate unit testing project. I am using the CATCH unit testing framework rather than the Unreal automation, and I am hoping to keep the game and tests as separate projects for separation of interests. However, I cannot successfully link the game project to the unit testing one.
I can set the include directories to include the headers from the game in the unit testing project. But I cannot get the latter project to find implementation files. I have tried linking the libraries I could find, but I always get the LNK2001 unresolved external symbol error. So I am stuck with undefined methods.
I am new to linking between projects altogether, so likely I am missing something simple. I am using Visual Studio Community 2013. The most likely looking libraries I found are in Intermediate\Build\Win64\Editor**.lib. I included these library directories in (unit testing) Project Properties -> Linker -> General -> Additional Library Directories, and I included the library filenames in Project Properties -> LInker -> Input -> Additional Dependencies.
Are these the right libraries?
Does Unreal output libraries that can be used by other projects?
Is there any way to reference classes in my game project in another project?
Should I make three projects: one for linking with Unreal, one (which outputs a library rather than executable) with the source code, and one with the test code?
I not fully understand what are you trying to do with that speration, but basing from fact you trying to wiggle around VS configs, you seem to lack knowlage how UE4 build system works. UE4 has it's own build system called Unreal Build Tool (UBT), it does not require VS IDE to function, it just need VS compiler to compile the code. It operates based on C# build scripts which you can find in Source directory and all configuration is done here. Because of that VS project files has 0 impotence for UBT, it can build without them, they exist just for VS IDE convenience.
Also UE4 code structure is kind of similar to Linux Kernel, it's divided in to modules which can be un/loaded dynamically, when you make C++ project you create new engine module which will contain game code, so your game code is technically extension of engine. Keeping this in mind it might be hard to link it to something other then UE4, besides in order to properly run it and test it you need the whole UE4 running either way due to it's object management system.
Now i'm not sure how you seperate projects, because i'm not sure if you mean UE4 project (uproject) or VS project, but best way to divide "interest" in UE4 is to create separate UE4 module which builds only when you do "Development" or "Debug" or even "Testing" builds (you can set it up that way in build scripts). So i think incorporating CATCH as a sperete UE4 module will be the best approach.
Here docs about UBT:
And here tutorial how to link external library with build scripts which might be useful for you:
Follow this question
Once you sign in you will be able to subscribe for any updates here