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"

"No such file or directory exists" How to include header files?

Using Unreal engine 4.10.2 and visual studio community 2015 I can't figure out how to include a header file into my project so that I can create a static mesh component in my class. If I try and just include "StaticMesh.h", even though it shows up on the intellisense list, visual studio, when I compile, tells me "No such file or directory exists". I looked this up and some have suggested to instead include "Engine/StaticMesh.h" instead which I did. However, when I do this my editor crashes and I cannot reopen my project. How is it you are suppose to include files within your C++ classes in UE4? Thanks for any help

Product Version: UE 4.10
Tags:
more ▼

asked Jan 14 '16 at 08:08 PM in C++ Programming

avatar image

Boagz
50 14 21 28

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

The correct way is:

 #include "Engine/StaticMesh.h"

But I warn you, you must include anything before the generated line like below

  #include "GameFramework/Pawn.h"
  #include "Engine/StaticMesh.h"
  #include "HandballPawn.generated.h"


It will crash if you do

  #include "GameFramework/Pawn.h"
  #include "HandballPawn.generated.h"
  #include "Engine/StaticMesh.h"
more ▼

answered Jan 14 '16 at 08:23 PM

avatar image

knightster
6 1 1

avatar image Boagz Jan 14 '16 at 08:31 PM

This is the way I was doing it with:

  1. include "GameFramework/Actor.h"

  2. include "Engine/StaticMesh.h"

  3. include "MyClass.generated.h"

However this is crashing my project when I try and add UStaticMeshComponent variable to my code

avatar image TTaM Jan 14 '16 at 08:36 PM

Just to point out there, you don't need to include basic engine types like that.

avatar image darkgaze Jan 16 '18 at 10:48 AM

Then how do you do it?

avatar image knightster Jan 14 '16 at 08:46 PM

I added a UStaticMeshComponent to my code and it did not crash my editor. Can you share the way you write your cpp/h files?

avatar image Boagz Jan 14 '16 at 08:54 PM

Okay, so I'm finding that even if I don't include a header I can still create a UStaticMeshComponent. I'm guessing it's within "GameFramework/Actor.h"? However, I noticed that I wasn't creating a pointer I was just writing:

UStaticMeshComponent PickUpMesh;

and this was crashing my program. Does it make sense that not creating UStaticMeshComponent as a pointer would crash the program?

avatar image knightster Jan 14 '16 at 08:57 PM

Does it make sense that not creating UStaticMeshComponent as a pointer would crash the program?

Yes it make sense. Object cannot be shared with the editor, only instance of.

avatar image Boagz Jan 14 '16 at 08:59 PM

Okay thanks a bunch.

(comments are locked)
10|2000 characters needed characters left

It's good practice to use the full file path. So something like "Runtime/Engine/GameFramework/StaticMesh.h" (that's just an example path and is probably incorrect.)

more ▼

answered Jan 14 '16 at 08:15 PM

avatar image

TTaM
1.7k 79 28 81

avatar image Boagz Jan 14 '16 at 08:33 PM

Okay, I'll try that once I can figure out what exactly the full path is

avatar image knightster Jan 14 '16 at 08:45 PM

The path to the source is on my box:

\Epic Games\4.10\Engine\Source\Runtime\Engine\Classes

You can add anything after like

  Runtime/Engine/Classes/Engine/StaticMesh.h
avatar image Boagz Jan 14 '16 at 08:55 PM

Okay thank you

avatar image idbrii Mar 09 '17 at 09:47 PM

It's good practice to use the full file path

It's bad practice to use the full file path. It's good practice to use the full path from the root of the Include Path. In Unreal, that's everything after "Public", "Private", or "Classes".

Static Mesh is here:

Engine/Source/Runtime/Engine/Classes/Engine/StaticMesh.h

So you should do:

 #include "Engine/StaticMesh.h"

The reason you want to use this path is so your code doesn't break if Epic moves the Engine module to make StaticMesh's new path:

Engine/Source/Runtime*Core/Engine/Classes/Engine/StaticMesh.h or Engine/Source/Runtime/Engine/Public*/Engine/StaticMesh.h or Engine/CPlusPlus/EngineModule/Public/Engine/StaticMesh.h

Since Unreal's compilation system sets the include path root to PublicIncludePaths defined in a Build.cs, you should make your includes relative to that.

(comments are locked)
10|2000 characters needed characters left
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