简体   繁体   English

如何包含自定义C库

[英]How to include custom C library

I'm trying to implement a custom library that I found oline. 我正在尝试实现一个我发现oline的自定义库。 Here is the link: http://rinkydinkelectronics.com/library.php?id=80 这是链接: http//rinkydinkelectronics.com/library.php?id = 80

I wanna use some of the functions to help me display the game snake with the chipKIT basic I/O shield for the UNO32 board. 我想使用一些功能来帮助我用UNO32板的chipKIT基本I / O屏蔽显示游戏蛇。

I put the files 我把文件

  • OLED_I2C.cpp OLED_I2C.cpp
  • OLED_I2C.h OLED_I2C.h
  • and both files inside OLED_I2C/hardware/PIC32 (since PIC32 is the hardware I have) 以及OLED_I2C / hardware / PIC32内的两个文件(因为PIC32是我的硬件)

into the same directive where my main is. 进入我主要的同一指令。 (My main is in a file called project.c) (我的主要是在一个名为project.c的文件中)

I then tested if the library works by trying to initialize the display with it, as I've seen in the examples that come with the download. 然后,我通过尝试使用它初始化显示来测试库是否正常工作,正如我在下载附带的示例中看到的那样。 Like so: 像这样:

(I removed the rest of the program and only kept the relevant parts) (我删除了程序的其余部分,只保留了相关部分)

#include <OLED_I2C.h>

OLED  myOLED(SDA, SCL, 8);

void setup()
{
    myOLED.begin();
}

main 
{
    setup();
}

But I got the error: 但是我得到了错误:

project.c:5:22: ödesdigert fel: OLED_I2C.h: No such file or directory
 #include <OLED_I2C.h>
                      ^

 (ödesdigert fel = fatal error)

Why can't it find the file, even though I put it in the same directory as my main file? 为什么它找不到文件,即使我把它放在与我的主文件相同的目录中?

Could anyone help me understand what I'm doing wrong, or perhaps, what I've gravely misunderstood? 任何人都可以帮助我理解我做错了什么,或者也许,我严重误解了什么?

PS. PS。 I'm sorry I wasn't able to include library in the tags, but library alone was not an option, and I simply do not know enogh about libraries to tell for sure what type this is. 对不起,我无法在标签中包含库,但单独的库不是一个选项,我根本不知道如何知道库是什么类型的库。

Change 更改

#include <OLED_I2C.h>

to

#include "OLED_I2C.h"

Angle brackets tell the compiler to look for the file in the system PATH (an environment variable set by the operating system which contains paths to critical binaries/libraries etc). 尖括号告诉编译器在系统PATH中查找文件(由操作系统设置的环境变量,其中包含关键二进制文件/库的路径等)。 Double quotes refer to files in the current working directory. 双引号是指当前工作目录中的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM