understanding of dll lib c++ vs - c++

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 ?

Related

Unable to use Precompiled headers in visual studio

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.

Unreal Engine and Clion (can't resolve some sybmols)

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.

Xcode C++ Standard Libraries not found

I've created an Allegro 5 project in Xcode 4.6.3 as an empty project. I've added all the Allegro 5 libraries as described in the Allegro documentation. But now I need to use some C/C++ libraries and get the error, that Xcode doesn't find the libraries (e.g. 'fstream file not found').
#include <allegro5/allegro5.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_image.h>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
How can I add the standard libraries to Xcode projects so that it finds them? Unfortunatelly I can't find any solution. This is not an Objective-C Project. It's written in C++ and also works if I don't use any of these libraries.
Thanks!
Does the name of your source file end with an extension that indicates it's C++? If it ends in (for instance) .c or .m, the compiler will not consider it to be C++, therefore the C++ headers won't be found. Try changing the extension on the source file name to .cpp (or some other extension that implies C++, see C++ code file extension? .cc vs .cpp ) and see if the header is found.

How can i find out what DLL's my C++ program uses?

Even when I build an exe in release mode, when I try to execute the program on another PC, I get DLL not found errors. So I need to find out which dlls my program needs and copy them with the exe. But I can't seem to figure out how to find what dlls my program uses.
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "SDL_mixer.h"
#include <string>
#include "head.h"
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <windows.h>
I'm pretty sure what dll's it needs is based on the includes so here they are. I know which ones are used by the SDL libraries but I don't know the others.
Dependency Walker might help. Have a look at the application screen-shot below.
Use dumpbin to print all dynamic libraries required by your executable or DLL:
dumpbin /dependents myprog.exe
Typically you can find dumpbin.exe in directory "C:\Program Files (x86)\Microsoft Visual Studio XXX\VC\bin".
You can use a dependence walker to see whether all dependence are available before your run the exe:

fatal error: vector: No such file or directory

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