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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Why can't I open include files?

Hello,

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

 #include "ThirdParty/AWThirdParty/AWFramework/libAWFramework/Include/AWFrameworkAll.h"

but the inside the library code itself it complains that it can't find the header i.e.

 #include "Networking/Sockets/ZMQ/AWZMQSocketBase.h"

but I can guarantee that as specified in the cs build file public path that I added , the file should be there

i.e.

UEBuildConfiguration.UEThirdPartyDirectory + "AWThirdParty/AWFramework/libAWFramework/Include" + "Networking/Sockets/ZMQ/AWZMQSocketBase.h"

should exists.

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

 PublicIncludePaths.Add

is supposed to do.

Any idea ?

Product Version: Not Selected
Tags:
more ▼

asked May 03 '14 at 07:47 PM in C++ Programming

avatar image

Chrys
301 21 27 44

avatar image Chrys May 03 '14 at 07:52 PM

In fact if I add

 #include "ThirdParty/AWThirdParty/AWFramework/libAWFramework/Include/Networking/Sockets/ZMQ/AWZMQSocketBase.h"

instead of just

 #include "Networking/Sockets/ZMQ/AWZMQSocketBase.h"

then it compiles but that is obviously wrong, the library needs to be agnostic of where it is being used.

any suggestion would be appreciated :)

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

2 answers: sort voted first

Wiki Tutorial

Have you read this tutorial?

https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System

Is this what you need?

Build.cs

 public class UE4Magic : ModuleRules
 {
     [Convenience Properties]
  
     [Constructor]
  
     public bool LoadBobsMagic(TargetInfo Target)
     {
         bool isLibrarySupported = false;
  
         if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
         {
             isLibrarySupported = true;
  
             string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86";
             string LibrariesPath = Path.Combine(ThirdPartyPath, "BobsMagic", "Libraries");
  
             PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "BobsMagic." + PlatformString + ".lib")); 
         }
  
         if (isLibrarySupported)
         {
             // Include path
             PublicIncludePaths.Add( Path.Combine( ThirdPartyPath, "BobsMagic", "Includes" ) );
         }
  
         Definitions.Add(string.Format( "WITH_BOBS_MAGIC_BINDING={0}", isLibrarySupported ? 1 : 0 ) );
  
         return isLibrarySupported;
     }
  
more ▼

answered May 03 '14 at 10:12 PM

avatar image

Rama
10.6k 446 345 1088

avatar image Chrys May 03 '14 at 10:22 PM

I think if I compare the code you wrote with the cs file I posted above there isn't much difference. Or can you see something missing ?

avatar image Rama May 03 '14 at 10:45 PM

well I didnt write the code, but if you and Bob Gneu matched up that well, the rest of his tutorial should be helpful!

https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System

avatar image Chrys May 04 '14 at 11:05 PM

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.

avatar image LennardF1989 May 18 '14 at 12:05 AM

Where did you move it too to get this far? I have the same problem.

avatar image Chrys May 18 '14 at 12:35 AM

my project folders look like this
MyGame
- Binaries
- Build
- Config
- Content
- DerivedDataCache
- Intermediate
- Plugins
- Saved
- Source
- ThirdParty

hope that helps

avatar image Chrys May 04 '14 at 11:42 PM

from the Core.h in unreal

 /// 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"

looks like Epic indeed does some trickery here.

avatar image Chrys May 05 '14 at 12:09 AM

okay so here is the solution, anywhere you include a library header you can simply put the above mentioned wrappers around ... i.e.

 #include "AllowWindowsPlatformTypes.h"
 #include "MyLibraryHeader.h" 
 #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.

avatar image Odiriuss Jun 03 '14 at 08:39 PM

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@@V?$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!

avatar image Chrys Jun 03 '14 at 10:36 PM

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.

avatar image Odiriuss Jun 04 '14 at 10:13 AM

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...

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

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 ?

more ▼

answered Mar 13 '15 at 09:30 AM

avatar image

Institut Image
1 3 5

(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