0

I'm trying to modify and compile uvccapture on the Raspberry Pi. I got the source from here (it's just a few files).

(I think) the only external files it needs are those of jpeglib which I downloaded from here.

When compiling, where do I put the jpeglib source files? UVCCapture has the following line:

#include <jpeglib.h>

Does that mean I should put the jpeglib source files in the same directory as the UVCCapture source files? That seems messy. How can I set up the compiler (modify the Makefile?), and where should I put the jpeglib files so that I don't need to change the uvccapture include file lines?

And a side question, how come it only includes the .h file and not the .c file? (I'm pretty new to C/C++)

Here is the Makefile:

CC=gcc
CPP=g++
APP_BINARY=uvccapture
VERSION = 0.4
PREFIX=/usr/local/bin

WARNINGS = -Wall

CFLAGS = -std=gnu99 -O2 -DLINUX -DVERSION=\"$(VERSION)\" $(WARNINGS)
CPPFLAGS = $(CFLAGS)

OBJECTS= uvccapture.o v4l2uvc.o

all:    uvccapture

clean:
    @echo "Cleaning up directory."
    rm -f *.a *.o $(APP_BINARY) core *~ log errlog

install:
    install $(APP_BINARY) $(PREFIX)

# Applications:
uvccapture: $(OBJECTS)
    $(CC)   $(OBJECTS) $(XPM_LIB) $(MATH_LIB) -ljpeg -o $(APP_BINARY)

Thanks

4

1 回答 1

3

源文件 ( uvccapture.c) 不关心头文件 ( jpeglib.h) 在哪里——至少它不应该关心。必须告诉编译器在哪里寻找头文件;传统上,头文件放在某个目录中,例如inc_files/,并使用类似的命令调用编译器

gcc -blah -blah -blah -Iinc_files  -c -o uvccapture.o uvccapture.c

如果你使用 Make,那么 Make 应该执行这样的命令。所以要么编辑makefile,要么将头文件放在当前目录中。

在 C/C++ 中使用的明智方法#include是让源文件和头文件包含头文件。也就是说,foo.c其中会有几行,例如:

#include <bar>
#include "baz.h"

并且baz.h可能有几行,例如:

#include <vector>
#include "qux.h" 

你几乎看不到#include foo.c,因为这几乎从来都不是一个好主意。

于 2013-03-27T01:47:15.487 回答