Hi, I’m trying to make a runtime skp importer with [this SketchUp C API Document][1] and the SDK files.
I created a plugin using third-party library template and
1. Copied .dll and .lib into the directory where example .dll and .lib exists.
2. Copied headers into the corresponding directory too.
3. Added paths in the .build.cs file.
using System.IO;
using UnrealBuildTool;
public class SkpImporterLibrary : ModuleRules
{
public SkpImporterLibrary(ReadOnlyTargetRules Target) : base(Target)
{
Type = ModuleType.External;
if (Target.Platform == UnrealTargetPlatform.Win64)
{
PublicIncludePaths.Add("$(PluginDir)/Source/ThirdParty/SkpImporterLibrary");
// Add the import library
// List of additional libraries (names of the .lib files including extension) - typically used for External (third party) modules
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "x64", "Release", "ExampleLibrary.lib"));
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "x64", "Release", "sketchup.lib"));
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "x64", "Release", "SketchUpAPI.lib"));
// Delay-load the DLL, so we can load it from the right place first
PublicDelayLoadDLLs.Add("ExampleLibrary.dll");
PublicDelayLoadDLLs.Add("SketchUpAPI.dll");
PublicDelayLoadDLLs.Add("SketchUpCommonPreferences.dll");
// Ensure that the DLL is staged along with the executable
RuntimeDependencies.Add("$(PluginDir)/Binaries/ThirdParty/SkpImporterLibrary/Win64/ExampleLibrary.dll");
RuntimeDependencies.Add("$(PluginDir)/Binaries/ThirdParty/SkpImporterLibrary/Win64/SketchUpAPI.dll");
RuntimeDependencies.Add("$(PluginDir)/Binaries/ThirdParty/SkpImporterLibrary/Win64/SketchUpCommonPreferences.dll");
}
else if (Target.Platform == UnrealTargetPlatform.Mac)
{
PublicDelayLoadDLLs.Add(Path.Combine(ModuleDirectory, "Mac", "Release", "libExampleLibrary.dylib"));
RuntimeDependencies.Add("$(PluginDir)/Source/ThirdParty/SkpImporterLibrary/Mac/Release/libExampleLibrary.dylib");
}
}
}
4. Modified the module’s main .cpp file.
#include "SkpImporter.h"
#include "Core.h"
#include "Modules/ModuleManager.h"
#include "Interfaces/IPluginManager.h"
#include "SkpImporterLibrary/ExampleLibrary.h"
#include "SkpImporterLibrary/SketchUpAPI/initialize.h"
#define LOCTEXT_NAMESPACE "FSkpImporterModule"
void FSkpImporterModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
// Get the base directory of this plugin
FString BaseDir = IPluginManager::Get().FindPlugin("SkpImporter")->GetBaseDir();
// Add on the relative location of the third party dll and load it
FString LibraryPath;
#if PLATFORM_WINDOWS
LibraryPath = FPaths::Combine(*BaseDir, TEXT("Binaries/ThirdParty/SkpImporterLibrary/Win64/SketchUpAPI.dll"));
#elif PLATFORM_MAC
LibraryPath = FPaths::Combine(*BaseDir, TEXT("Source/ThirdParty/SkpImporterLibrary/Mac/Release/libExampleLibrary.dylib"));
#endif // PLATFORM_WINDOWS
ExampleLibraryHandle = !LibraryPath.IsEmpty() ? FPlatformProcess::GetDllHandle(*LibraryPath) : nullptr;
if (ExampleLibraryHandle)
{
// Call the test function in the third party library that opens a message box
SUInitialize();
}
else
{
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("ThirdPartyLibraryError", "Failed to load example third party library"));
}
}
void FSkpImporterModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
// Free the dll handle
FPlatformProcess::FreeDllHandle(ExampleLibraryHandle);
ExampleLibraryHandle = nullptr;
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FSkpImporterModule, SkpImporter)
Building solution is done. But when I execute the project, a message pops up:
Is there anything I am missing? Any help would be very appreciated. Thanks for reading…