x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

"DLL linking" tutorial returns Null function pointer

I've also been following the Linking DLLs tutorial, creating the example DLL with "getCircleArea". After changing the solution platform to x64 it now gets the DLL handle, but

 DLLgetCircleArea = (_getCircleArea)FPlatformProcess::GetDllExport(DLLHandle, *procName);

just returns a null pointer. It seems widely accepted that my function name must have changed, and I should use "depends" to check this. I downloaded depends and can't really work out where my function might be if it is there. Anyone else solved the same problem?

Here is my code (which should be exactly whats in the tutorial)

 /// Declare the DLL function's type
 typedef float(*_getCircleArea)(float radius);
 
 ///Define the function using the DLL's function
 float ACircleActor::getCircleAreaDLL(float radius)
 {
     //FPaths::Combine(*FPaths::GamePluginsDir(), TEXT("CirclePlugin/"), TEXT("CirclesDLL.dll"));// Concatenate the plugins folder and the DLL file.
     FString filePath = FPaths::Combine(*FPaths::GameDir(), TEXT("Binaries/Win64/"), TEXT("CirclesDLL.dll"));
     if (FPaths::FileExists(filePath))
     {
         void *DLLHandle;
         DLLHandle = FPlatformProcess::GetDllHandle(*filePath); // Retrieve the DLL.
         if (DLLHandle != NULL)
         {
             _getCircleArea DLLgetCircleArea = NULL; // Local DLL function pointer.
             FString procName = "getCircleArea"; // The exact name of the DLL function.
             DLLgetCircleArea = (_getCircleArea)FPlatformProcess::GetDllExport(DLLHandle, *procName); // Export the DLL function.
             if (DLLgetCircleArea != NULL)
             {
                 float out = DLLgetCircleArea(radius); // Call the DLL function, with arguments corresponding to the signature and return type of the function.
                 return out; // return to UE
             }
         }
     }
     return -1.00f;
 }

And the dll code:

 // CirclesDLL.cpp : Defines the exported functions for the DLL application.
 //
 
 #include "stdafx.h"
 float getCircleArea(float radius)
 {
     return 3.1416 * (radius*radius);
 }
 

My dll is attached, as a .txt since this won't allow .dll.link text

Product Version: UE 4.11
Tags:
circlesdll.txt (10.8 kB)
more ▼

asked Apr 14 '16 at 04:27 PM in C++ Programming

avatar image

unrealWhiteted
1 1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I've solved my own question with this:

 #define MY_DLL_API __declspec(dllexport)
 
 // Undecorated function export : myCFunction
 extern "C"
 {
     MY_DLL_API float getCircleArea(float radius);
 };
 
 
 extern "C"
 {
     // Undecorated function code
     MY_DLL_API float getCircleArea(float radius){
         return 3.14159265 * radius * radius;
     }
 
 };

more ▼

answered Apr 14 '16 at 06:52 PM

avatar image

unrealWhiteted
1 1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question