I have written a library that I want to use in my new UE4 project.
So I have added a include and lib folder to the /Engine/Source/ThirdParty/ folder (as described in this forum post UE4 AnswerHub
It all works fine when I generate the solution files there is effectively now a folder called “AWFramework” and it contains the cs build file.
Unfortunately when I try and include any header from my library then I get a compiler error saying that the header cannot be opened.
Now I am usually quite familiar with as to why the header cannot be found but with this unreal build system I am a bit confused.
here my CS build file
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class AWFramework : ModuleRules
{
public AWFramework(TargetInfo Target)
{
Type = ModuleType.External;
if ((Target.Platform == UnrealTargetPlatform.Win64) ||
(Target.Platform == UnrealTargetPlatform.Win32))
{
PublicIncludePaths.Add(UEBuildConfiguration.UEThirdPartyDirectory + "AWThirdParty/AWFramework/libAWFramework/Include");
string LibraryPath = UEBuildConfiguration.UEThirdPartyDirectory + "AWThirdParty/AWFramework/libAWFramework/Lib/";
string LibraryName = "libAWFramework";
if (Target.Platform == UnrealTargetPlatform.Win64)
{
LibraryPath += "x64/";
}
else if (Target.Platform == UnrealTargetPlatform.Win32)
{
LibraryPath += "Win32/";
}
PublicLibraryPaths.Add(LibraryPath);
PublicAdditionalLibraries.Add(LibraryName + ".lib");
}
}
}
I have triple checked that the header files are effectively at the right location and that my paths are correct, but the problem seems to be that if I reference my library header from within my game code, I need to specify something like this
so how do I make sure that the paths for files referenced from my unreal game are compatible with paths referenced by my library. As far as I know usually the paths are looked up depending on what additional path directories are being added to a project but I can’t seem to find any such thing in the UE4 project(in fact I believe that is what
okay so I got finally my includes working. I had some issues with where I placed my third party code, I moved it and now at least it seems to get one step further.
I receive now a ton of errors where Unreal seems to dislike some data types that the library uses. I know the wiki page mentions that but it doesn’t mention how to fix it so here is the problem
19>C:\Program Files (x86)\Windows Kits\8.1\include\shared\ws2def.h(245): error C2872: 'INT' : ambiguous symbolC:\Program Files (x86)\Windows Kits\8.1\include\shared\ws2def.h(245) : error C2872: 'INT' : ambiguous symbol
19>
19> could be 'C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h(176) : int INT'
19> or 'I:\Projects\AWOnline\UnrealEngine\Engine\Source\Runtime\Core\Public\Core.h(509) : DoNotUseOldUE4Type::INT'
There is a very similar error about DWORD which unreal also doesn’t seem to like.
/// Trick to prevent people from using old UE4 types (which are still defined in Windef.h on PC).
namespace DoNotUseOldUE4Type
{
/// Used to cause compile errors through typedefs of unportable types. If unportable types
/// are really necessary please use the global scope operator to access it (i.e. :: INT).
/// Windows header file includes can be wrapped in #include "AllowWindowsPlatformTypes.h"
/// and #include "HideWindowsPlatformTypes.h"
I would strongly suggest to create a header file that includes all relevant header files from any external library and just wrap the entire block and then just include that header file where you need have access to your library.
Hey man, thx for all the help so far! I managed to get rid of the errors you mentioned here, but now i have problems using functions from the library. For example i have function that returns a string but i get link errors like this one:
error LNK2019: unresolved external symbol “public: static class std::basic_string,class std::allocator > __cdecl myTester::islibAlive(void)” (?islibAlive@myTester@@SA?AV?$basic_string@DU?$char_traits@D@std@@anonymous_user_e71e0d8a?$allocator@D@2@@std@@XZ) referenced in function “public: __cdecl AUtester::AUtester(class FPostConstructInitializeProperties const &)” (??0AUtester@@QEAA@AEBVFPostConstructInitializeProperties@@@Z)
Same thing with a function that returns a float value. If you could help in any way i would greatly appreciate it!
this usually means the library isn’t correctly references In the project or the library isn’t exporting the function (in case its a dll). Its not an unreal specific error.
I really don’t get what the problem is, if i change for example the path to the lib in the build file it gives me errors, even when i use the a function from the lib in code it gives me no intellisense errors, the only error that it does give is the one i gave above. I really don’t get what am i doing wrong…
Hi
This topic is a bit old but I had the unresolved link problem and I solve it by compiling the dependancies in 64bits. Maybe your dependancies are 32bitss ??
btw, I am now trying to run my UE4 VC2013 project with a win32 settings (all my dependancies are not 64bits) but I have got a “fatal error C1083: Cannot open include file: ‘MyProject21.h’: No such file or directory”
Does anyone has any new thoughts about that ?