CodeBlocks header common folder - c

I have multiple projects which have the same header files over and over again, is it possible to create a common utils folder with all the headers and their source files?
Project files with header files

Yes, you can. First make a folder and insert all of your header file in that folder. then create a makefile and you can add that folder for the headers in a Makefile. See here
Other option can be to give path in include like
#include "../Headers/check.h"
#include "../Headers/stackstring.h"

Related

VS Code cannot open source "graphics.h", although "C:/MinGW/libs/**" is added to includePath

So I'm trying to import this library to my code, so I copied the header files to my MinGW/include folder, then copied the library files to MinGW/lib, and finally added "C:/MinGW/include/**" to my includePaths in the C/C++ config file. Still thou, I'm getting the error that this header doesn't exist

vim include .h files from projects include directory

EDITED.
Is there a way so that vim detects the path of the header files without using relative paths in the source files like #include "../foo.h"
How to set the path option correctly for the current project folder and how to make a rule for it so that every project with that folder structure can profit?
Are there plugins for it?
I have a multifile c project. int the project folder is one src and one include folder. the src directory contains all .c files, the include folder inhabits all .h files.
project
|_ src
|_ include
example: main.c
#include "..\foo.h"
..
Vim knows about foo.h if the file is within the src folder, but not if it is in the include folder
I have tried setting the path variable in the .vimrc file with no luck.
All other includes from usr/include are working fine.
You must declare either a relative or Absolute path. So there is no "auto detection" just from a file name.
Side note: Vim doesn't care about your paths, the C Preprocessor Include cares about your paths

C #include pbl.h path

I'm working on a project on my local machine using C.
I wanted to borrow data structure implementations from PBL
(http://www.mission-base.com/peter/source/)
When I download the zip file from PBL's github repo, there are hundreds of files inside it.
To freely use things from the PBL library, which file should I #include in my project file using #include "/path/to/pbl.h"?
There are many files in the PBL src folder but I'm suspecting I will have to point to one main header file (enlighten me if I"m wrong)
Second part is where I should place the PBL source files so that
1) since the whole PBL file structure is huge, I don't think I should put it in my project folder... then where should I put it (and call it from)?
2) I also plan to push my project to GitHub, then how can I maintain the file structure dependencies in the remote repo without having to push the whole PBL library up to my repo along with my project files? (correct me if the right thing to do is to push both project files and the PBL library)
Thanks in advance!
No, you should avoid using anything with an absolute path name such as:
#include "/path/to/pbl/pbl.h"
You should probably use:
#include "pbl.h"
and specify a compiler option like:
gcc -I/path/to/pbl …
to specify where the header is actually found (or headers are found).
You could also look at the documentation for the library. If it says use a different notation, follow what it says.

How to link static library with xcode?

I have built ffmpeg and link it to my project:
But when I include libavformat.h , it game me error:
I want to know what's the settings I am missing ?
You should add the header files to your header search path in the Build settings and just use #import "avformat.h".

Preserving Header Directory Structure in Xcode for Static Library

I'm developing a static library in C++ using Xcode. I have an Installation Directory set where it copies all of my public header files, but when I compile it just copies all the headers into one directory. Is there a way to tell Xcode to preserve the directory structure of my header files? Thanks in advance!
I also needed to preserve the header file directory structure for a C++ library project and I finally managed to do it. It is ridiculously complicated with XCode, compared to the simple nature of the task. The key is to create "folder references" at first, then to copy the header folders in an extra build phase and afterwards to delete .c/.cpp-files from these exported header folders with a script, because XCode will not only copy the .h-files.
I've written a blog post here on how to all achieve that, because it's more tricky in detail. You might also want to check out an example XCode project that I've pot on github.
When you add files to your project, you have to choose next parameter on an additional window "Create folder references for any added folders". And then all your files will have fixed path for your files and will save structure after compilation.

Resources