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
Related
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.
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.
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 am finding some issue in the order the include headers are defined in the c / c++ files when i execute pclint.
Say the include order is ,
#include <sys/timerfd.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <stdarg.h>
#include <string.h>
and when i execute the pclint it gives error in say , FILE is un declared etc.
Later i changed the order of include to
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <stdarg.h>
#include <string.h>
#include <sys/timerfd.h>
i could see that many errors were gone . I am not able to figure out why is this behavior. I am using PC-lint for C/C++ (NT) Vers. 8.00w.
i have marked the include path as say, +libdir(D:\timesys\nitrogen6x\toolchain\include)
Thank You
Brijesh
Supposedly, the inclusion of header files does slightly matter, although it's rare to find such an occasion. Some include files use types, enums or something else that is only defined in another include file.
On Linux, for example, some functions require the inclusion of multiple headers. Some of the programs using those, fail if you include those headers in the wrong order.
Kinda like the final linking stage. You have to set the libs in the correct order, otherwise you may get unresolved dependencies.
If I find an example, i will post it here.
EDIT:
Found an example. Qt. Qt has the most absurdly complicated set of headers. If you include, for example, opengl.h before QtOpenGL.h, it gives you a compilation error, because inside the Qt headers it checks for the inclusion of opengl. For some reason, QtOpenGL.h must come first.
i used a c++ programm for image processing using opencv 2.1. and that program has below include files:
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <math.h>
#include <string.h>
but after debuging the program i get error message as:
fatal error C1083: Cannot open include file: 'opencv2/core/core.hpp': No such file or directory.
that is same as for imgproc.hpp and highgui.hpp after that i changed #include "opencv2/highgui/highgui.hpp" to #include <highgui.h> and that error solved.
But i could not find a solution for imgproc.hpp and highgui.hpp and there are no files named imgproc.hpp and highgui.hpp inside the opencv folder.
How can i solve this error?
From the path separator, I assume you are using *nix OS. So the following shell commands should help you to find the correct location of the header files:
locate highgui.h
locate highgui.hpp
As previously stated, your libraries aren't in an included area. Most people have tailored their responses to a Linux-based system, but if you're on Windows (i.e. Using Visual Studio), you can usually just include the entire path of your library folder in the include statement.
For example:
#include "C:\OpenCV\bin\install\opencv2\highgui\highgui.hpp"
#include "C:\OpenCV\bin\install\opencv2\imgproc\imgproc.hpp"
I recently had my fair share of errors after trying to install OpenCV 2.4.1 and finding the correct directories to include (both for 'include' and 'lib') was difficult at first. I recommend re-installing your OpenCV and going from there.
http://opencv.willowgarage.com/wiki/InstallGuide