Problem in addin new heder files to my program

Discussion in 'C' started by ahrouhi, Jul 6, 2011.

  1. ahrouhi

    ahrouhi New Member

    Joined:
    Mar 11, 2011
    Messages:
    24
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Student/Research
    Location:
    Melbourne
    Hi everybody
    I am using DEV C++ compiler and write simple standard C code in this compiler. I encontered a problem when i included some new header files and wnated to use some of the functions inside the header files.
    I updated the include file directory and add the location of new header files to the compiler but still the compiler can not recognise the function which are in new header files. Whats your advice?:thinking:
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    I see you're fairly new here. Think through this problem description for a moment. How descriptive is it? How likely is it that we'll be able to provide a solution?
     
  3. ahrouhi

    ahrouhi New Member

    Joined:
    Mar 11, 2011
    Messages:
    24
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Student/Research
    Location:
    Melbourne
    You are right, my explanation about the problem was so naive. My problem is that i wnat to use an open source software(ffmpeg) which has written in C. I have downloaded all header files and other related source file and also ffmpeg.c file in a folder. I want to compile ffmpeg.c so i do the following:
    1-Open ffmpeg.c file in DEV C++ compiler.
    2-Set Include directory from tools/compiler options/ directories to ffmpeg/libavcodec (folder containing headers).
    (There is a another setting place for libraries which i dont know i should set it to which directory.)
    3-Compile the program.

    But I get many compile time errors such as:
    "Line 30 In file include c:\.......libavutil\avutil.h" and when i look at the line in that header file it is just a global variable.
    Whats your advice?
     
  4. ahrouhi

    ahrouhi New Member

    Joined:
    Mar 11, 2011
    Messages:
    24
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Student/Research
    Location:
    Melbourne
    regarding the above mentioned problem, If you have a look in this link, You may get my mean in another point of view:
    dranger.com/ffmpeg/tutorial01.html
    In the link, the author easily describe how to add a header file and then use the functions used in header files. But when i follow the same on my code, i encounter the problem again:
    the simple line of code is here:
    But the compiler at first function call : av_register_all();
    make an error and says "av_register_all undeclared"
    I know that header files just contain the function prototypes. do i need install appropriate dll? Do i have to make a linking file first? How?
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Please post the *exact* error messages. Do not attempt to reinterpret them; you remove the essential information that helps experts determine the cause. Feel free to ADD your interpretation, but do not post ONLY your interpretation.

    Are the errors thrown by the compiler or the linker? These have very different implications.
     
  6. ahrouhi

    ahrouhi New Member

    Joined:
    Mar 11, 2011
    Messages:
    24
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Student/Research
    Location:
    Melbourne
    Sorry about that.the error is compiler error and the compiler log is:
    As can be seen even header files did not recognise.
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    OK, you need to learn to read an error list, specifically you must start with the FIRST error not the LAST.

    The first error is this:
    C:\1-Rouhi-Personal\My-C-H264\MyFrameCounter\test2.cpp:5:28: ffmpeg/avcodec.h: No such file or directory

    which explains exactly why it doesn't know what an av_register_all is - this is most likely declared in one of those headers.

    The compiler (actually the preprocessor) looks in the current directory, in a series of "standard" locations, and at -I clauses on the command line to find header files. The only -I's you've specified are:

    -I"d:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"
    -I"d:\Dev-Cpp\include\c++\3.4.2\backward"
    -I"d:\Dev-Cpp\include\c++\3.4.2\mingw32"
    -I"d:\Dev-Cpp\include\c++\3.4.2"
    -I"d:\Dev-Cpp\include"

    so it's my guess that d:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include\ffmpeg/avcodec.h,
    d:\Dev-Cpp\include\c++\3.4.2\backward\ffmpeg/avcodec.h,
    and the other three, don't exist.

    As you've told the linker (with -L) to look in
    C:\1-Rouhi-Personal\SoftwareH264\SoftwareFFMPEG\ffmpegWinComm and-0.5\libavcodec
    and
    C:\1-Rouhi-Personal\SoftwareH264\SoftwareFFMPEG\ffmpegWinComm and-0.5\libavformat
    for libraries, you need to locate avcodec.h somewhere under
    C:\1-Rouhi-Personal\SoftwareH264\SoftwareFFMPEG
    then add - not THAT directory, but the directory that contains the ffmpeg directory that itself contains avcodec.h, to the g++ line as another -I clause.

    When linking with non-standard libraries, you normally need to tell the preprocessor where to find headers with -I and the linker where to find libraries with -L and/or -l (lower case L).

    This also highlights what to do about multiple errors. The fix for the first error should fix the second, and in this case also the third. This is useful when faced with 100s of errors; don't lose your cool, just look at the first 2-3 errors and fix those, then recompile before moving on to the next.
     
  8. ManzZup

    ManzZup New Member

    Joined:
    May 9, 2009
    Messages:
    278
    Likes Received:
    43
    Trophy Points:
    0
    Occupation:
    Production Manager:Software @ ZONTEK
    Location:
    Sri Lanka
    Home Page:
    http://zontek.zzl.org
    whats you have to understand is that ffmpeg is one of those large project with many headers and other interconnected files which are needed to be included in order for even the smallest thing to work

    so if you follow uo a dicumentation by ffmpeg by itself closely it will be better
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice