DSI2598+編譯出現錯誤

rtaurlin發佈於2021-05-11 18:18:54

瀏覽6682

回覆2

最後編輯於2024-10-30 22:34:32

請教DSI2598+編譯出現如下錯誤,如何解決?

ARDUINO 重裝也沒有用

==============================================

Arduino:1.8.13 (Windows 10), 開發板:"Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), STM32duino bootloader, 72Mhz (Normal), Smallest (default)"


libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::skip()':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:138: multiple definition of `OneWire::reset()'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:165: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::search(unsigned char*)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:176: multiple definition of `OneWire::write_bit(unsigned char)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:203: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::read_bit()':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:200: multiple definition of `OneWire::read_bit()'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:227: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::write(unsigned char, unsigned char)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:224: multiple definition of `OneWire::write(unsigned char, unsigned char)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:251: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::write_bytes(unsigned char const*, unsigned short, bool)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:238: multiple definition of `OneWire::write_bytes(unsigned char const*, unsigned short, bool)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:265: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::read()':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:252: multiple definition of `OneWire::read()'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:279: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::read_bytes(unsigned char*, unsigned short)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:262: multiple definition of `OneWire::read_bytes(unsigned char*, unsigned short)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:289: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::select(unsigned char const*)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:271: multiple definition of `OneWire::select(unsigned char const*)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:298: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::skip()':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:284: multiple definition of `OneWire::skip()'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:311: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::depower()':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:288: multiple definition of `OneWire::depower()'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:315: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::reset_search()':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:303: multiple definition of `OneWire::reset_search()'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:330: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::target_search(unsigned char)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:318: multiple definition of `OneWire::target_search(unsigned char)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:345: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::crc8(unsigned char const*, unsigned char)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:497: multiple definition of `OneWire::crc8(unsigned char const*, unsigned char)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:509: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::crc16(unsigned char const*, unsigned short, unsigned short)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:535: multiple definition of `OneWire::crc16(unsigned char const*, unsigned short, unsigned short)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:551: first defined here

libraries\OneWireSTM\OneWireSTM.cpp.o: In function `OneWire::check_crc16(unsigned char const*, unsigned short, unsigned char const*, unsigned short)':

C:\Users\mcas\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\OneWireSTM\src/OneWireSTM.cpp:529: multiple definition of `OneWire::check_crc16(unsigned char const*, unsigned short, unsigned char const*, unsigned short)'

libraries\OneWire\OneWire.cpp.o:C:\Users\mcas\Documents\Arduino\libraries\OneWire/OneWire.cpp:545: first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1

開發板 Generic STM32F103C series 編譯錯誤。

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 

共2條回覆 最後由rtaurlin回覆於2021-05-12 08:26:20
#1
abc 回覆於 2021-05-15 11:09:28

#include <OneWire.h> 這是 Arduino 標準 Lib ,若是使用 STM32 方式請改為 STM32 內建的 Lib

也就是改為 :

#include <OneWireSTM.h> 即可完成編譯動作 !!  

 

by 曹大工作室

 

#2
rtaurlin 回覆於 2021-05-12 08:26:20

程式碼

/********************************************************************/
// First we include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>
/********************************************************************/
// Data wire is plugged into pin 2 on the Arduino 
//#define ONE_WIRE_BUS 2 
#define ONE_WIRE_BUS PB11
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices  
// (not just Maxim/Dallas temperature ICs) 
OneWire oneWire(ONE_WIRE_BUS); 
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);
/********************************************************************/ 
void setup(void) 

 // start serial port 
 Serial.begin(9600); 
 Serial.println("Dallas Temperature IC Control Library Demo"); 
 // Start up the library 
 sensors.begin(); 

void loop(void) 

 // call sensors.requestTemperatures() to issue a global temperature 
 // request to all devices on the bus 
/********************************************************************/
 //Serial.print(" Requesting temperatures..."); 
 sensors.requestTemperatures(); // Send the command to get temperature readings 
 //Serial.println("DONE"); 
/********************************************************************/
 //Serial.print("Temperature is: "); 
 Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"?  
   // You can have more than one DS18B20 on the same bus.  
   // 0 refers to the first IC on the wire 
   delay(1000); 
}