设为首页收藏本站

arduino 单片机机器人爱好者之家

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 8135|回复: 5

error: ld returned 1 exit status,库文件冲突如何处理

[复制链接]

签到天数: 4 天

[LV.2]偶尔看看I

发表于 2016-1-7 00:08:06 | 显示全部楼层 |阅读模式
看不懂:
Arduino:1.6.7 (Windows 7), 开发板:"Arduino/Genuino Uno"

C:\Users\lion\AppData\Local\Temp\buildeb35d0ea9569b85ee8e1ef26ab5dce85.tmp/core\core.a(Tone.cpp.o): In function `__vector_7':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:539: multiple definition of `__vector_7'

libraries\IRremote\IRremote.cpp.o:C:\Users\lion\Documents\Arduino\libraries\IRremote/IRremote.cpp:107: first defined here

collect2.exe: error: ld returned 1 exit status

"IRremote.h" 对应多个库
已使用: C:\Users\lion\Documents\Arduino\libraries\IRremote
未使用:D:\Program Files (x86)\Arduino\libraries\RobotIRremote
exit status 1
编译有误。

  报告将会包含更多的信息
  "在编译时,输出详细信息"
  在 文件>首选项 中启用

签到天数: 4 天

[LV.2]偶尔看看I

 楼主| 发表于 2016-1-7 00:11:41 | 显示全部楼层
原程序:
[AppleScript] 纯文本查看 复制代码
#include <IRremote.h>
#include "pitches.h"
int RECV_PIN = 10;
int state = 0;
IRrecv irrecv(RECV_PIN);
decode_results results;
// notes in the melody:
int melody[] = {

  NOTE_E4, NOTE_E4, NOTE_E4, NOTE_C4, NOTE_E4, NOTE_G4, NOTE_G3,  
  NOTE_C4, NOTE_G3, NOTE_E3, NOTE_A3, NOTE_B3, NOTE_AS3, NOTE_A3, NOTE_G3, NOTE_E4, NOTE_G4, NOTE_A4, NOTE_F4, NOTE_G4, NOTE_E4, NOTE_C4, NOTE_D4, NOTE_B3, 
  NOTE_C4, NOTE_G3, NOTE_E3, NOTE_A3, NOTE_B3, NOTE_AS3, NOTE_A3, NOTE_G3, NOTE_E4, NOTE_G4, NOTE_A4, NOTE_F4, NOTE_G4, NOTE_E4, NOTE_C4, NOTE_D4, NOTE_B3, 
  NOTE_G4, NOTE_FS4, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_GS3, NOTE_A3, NOTE_C4, NOTE_A3, NOTE_C4, NOTE_D4, NOTE_G4, NOTE_FS4, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_C5, NOTE_C5, NOTE_C5, 
  NOTE_G4, NOTE_FS4, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_GS3, NOTE_A3, NOTE_C4, NOTE_A3, NOTE_C4, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_C4, 
  NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_C4, NOTE_A3, NOTE_G3, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_D4, NOTE_E4, 
  NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_C4, NOTE_A3, NOTE_G3

};

// note durations: 4 = quarter note, 8 = eighth note, etc.:

int noteDurations[] = {

  8,4,4,8,4,2,2, 
  3,3,3,4,4,8,4,8,8,8,4,8,4,3,8,8,3, 
  3,3,3,4,4,8,4,8,8,8,4,8,4,3,8,8,2, 
  8,8,8,4,4,8,8,4,8,8,3,8,8,8,4,4,4,8,2, 
  8,8,8,4,4,8,8,4,8,8,3,3,3,1, 
  8,4,4,8,4,8,4,8,2,8,4,4,8,4,1, 
  8,4,4,8,4,8,4,8,2
  
};
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();     // Start the receiver
  pinMode(7,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(2,OUTPUT);
}
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume();        // Receive the next value
    if(results.value == 0xFF30CF){
     digitalWrite (6,HIGH);
     digitalWrite (7,LOW);
     digitalWrite (5,LOW);
     digitalWrite (3,LOW);
     digitalWrite (4,LOW);
     digitalWrite (2,LOW);
    }
    if(results.value == 0xFF18E7){
     digitalWrite (7,HIGH);
     digitalWrite (6,LOW);
     digitalWrite (5,LOW);
     digitalWrite (3,LOW);
     digitalWrite (4,LOW);
     digitalWrite (2,LOW);
    }
    if(results.value == 0xFF7A85){
     digitalWrite (5,HIGH);
     digitalWrite (7,LOW);
     digitalWrite (6,LOW);
     digitalWrite (3,LOW);
     digitalWrite (4,LOW);
     digitalWrite (2,LOW);
    }
    if(results.value == 0xFF10EF){
     digitalWrite (4,HIGH);
     digitalWrite (7,LOW);
     digitalWrite (6,LOW);
     digitalWrite (5,LOW);
     digitalWrite (3,LOW);
     digitalWrite (2,LOW);
    }
    if(results.value == 0xFF38C7){
     digitalWrite (3,HIGH);
     digitalWrite (7,LOW);
     digitalWrite (6,LOW);
     digitalWrite (5,LOW);
     digitalWrite (4,LOW);
     digitalWrite (2,LOW);
    }
    if(results.value == 0xFF5AA5){
     digitalWrite (2,HIGH);
     digitalWrite (7,LOW);
     digitalWrite (6,LOW);
     digitalWrite (5,LOW);
     digitalWrite (4,LOW);
     digitalWrite (3,LOW);
    }
    if(results.value == 0xFFA857){
    
  // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 98; thisNote++) {

    // to calculate the note duration, take one second
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.

    int noteDuration = 1000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);


    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);

    // stop the tone playing:
    noTone(8);
  }
    }
  }
}

回复 支持 反对

使用道具 举报

签到天数: 510 天

[LV.9]以坛为家II

发表于 2016-1-7 13:35:45 | 显示全部楼层
liona 发表于 2016-1-7 00:11
原程序:[mw_shl_code=applescript,true]#include
#include "pitches.h"
int RECV_PIN = 10;

库文件冲突了,
看下下面帖子:
http://www.yfrobot.com/thread-2244-1-1.html
#7楼 #8楼 -- 解决方法。
回复 支持 反对

使用道具 举报

签到天数: 510 天

[LV.9]以坛为家II

发表于 2016-1-15 08:52:13 | 显示全部楼层
本帖最后由 AllBlue 于 2016-1-15 08:54 编辑

没仔细看错误提示,依据错误提示是IRremote 和 Tone 之间冲突了,查了一下,是定时器冲突!但不太清楚怎么解决!因为两个都不好改,也都不能改!
于是百度了一下,有人遇到这个问题了 --- 下面是大神给的解释及解决方法:

原帖地址:http://tieba.baidu.com/p/2229803289

这个错误提示表面上是说在红外库里定义过的函数在Tone里又重复定义了,实际原因是红外库和Tone都使用了相同的内部计时器TIMER2(在各自的ISR函数里),换名字是不解决根本问题的。如果你不熟悉avr的中断处理函数ISR,修改哪一方都不靠谱,考虑下面的Tone的替代办法:

我们知道arduino的几个延时函数都是用的timer 0。这里有个不用timer2而用延时函数的发声函数,用它替代Tone应该可以避开与红外库的计时器冲突:

[C] 纯文本查看 复制代码
void newtone(byte tonePin, int frequency, int duration) {
    int period = 1000000L / frequency;
    int pulse = period / 2;
    for (long i = 0; i < duration * 1000L; i += period) {
        digitalWrite(tonePin, HIGH);
        delayMicroseconds(pulse);
        digitalWrite(tonePin, LOW);
        delayMicroseconds(pulse);
    }
}

回复 支持 反对

使用道具 举报

签到天数: 1 天

[LV.1]初来乍到

发表于 2016-1-23 20:02:30 来自手机 | 显示全部楼层
将文件库里的相关文件全部删掉,再从新加进去就可以了,尽量避免冲突
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|联系我们|YFRobot ( 苏ICP备13017135  

GMT+8, 2017-11-22 11:42 , Processed in 0.398086 second(s), 23 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表