版主: wanchong , wangyu , eepwwp , firedom

分享到:
共9条 1/1 1   

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

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

最后登陆时间:2015-10-30 14:31:32

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



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


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

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



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





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


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


[C++] 纯文本查看 复制代码
?
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库的路径,需根据自己的存放位置选择,附上upm库下载地址: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:by zpeng

13930862386
我是MM
普通会员

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

2# 发表于 2015-04-15 16:29:27
好好学习,板子做的好

RE:by zpeng

wuzebang
我是MM
普通会员

最后登陆时间:2015-01-14 10:40:03

3# 发表于 2015-04-16 21:35:47
机械工程小白默默路过。

RE:by zpeng

letree
我是MM
普通会员

最后登陆时间:2015-01-14 11:09:51

4# 发表于 2015-04-17 21:18:44
赞呐!

RE:by zpeng

jason612
我是MM
普通会员

最后登陆时间:2015-01-14 11:02:58

5# 发表于 2015-04-21 23:54:13
感谢分享

RE:by zpeng

645238061
我是MM
普通会员

最后登陆时间:2015-01-14 11:04:30

6# 发表于 2015-04-22 10:12:06
等更

RE:by zpeng

lygfsy6612
我是MM
普通会员

最后登陆时间:2015-01-14 11:03:47

7# 发表于 2015-04-22 13:57:19
高中,自学,没有任何基础,只有一腔热血。

RE:by zpeng

joexiao
我是MM
普通会员

最后登陆时间:2015-01-14 10:52:23

8# 发表于 2015-04-26 15:50:44
感谢分享

RE:by zpeng

asd44441717
我是MM
普通会员

最后登陆时间:2015-01-14 10:40:17

9# 发表于 2015-04-29 07:27:49
这个贴子必须顶
共9条 1/1 1   
快速回复主题
  • 匿名不能发帖!请先 [ 登陆 注册 ]