fatal error: sqlite3.h: No such file or directory

后端 未结 2 948
花落未央
花落未央 2020-12-25 12:00

I\'m trying to build a C application through cross compiling for a Zynq board (ARM architecture). When I type make without mentioning the ARM arch, it works fine on my lapto

相关标签:
2条回答
  • 2020-12-25 12:17

    You don't provide enough information to say for sure: in particular, you don't say where the sqlite3.h file actually is on your filesystem. However, based on what you do show I suspect you need to change the INCLUDES variable, to this:

    INCLUDES = lib/sqlite
    

    (or else change the #include in your code to be #include "sqlite/sqlite3.h"). This is assuming that the header file is in the same directory as the sqlite3.c source file.

    Note that this is a bad/confusing implementation. You should be putting the -I flag in the INCLUDES variable:

    INCLUDES = -Ilib/sqlite
        ...
    $(PROGRAM): $(SOURCE)
            $(CC) $(SOURCE) $(INCLUDES) -o$(PROGRAM) $(LDFLAGS)
    

    INCLUDES is plural which may lead someone to believe they could add multiple directories in that variable, but if you leave it the way you have it, this will cause strange compiler errors:

    INCLUDES = lib/sqlite another/dir
        ...
    $(PROGRAM): $(SOURCE)
            $(CC) $(SOURCE) -I$(INCLUDES) -o$(PROGRAM) $(LDFLAGS)
    

    will add the flags -Ilib/sqlite another/dir... note how the second directory doesn't have a -I option.

    Of course, by convention you should be using CPPFLAGS (for C preprocessor flags), not INCLUDES, but... :)

    0 讨论(0)
  • 2020-12-25 12:25

    I got this issue fixed with

    $ sudo apt-get install libsqlite3-dev
    

    (debian wheezy)

    0 讨论(0)
提交回复
热议问题