“为开发板 Arduino Nano 编译时出错”是什么问题啊?-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3314|回复: 12

[未解决] “为开发板 Arduino Nano 编译时出错”是什么问题啊?

[复制链接]
发表于 2021-7-9 16:15 | 显示全部楼层 |阅读模式
Arduino:1.8.13 (Windows 10), 开发板:"Arduino Nano, ATmega328P (Old Bootloader)"

libraries\OTTO.V9\Oscillator.cpp.o (symbol from plugin): In function `Oscillator::next_sample()':

(.text+0x0): multiple definition of `Oscillator::next_sample()'

libraries\OttoArduinoLib\Oscillator.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\Oscillator.cpp.o (symbol from plugin): In function `Oscillator::next_sample()':

(.text+0x0): multiple definition of `Oscillator::attach(int, bool)'

libraries\OttoArduinoLib\Oscillator.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\Oscillator.cpp.o (symbol from plugin): In function `Oscillator::next_sample()':

(.text+0x0): multiple definition of `Oscillator::detach()'

libraries\OttoArduinoLib\Oscillator.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\Oscillator.cpp.o (symbol from plugin): In function `Oscillator::next_sample()':

(.text+0x0): multiple definition of `Oscillator::SetT(unsigned int)'

libraries\OttoArduinoLib\Oscillator.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\Oscillator.cpp.o (symbol from plugin): In function `Oscillator::next_sample()':

(.text+0x0): multiple definition of `Oscillator::refresh()'

libraries\OttoArduinoLib\Oscillator.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\US.cpp.o (symbol from plugin): In function `US::US()':

(.text+0x0): multiple definition of `US::US()'

libraries\OttoArduinoLib\US.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\US.cpp.o (symbol from plugin): In function `US::US()':

(.text+0x0): multiple definition of `US::US()'

libraries\OttoArduinoLib\US.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\US.cpp.o (symbol from plugin): In function `US::US()':

(.text+0x0): multiple definition of `US::init(int, int)'

libraries\OttoArduinoLib\US.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\US.cpp.o (symbol from plugin): In function `US::US()':

(.text+0x0): multiple definition of `US::US(int, int)'

libraries\OttoArduinoLib\US.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\US.cpp.o (symbol from plugin): In function `US::US()':

(.text+0x0): multiple definition of `US::US(int, int)'

libraries\OttoArduinoLib\US.cpp.o (symbol from plugin).text+0x0): first defined here

libraries\OTTO.V9\US.cpp.o (symbol from plugin): In function `US::US()':

(.text+0x0): multiple definition of `US::TP_init()'

libraries\OttoArduinoLib\US.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\OTTO.V9\US.cpp.o (symbol from plugin): In function `US::US()':

(.text+0x0): multiple definition of `US::read()'

libraries\OttoArduinoLib\US.cpp.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src/Oscillator.h:19:7: warning: type 'struct Oscillator' violates the C++ One Definition Rule [-Wodr]

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.h:18:7: note: a different type is defined in another translation unit

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src/Oscillator.h:46:13: note: the first difference of corresponding definitions is field '_A'

     int16_t _A;  //-- Amplitude (degrees)

             ^

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.h:45:18: note: a field of same name but different type is defined in another translation unit

     unsigned int _A;  //-- Amplitude (degrees)

                  ^

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stdint.h:127:20: note: type 'int16_t' should match type 'unsigned int'

typedef signed int int16_t __attribute__ ((__mode__ (__HI__)));

                    ^

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.cpp:106:6: warning: 'refresh' violates the C++ One Definition Rule  [-Wodr]

void Oscillator::refresh()

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:106:6: note: implicit this pointer type mismatch

void Oscillator::refresh()

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src/Oscillator.h:19:7: note: type 'struct Oscillator' itself violates the C++ One Definition Rule

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.h:18:7: note: the incompatible type is defined here

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:106:6: note: 'refresh' was previously declared here

void Oscillator::refresh()

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:106:6: note: code may be misoptimized unless -fno-strict-aliasing is used

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.cpp:81:6: warning: 'SetT' violates the C++ One Definition Rule  [-Wodr]

void Oscillator::SetT(unsigned int T)

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:81:6: note: implicit this pointer type mismatch

void Oscillator::SetT(uint16_t T)

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src/Oscillator.h:19:7: note: type 'struct Oscillator' itself violates the C++ One Definition Rule

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.h:18:7: note: the incompatible type is defined here

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:81:6: note: 'SetT' was previously declared here

void Oscillator::SetT(uint16_t T)

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:81:6: note: code may be misoptimized unless -fno-strict-aliasing is used

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.cpp:70:6: warning: 'detach' violates the C++ One Definition Rule  [-Wodr]

void Oscillator::detach()

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:70:6: note: implicit this pointer type mismatch

void Oscillator::detach()

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src/Oscillator.h:19:7: note: type 'struct Oscillator' itself violates the C++ One Definition Rule

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.h:18:7: note: the incompatible type is defined here

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:70:6: note: 'detach' was previously declared here

void Oscillator::detach()

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:70:6: note: code may be misoptimized unless -fno-strict-aliasing is used

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.cpp:39:6: warning: 'attach' violates the C++ One Definition Rule  [-Wodr]

void Oscillator::attach(int pin, bool rev)

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:39:6: note: implicit this pointer type mismatch

void Oscillator::attach(int pin, bool rev)

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src/Oscillator.h:19:7: note: type 'struct Oscillator' itself violates the C++ One Definition Rule

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.h:18:7: note: the incompatible type is defined here

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:39:6: note: 'attach' was previously declared here

void Oscillator::attach(int pin, bool rev)

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:39:6: note: code may be misoptimized unless -fno-strict-aliasing is used

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.cpp:20:6: warning: 'next_sample' violates the C++ One Definition Rule  [-Wodr]

bool Oscillator::next_sample()

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:20:6: note: implicit this pointer type mismatch

bool Oscillator::next_sample()

      ^

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src/Oscillator.h:19:7: note: type 'struct Oscillator' itself violates the C++ One Definition Rule

class Oscillator

       ^

C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9\Oscillator.h:18:7: note: the incompatible type is defined here

class Oscillator

       ^

"Servo.h" 对应多个库

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:20:6: note: 'next_sample' was previously declared here

bool Oscillator::next_sample()

      ^

已使用: C:\Users\yyp\Documents\Arduino\libraries\Servo

未使用:C:\Program Files (x86)\Arduino\libraries\Servo

"Oscillator.h" 对应多个库

C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib\src\Oscillator.cpp:20:6: note: code may be misoptimized unless -fno-strict-aliasing is used

已使用: C:\Users\yyp\Documents\Arduino\libraries\OttoArduinoLib

C:\Users\yyp\AppData\Local\Temp\cci4Es7e.ltrans0.ltrans.o: In function `setup':

未使用:C:\Users\yyp\Documents\Arduino\libraries\OTTO.V9

D:\DIY\otto-diy\otto-diy-plus\Codes\OttoPLUS_touchultrasound_V9/OttoPLUS_touchultrasound_V9.ino:53: undefined reference to `Otto9Humanoid::init(int, int, int, int, bool, int, int, int, int)'

collect2.exe: error: ld returned 1 exit status

exit status 1

为开发板 Arduino Nano 编译时出错。



在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。


发表于 2021-7-9 17:22 | 显示全部楼层
nano.png
Arduino Nano的固件有新旧之分需要选择的。
 楼主| 发表于 2021-7-9 20:41 | 显示全部楼层
topdog 发表于 2021-7-9 17:22
Arduino Nano的固件有新旧之分需要选择的。

选了,但是还是不行
发表于 2021-7-9 20:48 | 显示全部楼层
看上去是重复调库导致的重复定义,具体问题还得看库代码和你写的代码
发表于 2021-7-9 22:39 | 显示全部楼层
D:\DIY\otto-diy\otto-diy-plus\Codes\代码与C:\Users\yyp\Documents\Arduino\libraries\和C:\Program Files (x86)\Arduino\libraries\库冲突
 楼主| 发表于 2021-7-9 22:57 | 显示全部楼层
OttoPLUS_touchultrasound_V9:5:10: error: Oscillator.h: No such file or directory

#include <Oscillator.h>

          ^~~~~~~~~~~~~~

compilation terminated.

exit status 1
Oscillator.h: No such file or directory


现在库又加不上去了
 楼主| 发表于 2021-7-9 23:00 | 显示全部楼层
topdog 发表于 2021-7-9 22:39
D:\DIY\otto-diy\otto-diy-plus\Codes\代码与C:%users\yyp\Documents\Arduino\libraries\和C:\Program File ...

OttoPLUS_touchultrasound_V9:5:10: error: Oscillator.h: No such file or directory

#include <Oscillator.h>

          ^~~~~~~~~~~~~~

compilation terminated.

exit status 1
Oscillator.h: No such file or directory


现在库文件又加不上去了

现在库文件又加不上去了
屏幕截图 2021-07-09 224958.png
发表于 2021-7-10 00:01 | 显示全部楼层
本帖最后由 topdog 于 2021-7-10 00:05 编辑

https://github.com/OttoDIY/OttoDIYLib   下载这个库文件
在C:\Users\用户名\Documents\Arduino\libraries 里面的结构如下:

otto.jpg

我用nano 烧录一下是正常的。
 楼主| 发表于 2021-7-10 01:27 | 显示全部楼层
topdog 发表于 2021-7-10 00:01
https://github.com/OttoDIY/OttoDIYLib   下载这个库文件
在C:%users\用户名\Documents\Arduino\libraries ...

Arduino:1.8.9 (Windows 10), 开发板:"Arduino Nano, ATmega328P (Old Bootloader)"

C:\Users\yyp\AppData\Local\Temp\ccnZ38Td.ltrans0.ltrans.o: In function `setup':

D:\DIY\otto-diy\otto-diy-plus\Codes\OttoPLUS_touchultrasound_V9/OttoPLUS_touchultrasound_V9.ino:53: undefined reference to `Otto9Humanoid::init(int, int, int, int, bool, int, int, int, int)'

collect2.exe: error: ld returned 1 exit status

exit status 1
为开发板 Arduino Nano 编译时出错。

在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。

后来它又出现这样的错误,这得什么解决?谢谢!

点评

查一下Otto9Humanoid类成员函数init()的声明格式,调用XXX.init( , , , , )的时候提供的参数个数、类型、顺序可能错了。出错地点在setup()函数里  发表于 2021-7-10 18:08
发表于 2021-7-10 19:42 | 显示全部楼层
18377855645 发表于 2021-7-10 01:27
Arduino:1.8.9 (Windows 10), 开发板:"Arduino Nano, ATmega328P (Old Bootloader)"

C:%users\yyp\AppD ...

电脑删除干净,再安装呀。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-29 03:56 , Processed in 0.114576 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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