Noobs DeSroobs
Noobs DeSroobs

Reputation: 283

Unresolved external symbol when linking to third party libraries from UE4

EDIT: Updated post to avoid linking to third party sites and to collect all required information here.

Any information is appreciated. If you need more info, please inform me and I will edit the post with the new details. Here is some useful information to start with.

Errors.

Source code.

I am trying to use a third party SDK consisting of one lib file and essentially one header file. I manage to get the intellisense to work, but I get linker errors even though I have modified my project's build.cs file to add the library path.

public OculusTest(TargetInfo Target)
    {
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
        // Add static libs
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "RPLidar/Libraries", "rplidar_driver.lib"));
        // Add a path with the .h that has the function definitions
        PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "RPLidar", "Includes"));
    }

I also checked if I was missing something, but in a standalone C++ project I use the same files and only the same files and it does work. The files in question are

RPLidar.h and rplidar_driver.lib

As such I assume the error is in me failing to tell the Unreal compiler where to find the lib file.

Thank you in advance for all information regarding this way too stubborn error.

Upvotes: 0

Views: 5824

Answers (1)

Noobs DeSroobs
Noobs DeSroobs

Reputation: 283

I finally found my error.

After checking that the same version of VSC++ was used to compile both programs and that I checked that it was in the correct configuration I changed one extra thing that made it all work out.

Instead of compiling to a multi threaded LIB file, I compiled the code as a DLL file. I did it by opening the LIB project properties and going to C/C++ -> Code Generation -> Runtime Library and setting it to Multithreaded DLL (/MD). Under General I set the configuration type to be a static library (.lib).

Upvotes: 1

Related Questions