Android Studio : include an other path in a c file - c

I develop an application on Android Studio, and I use the code of a C project. The 2 codes needs to be the same.
I have a C file myfile.c located in myC/abc/ with this :
#include "lib/myheader.h"
But myheader.h is located in myC/lib/
So the only way I found is :
#include "../lib/myheader.h"
But I need to keep the same code. So I can't change the file.
Is it possible? Anyone have an idea?
I use CMake to add C code to my project.

I fixed it. I add include_directories(src/main/myC) in my CMakeList.txt.

Related

Why Visual Studio Code can't compile my C code?

I have a problem which is: VSC can't compile my C code as the title said. I have looked for the problems and did all what was necessary:
installed msys
installed mingw
installed C/C++ extensions
added code runner
Yet the problem is still showing like this:
gcc.exe: error: name.c: No such file or directory
(Note that I'm an absolute beginner when it comes to using VSC and don't have any background in coding so I'd appreciate it if I get to know the solution by simple vocabulary :) )
It seems like your c file('name.c') is not located in your working directory.
Moving your c file to your project folder may solve your problem.
To check your working directory, choose terminal tab and type 'pwd'.

Library Window at DevCPP

i'm trying to use window.h at devc++, i installed devc++ without mingw and installed MinGW32 separeted.
I'm trying to compile an souce code that have #include <window.h> but appear an error.
window.h: No such file or directory.
What can i do to be able to compile with window.h at dev c++?
At compiler options i had added path to mingw32\bin and mingw32\lib\gcc\mingw32.
What can i do to solve that?
I believe you want to use #include <windows.h> instead, which is the typical include statement for the Windows header file. Note the 's' in the windows.h.

First steps with SQLite and C

i'm trying to use SQLite in C. I downloaded the precompiled Binaries for Windows from the SQLite-Homepage. I extracted them and added sqlite to my environment path var. Using the command line, everything works.
Now i trying to use sqlite in a simply C-Code. Many Tutorials showed me to beginn with:
#include <sqlite3.h>
But my Compiler can't find the the file. The same result, trying with:
#include "C:/sqlite/sqlite3.h"
I'm new at C but don't i need a Header-File (*.h) for the #include command? Because the downloaded sqlite package only consist of: sqlite3.def, sqlite3.dll, sqlite3.exe (shell).
Thanks for your help
To use SQLite, download the source (the amalgamation), and include sqlite3.c in your project, together with your other source files.
(The sqlite3.h file should be in the same directory.)

assert.h missing when compiling with mingw

I am compiling C code with MinGW. The C code is a tcl package/extension.
(using the MinGW compilor, downloaded: mingw-get-inst-20111118.exe)
Compiling the code (e.g. the tcl package) works fine under linux.
I am running "./configure" and using the supplied "Makefile.in".
The problem is that the C code at some point includes "assert.h".
The other header files are fine, e.g. for "string.h" and "stdlib.h".
This is because the TCL sources include a subfolder called "./compat". In this filder the header files are located just in case they are not found somewhere else.
But in the "./compat" folder the file "assert.h" is missing. So I get an error.
I searched for the header file in "c:\MinGW\include" but I did not find "assert.h" there.
Either I copy my own "assert.h" in the "./compat" folder. Or I install some MinGW package that puts some "assert.h" in a subfolder of "c:\MinGW\".
=== SOLUTION: ====
c:\MinGW\include\assert.h
I was the hole time in front of me!!!
My bad! thx.
<assert.h> is part of standard C and included with the base dev package:
Did you download the dev package?
Did you download this?
http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/mingwrt-3.20/
I don't know about the peculiarities of the tcl package, but if it includes its own assert.h. then you should include on on the Include path, along with the libraries that came with it.
Which IDE are your using?
It seems you downloaded only mingw partially. Download the full development package that is bundled with IDEs like Codelite and Code::Blocks.

Eclipse CDT -- How to map Linux path's to Windows paths?

We have a C-code project written for a Linux environment but we also want the ability to view and edit the code on Eclipse for Windows and have the headers be resolved. The problem we are facing is that a lot of the headers are included with absolute paths in the Linux format such as:
#include "/path/to/custom/header.h"
What I would like to be able to do is have Eclipse CDT map:
/path/to/custom/ --> C:\path\to\custom\
Is this possible?
I suppose you should rather use the classic way and inlude the directories where the header files are located, instead of refering to an absolute path in your sources.
#include "header.h"
and add -Ic:\path\to\custom

Resources