Unresolved external symbol when linking to third party library

I’m trying to use AngelScript library with Unreal Engine. After following the tutorial here I’m stuck at linker error.

scriptTestCharacter.cpp.obj : error LNK2001: unresolved external symbol "private: static class asIScriptEngine * AscriptTestCharacter::engine" (?engine@AscriptTestCharacter@@0PEAVasIScriptEngine@@EA)

The static library I’m using was built in the same compiler, with 64 bit platform selected, using the Multi-threaded DLL runtime.
I have tested the library in a separate project outside of UE and it compiles and works just fine.

Are there any other steps I might have missed? So far i’ve done the following:

  1. Compiled the library using the provided settings (64 bit, static, with multi threaded DLL runtimes)
  2. Copied the library and includes to a folder in project directory
  3. Edited the scriptTest.Build.cs to link the library using UE4 build system
  4. Added include and library folders to MSVC project directories.

scriptTest.Build.cs file: link

MSVC build log: link

I am sure the build system can find the library file. After making a typo in the library file name, the error changed accordingly.

Solved. Problem was that I compiled the library along with included add-ons. Now I’m linking with clean library and adding addon as source file into the project.

Hmmm. I know this is a very old posting, but I’m responding to the title, exactly as written. I’ve been struggling to add a third party library to a plugin with a whole lot of troubles.

I created a static .lib library of the product I was interested in. Built mylibrary.build.cs file exactly right, but total fail with error above. It was like the system was just not finding my .lib content.

I notice that on a simple demo for my library (non-UE4) someone added an environment variable “ZMQ_STATIC”

Oops. I never added that. And deep within the library header files there were a bunch of

#if defined ZMQ_STATIC....

routines. No wonder stuff was missing. duh. The simple fix was to add the following to mylibrary.build.cs file:

PublicDefinitions.Add("ZMQ_STATIC=1");

All fixed.

1 Like