Dealing with include files in C / zephyr-rtos - c

I have a little project where I want to use the ESP32's ADC, and I want to use zephyr as my RTOS. I am using one of the examples provided by the ESP-IDF to set the register and read input from the ADC pins. This example works if I use the idf.py tool and within the same folder. Now I try to use west to build and flash this project into the esp32 with zephyr running on it, however when I try to build the project west cannot find the header files/source files specified inside the program. I have tried using absolute paths in every header file, moving the project+include folder to the zephyr workspace, initializing west inside the esp-idf workspace, etc... None of this has worked for me.
I suspect something along the cmake files is messing up with my project, but I really cannot pinpoint exactly what that is. My question is, how can I deal with header/source files that are outside the zephyr workspace? My folders look something like this:
Zephyr workspace
|-------ADC target project (copied originally from espressif folder)
|-------include files from zephyr
Espressif workspace
|-------ADC original project
|-------include files from espressif (I want to link this files to zephyr)

Related

Compiling with SDL in different directories

I'm trying to do a project which uses SDL2 to do the graphics.
I want to have my project files in a directory.
I have the functions that manipulate the SDL directly and pictures in a subdirectory of this (UI_library).
I solved the compiling part by adding to the compilation commands
-LUI_library
The problem is that when I run the program, it can't find the pictures, since it assumes they are in the project directory and not in the subdirectory.
Do you know how to fix this without manually changing the code in the subdirectory? There are a lot of references to the pictures in the library.
One way to solve this problem would be addressing the whole path to your file.
For Example:
Windos:
SDL_LoadBMP("C:\Documents\your_image.bmp")
Linux:
SDL_LoadBMP("/home/tigre200/Documents/your_image.bmp")

ioquake3 on MacOS: Bundling Freetype With Game

I'm making a game based on ioquake3, and I enabled the use of Freetype for rendering fonts in the game.
However, that library has been a sore on my back throughout the development, and now the game doesn't run right on MacOS computers besides my own because they don't have Freetype installed.
It will look for "renderer_opengl2_x86_64.dylib" in "." and fail. Yet ioquake3 runs just fine on the same computer. And if I transfer ioquake3.app's renderer dylibs, the game runs but without the text rendering because Freetype isn't enabled by default.
So my question is how I would be able to bundle Freetype with my ioquake3-based game. I thought it would be as simple as copying libfreetype.6.dylib into [game].app/Contents/MacOS , but that didn't work either. The original game doesn't use it so copying the renderer dylibs didn't work. I don't want every user to have to install Freetype and link it and all that, so how do I get the library bundled with my app?
OK, so I found out that the renderer dylib files were calling on a hard-coded directory in the system, a directory I had to map myself to get the game to compile but otherwise is not on a normal MacOS computer.
So what I did was use install_name_tool in Terminal to change the directory the dylibs searched in.
install_name_tool -change /usr/local/lib/libfreetype.6.dylib #executable_path/libfreetype.6.dylib /Applications/{game name}.app/Contents/MacOS/renderer_opengl2_x86_64.dylib
^ Then the same thing for the OpenGL 2 dylib, and I copied the libfreetype.6.dylib file into the Contents/MacOS directory of my app. After that, the game ran perfectly on my computer and the "guinea pig" computer I used that didn't have Freetype installed.
I hope this might help anyone else having issues with Freetype and ioquake3!

How to make multiple subdirectories in Eclipse from existing code

I am using Windows 10 and Eclipse Mars edition 32 bit. Programming in C
I am trying to learn C from a Lynda.com course C Essential Training. The course provides a zipped directory with many .c and files and a few others like .h files as you can see below.
However in the video he managed to get each .c file and related source code into its own directory structure.
I've tried numerous type of imports and I also used a batch file to put each .c file in its own folder and tried importing that. I was able to get the Eclipse IDE project window to look like the instructors, but as soon as I tried to compile individual .c programs the project kept looking in the primary workspace folder which for me is C:\Source\Testing\workspace and error'd out.
Is there an import option to create this type of subdirectory structure automatically? I want to go through the tutorial and build and execute each .c file individually. However what I have had to do is put the .c file into a single folder build it and run it one at a time. I then have to delete the source and debug folder and start over for each lesson. There must be a better way.
Eclipse workspace is streigh connected to FS.
This means that your workspace in Eclipse is a folder on your hard disk or where it is stored.
What you can simply do is to create a new folder using right-click-popup-menu within Eclipse Project Explorer and then copy/move files into the new folder.
Or you can create a new folder into your workspace directory and copy/move file inside, then you must refresh Eclipse workspace.

relative path and system paths are not working in codeblocks

When I am trying to access files from standard usr/ it is not working. and showing errors that file is missing .
I have added path but and make it work but i think this is not the correct way.
I have a workspace with 10-12 projects which are of c and cpp both.
In one project I am using cpp with thrift libraries and protocol.
in that project only I am facing issue. with I am individually building that project it is working but when building it from the main project. it starts showing error in files.
There all almost 17 projects and 16 are generating .so files and all are going to the main project. and main is generating an executable. and that executable uses all the .so files.
but In thrift only it is showing errors. before it was showing for #include i added that file so now it is showing undefined type Name Space ..
I think this issue is because of relative path but I am not sure
Please Help

Add external source files from a library to the project in Eclipse-CDT

I have a project which I try to compile with Eclipse-CDT. The project depends on a library with header files and source files. How can I configure the project in Eclipse such that it will compile the needed source files from the library with the project?
With a makefile I use:
SRC+=lib_source.c
You can add linked source file.
Choose project properties and in the left panel choose c++ general.
Under it choose path and symbols.
Now in the right panel tabs choose source location and add linked source folder.
Include you need to define in "include" (under c++ build you will find settings)
Another approach is to use the operating system to add your libraries to the project. Eclipse then treats all source files (including library files) as part of the project, and therefore compiles any that need it even if they are in the libraries. This set-up allows keeping the library sources in a separate git repository from the project source code. You can record the git commit of a library to provide library version control so that improving the library in one project does not break all the others. The setup relies on the operating system's capability to link directories in a way that is entirely transparent to eclipse--in windows using the mklink command.
In windows the steps are
put your library files in a clean workspace not mixed with .git (you can have .git in the parent directory as egit sets it up)
use cmd window in administrator mode to add a link from your project directory to your library directory.
from eclipse press F5 t make sure your project matches what is on disk, then set up git to ignore your library directory.
set up your library file properties for read only access unless you are still tweaking that library.
set up your project include path to include the project sub-directory in your project.
I can't remember why I abandoned eclipse linked directories; i think it was that the includes kept breaking. The mklink approach has worked flawlessly so far.
I have a pdf tutorial of how to set this up--but I'm new to the forum and don't see how to attach a file.

Resources