How do I #include plugin source files in my custom Unreal Engine module? - c++

I'm working with a C++ Unreal Engine project and made my own custom module called MyActor, Unreal Engine automatically created the .cpp and .h files for me. That much appears to be working.
So now I want to include classes or methods from the AppleARKit plugin then override and call them from my custom MyActor module.
First I tried using #include AppleARKitLiveLinkSourceFactory.h because it has theIARKitBlendShapePublisher::PublishBlendshapes method which I want to modify and use.
It didn't work at first with this error: E1696 Cannot open source file AppleARKitLiveLinkSourceFactory.h but I found out I could include them in Visual Studio using the "Include Directories" under Properties like this:
The AppleARKitLiveLinkSourceFactory.h lives in the Public folder but I included the Private folder as well, I don't know if I need to do that. This appeared to work at first but then I got the same error as before for every dependency inside the AppleARKitLiveLinkSourceFactory.h file.
Do I have to include the individual directories for every dependency down the entire chain? Is there an easier way?

When I ran into the issue of including files from a plugin, in my case LidarPointCloud, the following steps worked for me:
1) In my <project-name>.Build.cs file, I added the module name I wished to use (LidarPointCloudRuntime) to the public dependency list
PublicDependencyModuleNames.AddRange(new string[] { "LidarPointCloudRuntime", "Core", "CoreUObject", "Engine", "InputCore" });
I determined the module name by opening the .uplugin file in the plugin's folder, and looked at the Modules section. If multiple module names are listed, you should pick the one that contains the source for the classes you care about.
2) I then rebuilt the project, closed my editor, then right clicked my <project-name>.uproject file and regenerated project files.
After that, I was able to access the .h files in my code.
-Update-
It seems that AppleARKitFaceSupport has dependencies on other plugins that may need to be included. For example, ARSystems.h lives in AugmentedReality. When I add that to PublicDependencyModuleNames and perform the same steps, it can find ARSystem.h.

Related

Use OpenSSL in Unreal Engine 4.25

I’m trying to use the OpenSSL library included with the engine.
I am using 4.25
In my searches I see people saying to add OpenSSl as a dependency to my project’s build file.
I have seen couple different lines to add to the build file, every one of them causes errors - usually about the the function not being in the current context.
AddEngineThirdPartyPrivateStaticDependencies(Target, “OpenSSL”);
is one example - I believe I read some where to try
ExtraModuleNames.AddRange( new string[] { “OpenSSL”} ); - but that came back with OpenSSL not being a c++ module.
There is another function out there that I forget, but when I tried it, I got the error again about not being in context.
So far only by adding the folder “E:\UE_4.25\Engine\Source\ThirdParty\OpenSSL\1.1.1\Include\Win64\VS2015” to the visual studio c/c++ directory includes list can I just do a regular "#include “openssl/sha.h”. - but when I compiled it, it failed saying that the file didn't exist. Yet I can right click the include in code and view it, as well as intellisense recognizing the classes and functions.
In the solution explorer, I can see the openssl folder under UE4\Source\ThirdParty\openssl - but none of the different openssl version show up and none of the source code files.
In fact, all the ThirdParty libraries just contain one or more build files, or files with a .tps extension.
My ultimate goal is to get access to sha-256 to generate a hash for comparing local custom maps with a server copy - assumption is that if hash is different, server copy is a newer version and is then downloaded.
So my ultimate question is how do I use Unreal's included OpenSSL library.
My problem is that I kept trying to do things in the target file, not the build file - as mentioned in a comment above by Strom.
To enable OpenSSL in an unreal c++ project (I'm using Visual Studio):
Open up your project build file.
Add OpenSSL to the PublicDependencyModuleNames:
using UnrealBuildTool;
public class MyProject : ModuleRules
{
public MyProject(ReadOnlyTargetRules Target) : base(Target)
{
PublicDependencyModuleNames.AddRange(new string[] {
"PhysicsCore",
"OpenSSL"
});
}
}
Close your solution, right click your unreal project .uproject file and choose "Generate Project Files".
Where you want to use openSSL add at the top of your code file in the includes section or in your header file. (in my case I'm using evp as the docs say for sha256).
#define UI UI_ST
THIRD_PARTY_INCLUDES_START
#include "openssl/evp.h"
THIRD_PARTY_INCLUDES_END
#undef UI

Using multiple resource files in MFC project

I'm working in MFC (C++11)in VS2015 and I have a set of standalone GUIs that i'd like to use across multiple projects. I know this is possible by creating a .rc file that can be included in the main .rc file of each project based on this:
Using Multiple Resource Files
While conceptually I understand what it is describing, i can't find any example of creating the standalone .rc file and second resource file. I created a test resource header file that lives globally in my solution and tried to include it using Resource Includes, but it can't find it, even with the path. Can anyone point me to links or examples on how to set this up?
I have either .rci files, that are never used with the resource editor. They are used with #include freely.
Or I have special .rc files that contain standard symbols and messages, that are used over a larger set of projects.
I just simply add the second rc file to the project. This resource file is simply #include'ed into the main .rc file of the project.
To prevent errors in the project. This second .rc file is excluded from the build. In the solution explorer right click on the item. And set Exclude from Build to YES.
Take care about collisions of IDs.
Here is how I do it. If you drop the resource you would like to include on the resource folder in the solution explorer, it will show up as a separate and editable resource in your project
You will have to include the headers in your project that go along with them, of course. So watch out for collisions of your IDs. You may have to go to the new resource and use IDs that have been set aside by adjusting _APS_NEXT_XXX_VALUE. I've never used the 'Resources Includes..'. as described in TN035. I just checked and relative paths to bitmaps seems to work fine. Hope that helps.
I know two approaches of doing it. I will demonstrate it assuming you want it for the need of managing the fact your application supports several languages.
The first one is already described by user #xMRi, and depending on your configuration/platform you will include only the .rc in question. For example you have configurations:
en_GB
fr_FR
pt_PT
de_DE
and files
Project_en_GB.rc
Project_fr_FR.rc
Project_pt_PT.rc
Project_de_DE.rc
For getting this right, you will need to do Exclude from build on them all, except on the Configuration you have selected at the moment on the VS Toolbar combo. If you have fr_FR selected, do Exclude from build of all other .rc except Project_fr_FR.rc files and apply the same logic on every configuration.
The other is to have a VS project (vcproj) for each language, where each project contains the .rc file brlonging to it.
The projects
Project_en_GB
Project_fr_FR
Project_pt_PT
Project_de_DE
contain respectively
Project_en_GB.rc
Project_fr_FR.rc
Project_pt_PT.rc
Project_de_DE.rc
Here at work we use both (I never heard of .rci files before; we use the first with normal .rc files), depending on the project.

C++-Build: After editing a file in a project the build process takes a long time. How to find out which files/classes are responsible?

I have a very large VC++-Project which takes a long time to Rebuild after i edited a file. Maybe it's a central-class and so the following classes have to be rebuild, too. I'm using class-definitions and do include the header in the cpp-file, not .h-file in .h-file ;-)
Is there a way to find out which class/file is resposible? Are some useful tools to visualize the includes in a graph/dependencygraph? How do you get it?
Any file which directly or indirectly (through another include) #includes the file you changed will have to be rebuilt. Also if you have custom rules (say, the file you are editing is part of a custom rule that generates new source files), then any files changed by this rule and their dependencies will also have to be rebuilt.
MSDN Doc for visualizing the dependency graph:
http://msdn.microsoft.com/en-us/library/ff657798.aspx
ElectricAccelerator can help you answer this question by giving you an XML-annotated build log that includes information about which files are accessed during the compilation of each object, and the build time for each object. It has a Visual Studio plugin so it integrates right into your current environment.
Disclaimer: I'm the architect of ElectricAccelerator

Errors while porting cocos2d-x project to android

I have successfully run the "Step by Step Coos2dxSimpleGame Series" (http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Tutorials) in windows using visual c++. Now I want to port this project to an android device, Hence I copied the classes namely HelloWorld,AppDelegate and GameOverScene and their header files to Classes folder and the resources to /Resources folder. Then I have modified the android.mk file to include a new class called GameOverScene.cpp which is not present before .
Then I run ./build_native.sh . The error message is here (http://www.cocos2d-x.org/attachments/1152/native_error.PNG) .
Is the process I am following correct?
In HelloWorldScene.h, change:
HelloWorld::~HelloWorld();
HelloWorld::HelloWorld();
to:
~HelloWorld();
HelloWorld();`
You must not add the class name in your declarations in header files (but you have to do it in your cpp file).
One thing that I can suggest You is to follow step by step this tutorial
http://magicscrollsofcode.blogspot.com/2011/09/quick-and-dirty-guide-to-getting.html
and also don't forget about this:
http://www.cocos2d-x.org/boards/6/topics/8572?r=8577#message-8577 afterwards
these two things helped me a lot one time :)

How to include net_rim_api_wlan_hotspot in my BB project?

I have a project that is going to create hotspot client, so it imports net.rim.device.api.wlan.hotspot.*
When the code runs it complains that it cannot find net_rim_api_wlan_hotspot. If I display the table-of-contents for the jar file, *\BlackBerry JDE 5.0.0\lib\net_rim_api.jar, the file class files are listed.
What steps am I missing to build the project correctly?