UE 4.23
CLion 2019.2.1 (clangd server off)
After testing this newbie tutorial i have many unresolved symbols in clion like on picture:
Only when I add this-> to variable or method - the red letters are disappear.
How avoid this?
In your FloatingActor.cpp file, add the following includes after #include "FloatingActor.h":
#include "Components/StaticMeshComponent.h"
#include "ConstructorHelpers.h"
will solve the problem.
Please note that you should only put these includes inside the .cpp file, not the .h file.
Here are my includes in .cpp file and .h file.
FloatingActor.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FloatingActor.generated.h"
FloatingActor.cpp
#include "FloatingActor.h"
#include "Components/StaticMeshComponent.h"
#include "ConstructorHelpers.h"
More discussions here.
Related
I am trying to understand dlls. But it is still a bit vague. So please forgive if this is a very stupid question.
Lets say I have a project with lots of files and a mainfile that #includes those files.
mainfile.cpp:
#include "fileA.h"
#include "fileB.h"
#include "fileC.h"
I can create a mydll.dll from this project. A lib is created along with that. (I used C++, VS)
Then I have a project UseMydll that uses this dll. There I include
#include "pch.h"
#include "fileA.h"
#include "fileB.h"
#include "fileC.h"
So whats the point then in creating the dll if I still need to include and provide my fileA,fileB,fileC ?
I've seen several questions discussing this topic but none of their solutions seems to apply here. I have several libraries that I don't wont to be compiled every time I build the project so I've created "b5pch.h" and b5pch.cpp" files.
//b5pch.h
#pragma once
#include <iostream>
#include <memory>
#include <utility>
#include <algorithm>
#include <functional>
#include <sstream>
#include <string>
#include <vector>
#ifdef B5_PLATFORM_WINDOWS
#include <Windows.h>
#endif
//b5pch.cpp
#include "b5pch.h"
In properties I've set precompiled header for every cpp file to be Use(/Yu) like so:
And for b5pch.cpp it's set to Create(/Yc)
after that I've added #include "b5pch.h at the start of each cpp file(I only have two not including b5pch.cpp) but when I try to build the project I get two errors saying exactly the same thing
Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "b5pch.h"' to your source?
Okay I've fixed the problem. when I was including b5pch.h in my cpp files I was doing it like this:
#include ../b5pch.h since they were in different directories.
When I moved pch files in same directory and I just wrote #include b5pch.h there were no more errors. I didn't wanted them to be in same folder so I've moved them back out but in Project Properties->Additional Include Directories I've added "src" so I could just use #include b5pch.h in my cpp files even tho they were not in the same folder.
I have simple project where I use tiny ttmath library for C++ (big nums).
This library consists of 13 *.h files.
I have included all these files in a stupid way:
#include "ttmath\ttmath.h"
#include "ttmath\ttmathbig.h"
#include "ttmath\ttmathdec.h"
#include "ttmath\ttmathint.h"
#include "ttmath\ttmathmisc.h"
#include "ttmath\ttmathobjects.h"
#include "ttmath\ttmathparser.h"
#include "ttmath\ttmaththreads.h"
#include "ttmath\ttmathtypes.h"
#include "ttmath\ttmathuint.h"
#include "ttmath\ttmathuint_noasm.h"
#include "ttmath\ttmathuint_x86.h"
#include "ttmath\ttmathuint_x86_64.h"
What is the right way? I expect smth like this:
#include "ttmath\*.h"
but can not find...
What is the right way? I expect smth like this:
#include "ttmath\*.h"
but can not find...
That won't work because the preprocessor is not going to expand characters to match things in the way you expect wildcards to work.
My recommendation would be to create a single custom header file of your own, and place all the #include entries in there. For example, in your .c file, you can add your own header:
#include "my_header.h"
And the contents of my_header.h would be:
#include "ttmath\ttmath.h"
#include "ttmath\ttmathbig.h"
#include "ttmath\ttmathdec.h"
#include "ttmath\ttmathint.h"
#include "ttmath\ttmathmisc.h"
#include "ttmath\ttmathobjects.h"
#include "ttmath\ttmathparser.h"
#include "ttmath\ttmaththreads.h"
#include "ttmath\ttmathtypes.h"
#include "ttmath\ttmathuint.h"
#include "ttmath\ttmathuint_noasm.h"
#include "ttmath\ttmathuint_x86.h"
#include "ttmath\ttmathuint_x86_64.h"
Basically, you put everything in a single header, and include that one instead.
The preprocessor doesn't have an "include all" built into it. Neither does it accept wildcards in filenames. You'll have to manually include all of them.
A common solution is to place all the includes in a new .h file and include that one every time you need all of them.
I'm trying to compile some code to render stuff on windows that don't belong to my application. I want to use DirectX 9 to achieve this, but for some reason linker errors are killing me right now.
Im including all my libs in a .h file (see main.h below).
Now i include this .h file in every other .h file i have, to make use of it everywhere. Sometimes i only include a .h file that includes my main file.
The problem is now, that when i go to any class I want to use DirectX in (with included .h file), i get the LNK2019 error.
auto hResult = Direct3DCreate9Ex( D3D_SDK_VERSION, &this->m_pDirect3D9Ex );
Error at Direct3DCreate9Ex
The corresponding .h file includes the main .h file in the following way:
#ifdef _MSC_VER
#pragma once
#endif
#include "main.h"
main.h (complete):
#pragma once
#endif
#include <Windows.h>
#include <iostream>
#include <vector>
#include <memory>
#include <chrono>
#include <thread>
#include <d3d9.h>
#include <d3dx9.h>
#include <dwmapi.h>
#pragma comment( lib, "d3d9.lib" )
#pragma comment( lib, "d3dx9.lib" )
#pragma comment( lib, "dwmapi.lib" )
#endif
This even works when compiling with VisualStudio, but I need to achieve this using the cl.exe. When i try to build it after i moved everything out of VisualStudio, the unresolved symbol errors occur.
I would greatly appreciate any help i could get, already wasted hours on this.
Edit: Error
You are pointing to the 64 bit DirectX libraries on your command line. You need to use the 32 bit libs.
I have an Android project comprising of lots of native code in C++. However, I am unable to build my library as it is not able to find out vector.h header file. What could be the issue ?
A sample of my inclusions in almost all the pages.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <vector>
The compiler is able to find out all other header files except vector.h in every file. Any suggestions about where am I going wrong ?
NOTE : Filenames end with .cpp and I have already tried #include <vector.h> , #include "vector.h"
Thanks !
The issue was finally resolved by creating Application.mk in JNI folder of project and adding the following to it :-
APP_STL := stlport_static
For more details, refer to this question on SO