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

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

Related

Android Studio : include an other path in a c file

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.

How to make project folder act as system folder in Eclipse Luna

I'm working on a porting of the net-snmp library. I started by importing the parts of the code that I need in my Eclipse Luna project, running on Lubuntu Linux 15.10. I don't want to modify every single file from (for instance)
#include <net-snmp/net-snmp-config.h>
to
#include "net-snmp/net-snmp-config.h"
I don't want to install net-snmp in my system either, to avoid confusion.
How do I tell Eclipse to look in the project root for header files?
Thanks
Ok I think I found a way:
go to Project Properties
under C/C++ Build go to Settings
under the tab "Tool Settings" go to "Includes" under "GCC C Compiler"
Click the "+Add" icon under "Include paths (-l)"
Click "Workspace" and then select the folder

CMake: Header files cannot be opened

I am working to build a Code Composer Studio project using cmake, which is new to me. It builds successfully under Linux but I am struggling to get it to work under Windows. The cmake command executes without issue, but make fails during the very first C object at the very first #include with the error code
fatal error: could not open source file "stdbool.h" (no directories in search list)
I'm using the libraries included in CCS's compiler (c6000_7.4.15), and that whole folder is included in the CSS project. I include it in cmake as well. In my .cmake file:
set (CCS_ROOT ${CCS_ROOT_V6_WIN} CACHE PATH "code composer install directory")
set(CGT_COMPILER_ROOT ${CCS_ROOT}/tools/compiler/c6000_7.4.15 CACHE INTERNAL "DSP Compiler Root")`
And in the CMakeLists.txt file:
set (COMPILER_INCLUDE ${CGT_COMPILER_ROOT}/include)
INCLUDE_DIRECTORIES ("${COMPILER_INCLUDE}")
Why can the header files not be opened when they're linked in the project and CMake can find them just fine?
EDIT: The directory structure had been changed underneath me, so I took the opportunity to add all of the external files directly into the project to make it completely platform-independent. That way, since the project is managed by our Git repository, users won't have to install the CSL or any other programs to build the project. This also means that paths to libraries and header files will never change between revisions and environments.
Unfortunately, this has not solved my problem. The project continues to build in Linux while failing to ind the very first included header file. I also notice that, under Windows, it cannot find my own header files unless I provide a relative path, e.g. #include "../Common.h" I can get make to find stdbool.h if I provide an absolute path to the compiler directory, but that exposes a web of additional broken links between files.
As a side note, the project builds successfully within Code Composer Studio, so I am assuming that this isn't an issue with my specific Windows environment nor with the code within the project itself.
This seems to be an issue with gcc.exe. I set an environment variable CC to the path of a different compiler (in my case a TI compiler) within my build script and that fixed the problem.

including wpa_ctrl.h in a C code

I would like to add wpa_ctrl.h on a C code, and the source code has the following header files:
#include "includes.h"
#include "common.h"
how do I suppose to have them? Do I need to install any package or do they suppose to be at the kernel header files or in the include path? If I need to include it manually, then each file depends on some many header files that needs to be added manually, is there a convenient way to add the files that are needed
These files are part of the hostapd project, and internal header files that won't be installed so you can't just include them after installing the package.
You'd be probably better off just ripping out the parts from wpa_ctrl.h you need. Depending on what you need it might be even better to use e.g. the DBus interface to communicate with wpa_supplicant (if that's what you want).
You get them from wpa_supplicant source code.
Here's where to find them:
wpa_supplicant-2.4/src/utils/includes.h
wpa_supplicant-2.4/src/utils/common.h
I copied them into my project directory and everything worked.
Here's where to find the source code:
https://w1.fi/releases/

How can I link the source path of a compiled library to a different location in Eclipse?

I've installed the msp430-gcc compiler and associated tools to do some open-source msp430 development at home using Eclipse. I'm developing on a slightly older Macbook Pro running OS X Lion and installed the tools using MacPorts. I'm running Eclipse 3.7.2 with the CDT and GCC Cross Compiler Support plug-ins. I have a simple empty main() written that compiles and links just fine.
The ELF parser lets me view the contents of the ELF binary just fine with the exception of one component; when I try to view the contents of the startup code in crt0.S, it gives me a blank file. When I click on the crt0.S component of the ELF, the filename bar at the bottom of the Eclipse window shows "/opt/local/var/macports/build/_Volumes_work_mports_dports_cross_msp430-gcc/msp430-gcc/work/gcc-4.6.3/gcc/config/msp430/crt0.S". This makes sense because of my MacPorts install of msp430-gcc. crt0.S is archived into /opt/local/lib/gcc/msp430/4.6.3/libcrt0.a on my machine.
What I want to be able to do is tell Eclipse to look elsewhere for the source files for the libraries that are automatically linked when I build with the msp430-gcc toolchain. This would presumably include everything in /opt/local/lib/gcc/msp430/4.6.3/. I started by downloading the source for mspgcc-20120406 (the version in my MacPorts install) and applying the gcc patchfile to an empty directory tree. This created the gcc/config/msp430 directory, including the crt0.S and crt0ivtbl.S files.
What I have had no luck accomplishing is telling Eclipse to look in ~/Developer/mspgcc-20120406/gcc-4.6.3/config/msp430/ instead of the path that's in the already-built libcrt0.a. I tried playing around with the Project Preferences->Paths and Symbols->Source Location window, but didn't have much luck. I searched through this website and on Google and the closest thing I came up with was this question but it doesn't "smell" like the right answer.
I would like to avoid solutions that involve moving the library source into my project. I'd rather have a solution that will work for multiple projects.
All help is greatly appreciated! Thanks in advance.
Try and check if the Eclipse linked resource could help you declare that external directory from within your Eclipse project here.
Linked resources are files and folders that are stored in locations in the file system outside of the project's location. These special resources can be used to add files and folders to your project that for some reason must be stored in a certain place outside of your project. For example, a linked folder can be used to store build output separately from your source files.
I find interesting how you can define that linked resource:
Linked resource target paths can be either defined as absolute paths, or relative to a path variable.
Since you can define it relative to (for instance) your Eclipse project location PROJECT_LOC, you can then setup your resource in a way which won't change between two environments.

Resources