We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Gcc Compilation file not found

  • Hi,

    I am trying to compile a source code on Onion Omega 2S+
    I have installed GCC on Onion Omega (booting from external SD card)
    GCC Version: gcc (OpenWrt GCC 5.4.0) 5.4.0

    I am able to compile a simple hello world and other programs which have C header files in the same directory.

    Now I am trying to compile a source code which has header files in multiple directories.
    I used below command to compile my code.

    gcc -I/root/Abc/api_lib/include -o test analyzer.c

    I get the error as No Such file or directory (for header files).
    But these header files are in this location "/root/Abc/api_lib/include"

    I even added this directory path in PATH environment.
    I still get the same error.
    Could anyone help me on this??

    I am new to Linux environment.

    Any pointers on this will be much appreciated.

  • @Rohit-P without seeing the specific error or knowing your level of experience, my first thought is maybe you are using

    #include "myheader.h"

    instead of

    #include <apiheader.h>

    The former is a literal path, the latter will look down the include path

  • Hi @crispyoz ,
    Thank you for your response.

    I have used #include <Myheader.h> as I am including the directory path in the PATH environment.

  • @Rohit-P have you checked you have the correct case in your path and header names, linux is case sensitive.

  • @crispyoz Thank you for the support.

    Yes the names are proper and the path name is also same.
    And yes i am aware that it is case sensitive.

  • @Rohit-P add -v to your commandline so gcc will show you where it is looking, also ensure you have a space between -I and your include path

  • @crispyoz Thank you for your support.
    I am able to compile it now.
    I tested with a small program.
    There was a mismatch in the header file declared.

    Now the issue is that my source code has lot of subfolders defined and each sub folder contains different header files.

    Do I have to include all the Subfolders through -I command?
    This becomes very much difficult.

    So do you suggest me to write a Makefile for this?
    Or we can do it through commandline?
    and all these headers in my source code use "" for includes.

    Thanks in advance.
    Please provide me with some pointers, would be of great help.
    Any pointers for suggested reading will be much appreciated.

  • @Rohit-P Glad you were able to compile now. You can add each include directory in additional -I parameters, alternatively you can use the environment variable C_INCLUDE_PATH like this:

    export C_INCLUDE_PATH=.:/some/include/path:/some/other/include/path

    if you are using C++ the variable is CPLUS_INCLUDE_PATH

    GCC is well documented , take a look at gcc.gnu.org.

    You could use a make file, most people would for a project of any complexity, but I wonder why you are not using the cross compiler instead as this is a much faster method of compiling code of any complexity. Also it will allow you to use your favorite IDE.

    Here is the document link on how to set up cross compilation environment:


  • @crispyoz Thank you for all your time and support.

    Thank you for the pointers on GCC will learn about it more.
    Yes I will setup the cross compilation environment.

  • @Rohit-P You're welcome. Good luck with your setup.

Log in to reply

Looks like your connection to Community was lost, please wait while we try to reconnect.