Monday, 15 March 2010

compilation - Compiling C++, organising include files -


I am trying to modify and compile uvccapture on Raspberry Pi. I got the source (these are just some files). (I think) only external files are needed, they are jpeglib that I downloaded from.

When compiling, where do I put jpeglib source files? The following line is in UVCCapture:

  #include & lt; Jpeglib.h & gt;   

Does this mean that I should have jpeglib source files in the same directory as the UPCSE source source? It seems messy. How can I set compiler (modify makefile?), And that's why I include file lines to change uvccapture?

And one does not need where I should keep jpeglib files, side questions, how come it only includes .h file and Not a C file? (I'm quite new to C / C ++)

Here's the makefile:

  cc = gcc cpp = g ++ APP_BINARY = uVccapture VERSION = 0.4 PREFIX = / Usr / uvccapture clean: local / bin alert = -Wall CFLAGS = -std = gnu99 -O2 -DLINUX -DVERSION = \ "$ (version) \" $ (warning) CPPFLAGS = $ (CFLAGS) = uvccapture.o v4l2uvc O All items: @ echo "cleaning directory." Rm -f * A * O $ (APP_BINARY) core * ~ logon install errorlog installed: $ (APP_BINARY) $ (prefix) $ application: uvccapture: $ (items) $ (cc) $ (objects) $ (XPM_LIB) $   P> The source file ( uvccapture.c ) does not care where the header file ( jpeglib.h ) - should not be at least this. The compiler should be told where the header files will be; Traditionally, the header files go to some directories such as  inc_files / , and compile a command like  
  GCC-Blah-Blah-Blah-Ens_file-c- O uvccapture.o uvccapture.c   

If you use make, then execute a command like that. Then either edit the makefile, or put the header file in the current directory.

Wisely use #include contains the C / C ++ source files and header files, header files are foo.c There should be some lines like:

  #include & lt; Bars & gt; There are some lines in #include "baz.h"   

and baz.h such as:

  #include & LT; Vector & gt; #include "qux.h"   

You can almost never see #include foo.c , because it's almost never a good idea.

No comments:

Post a Comment