版主: wanchong , wangyu , eepwwp , firedom

分享到:
共50条 1/5 1 2 3 4 5 »   

解决Eclipse使用UPM库错误__设置链接库

    [您是本帖的第7385位阅读者]
lilianhu
我是MM
普通会员

最后登陆时间:2015-10-30 14:46:45

直达楼层
1# 发表于 2015-03-12 10:04:23
在eclipse编写edison或者伽利略程序的时候经常会用到其他类库,刚接触到eclipse的朋友就无从下手,也不知道怎么去搜索解决方法。
       我们以官方的upm器件库来做演示
       upm器件库包含了很多的元件模块,如下图

我们以st7735 LCD液晶屏模块来做演示,st7735 就是arduino官方的那个LCD模块

首先打开eclipse,  没有下载的朋友请参考部署eclipse

在官方例程“2_cpp_helloworld"右击,点击"Copy"复制,


在项目资源管理器空白处右击,点击"paste"粘贴,重命名一下,注意不要有中文






这样做的目的是因为官方例程的程序很多设置已经帮我们配置好了,我们只需要修改少量的设置就可以正常编译


打开刚才复制的官方例程代码,进行编辑,复制粘贴下面的代码



01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * Author: Yevgeniy Kiveisha <[url=mailto:yevgeniy.kiveisha@intel.com]yevgeniy.kiveisha@intel.com[/url]>
 * Copyright (c) 2014 Intel Corporation.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
 
#include <string.h>
#include <unistd.h>
#include <iostream>
#include "st7735.h"
#include <signal.h>
 
int
main(intargc,char**argv)
{
//! [Interesting]
    upm::ST7735 * lcd =newupm::ST7735(7, 4, 9, 8);
    lcd->fillScreen (ST7735_RED);
    lcd->refresh ();
 
    lcd->fillScreen (ST7735_CYAN);
    lcd->refresh ();
 
    lcd->fillScreen (ST7735_BLACK);
    lcd->refresh ();
 
    lcd->drawLine(10, 10, 10, 100, ST7735_MAGENTA);
    lcd->drawLine(20, 20, 10, 100, ST7735_YELLOW);
    lcd->drawLine(30, 30, 50, 100, ST7735_WHITE);
    lcd->refresh ();
 
    lcd->drawPixel (20, 20, ST7735_GREEN);
    lcd->refresh ();
 
    lcd->drawTriangle (50, 50, 80, 80, 60, 90, ST7735_GREEN);
    lcd->refresh ();
 
    lcd->drawCircle (100, 110, 10, ST7735_BLUE);
    lcd->refresh ();
 
 
    lcd->setTextWrap(0x0);
 
    lcd->setCursor(0, 30);
    lcd->setTextColor(ST7735_RED, ST7735_RED);
    lcd->setTextSize(1);
    lcd->print("Hello World!");
 
    lcd->setCursor(10, 50);
    lcd->setTextColor(ST7735_RED, ST7735_YELLOW);
    lcd->setTextSize(2);
    lcd->print("BIG");
 
    lcd->refresh ();
 
    std::cout <<"exiting application"<< std::endl;
 
    deletelcd;
//! [Interesting]
    return0;
}

按Ctrl+S保存


     
可以看到eclipse提示这些代码有很多错误,之所以有那么多错误提示是因为我们没有在eclipse设置upm-ST7735类库的头文件和链接库
#include "st7735.h"

设置头文件的步骤是在当前程序目录下 右击,点击属性进行设置


然后依次点击”C/C++ Build->Settings->Cross G++ Compiler下的Includes,点击

右上角的加号->File system选择路径,进行头文件添加,我们这里选择“C:\Users\While\Desktop\upm-master\src\st7735”这是我的upm库的路径,需根据自己的存放位置选择
st7335器件库头文件设置完成


现在需要设置st7735的链接库,关于链接库更多信息请点击动态链接库
设置方法如下:
           在当前程序目录下右击,点击属性进行设置,然后依次点击”C/C++ Build->Settings->Cross G++ Linker下的Miscellaneous,在Linker flags里面填入 ${LDFLAGS} upm-st7735




其中的${LDFLAGS}是环境变量,我的指向C:\Users\While\Desktop\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux\usr\lib           upm-st7735是要链接的库名字,st7735链接库文件名是"libupm-st7735.so"写的时候省略lib和扩展名



链接库就配置好了,点击确定,按Ctrl+S保存代码。提示:编译代码的时候要先保存


我们再编译一下刚才的代码,现在就不会有错误提示了




关于链接库的介绍结束





RE: 解决Eclipse使用UPM库错误__设置链接库

xc1234
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:12

2# 发表于 2015-03-13 17:25:49
膜拜大神

RE: 解决Eclipse使用UPM库错误__设置链接库

wuchangjing
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:15

3# 发表于 2015-03-13 23:46:06
我说看不懂你会打我吗?

RE: 解决Eclipse使用UPM库错误__设置链接库

gaoxingxing
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:19

4# 发表于 2015-03-14 17:13:44
楼主好流弊

RE: 解决Eclipse使用UPM库错误__设置链接库

xwf20050250
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:20

5# 发表于 2015-03-14 20:21:19
吊啊

RE: 解决Eclipse使用UPM库错误__设置链接库

x66442002
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:24

6# 发表于 2015-03-14 21:26:30
挺不错,

RE: 解决Eclipse使用UPM库错误__设置链接库

wuchangjing1
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:28

7# 发表于 2015-03-15 13:50:11
好好学习,板子做的好

RE: 解决Eclipse使用UPM库错误__设置链接库

348772317
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:29

8# 发表于 2015-03-15 14:48:27
外围模块到不错

RE: 解决Eclipse使用UPM库错误__设置链接库

wuchangjing2
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:34

9# 发表于 2015-03-15 16:04:30
参考,学习

RE: 解决Eclipse使用UPM库错误__设置链接库

handys
我是MM
普通会员

最后登陆时间:2015-01-14 11:05:35

10# 发表于 2015-03-16 08:33:32
来顶一个 准备入手一个。。
共50条 1/5 1 2 3 4 5 »   
快速回复主题
  • 匿名不能发帖!请先 [ 登陆 注册 ]