Using the Bridge to copy a file to an SD-card: Multiple definition of class File

Hi, I have an Yun-like setup with a teensy 3.1 and a RPi3 and wish to copy a file from the RPi to an SD card that is attached to the teensy using the bridge (FileIO.h).

The file comes easily over the bridge (as I can see using the serial monitor).

But: The problem is, that both the bridge and SdFat define a class File at some point and therefore, I can’t open a file on the SD card and write the received data in it.

This is the bridge I’m using: (Paul Stoffregens version https://github.com/PaulStoffregen/Bridge)
This is the SdFat library I’m using: (Bill Greimans version: GitHub - greiman/SdFat: Arduino FAT16/FAT32 exFAT Library)

How can I solve this? Can I use namespaces (I’ve only heard of that concept but not used it). Do I have to rewrite either the bridge or sdfat?

Thank you very much for pointing solutions out to me.

This is the code I think should work:

#include <Bridge.h>
#include <FileIO.h>

#include <SPI.h>
#include <SdFat.h>
const int chipSelect = 10;
SdFat sd;
SdFile myFile;


void setup() {
  // Bridge takes about two seconds to start up
  // it can be helpful to use the on-board LED
  // as an indicator for when it has initialized
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  Serial.begin(57600);
  while(!Serial){}
  Serial.println("Hi");

  digitalWrite(13, LOW);
  
  Bridge.begin(Serial1, 19200);
  digitalWrite(13, HIGH);

  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
    sd.initErrorHalt();
  }

  if (sd.exists("test.txt")){ 
    if (!sd.remove("test.txt")) {
      Serial.println("remove failed");
    }
  }
  // open the file for write at end like the Native SD library
  if (!myFile.open("test.txt", O_RDWR | O_CREAT)) {
    sd.errorHalt("opening test.txt for write failed");
  }
  // if the file opened okay, write to it:
  Serial.print("Writing to test.txt...");

  File remoteFile = FileSystem.open("/home/toddd/tmp/test.txt");
    if (remoteFile == NULL) {
      Serial.println("File not found on RPi");
      return;
    }
    else {
      Serial.println("File found on RPi");
    }
    // Jetzt lesen wir die Daten via Bridge und schreiben Sie ins File.
    // Now read from the bridge and write to sdFile.
    int i = 0;
    unsigned char inByte;
    while (remoteFile.available()){
      inByte = remoteFile.read();
      myFile.write(inByte);
      Serial.print(inByte);if (i++ == 16){i = 0;Serial.println();}
    }
    myFile.close();
    Serial.println("and closed");
  


}

void loop() {
  

}

This is the compiler-output:

Arduino: 1.8.1 (Mac OS X), TD: 1.35, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Fast, US English"
[... deleted some output to remain below 9000 chars message-size]
Compiling sketch...
"/Applications/Arduino_1.8.1.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O1 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=134 -DARDUINO=10801 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino_1.8.1.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/toddd/Documents/Arduino/libraries/Bridge/src" "-I/Applications/Arduino_1.8.1.app/Contents/Java/hardware/teensy/avr/libraries/SPI" "-I/Users/toddd/Documents/Arduino/libraries/SdFat" "/var/folders/g9/6r6j2ghh8xj4b_001s726yj80000gq/T/arduino_build_890213/sketch/nuage_file_bridge_to_sd_test.ino.cpp" -o "/var/folders/g9/6r6j2ghh8xj4b_001s726yj80000gq/T/arduino_build_890213/sketch/nuage_file_bridge_to_sd_test.ino.cpp.o"
In file included from /Users/toddd/Documents/Arduino/libraries/SdFat/utility/FatLib.h:22:0,
                 from /Users/toddd/Documents/Arduino/libraries/SdFat/SdFat.h:27,
                 from /Users/toddd/Documents/Arduino/bilderrahmen/nuage_file_bridge_to_sd_test/nuage_file_bridge_to_sd_test.ino:22:
/Users/toddd/Documents/Arduino/libraries/SdFat/utility/ArduinoFiles.h:32:0: warning: "FILE_READ" redefined [enabled by default]
 #define FILE_READ O_READ
 ^
In file included from /Users/toddd/Documents/Arduino/bilderrahmen/nuage_file_bridge_to_sd_test/nuage_file_bridge_to_sd_test.ino:19:0:
/Users/toddd/Documents/Arduino/libraries/Bridge/src/FileIO.h:24:0: note: this is the location of the previous definition
 #define FILE_READ 0
 ^
In file included from /Users/toddd/Documents/Arduino/libraries/SdFat/utility/FatLib.h:22:0,
                 from /Users/toddd/Documents/Arduino/libraries/SdFat/SdFat.h:27,
                 from /Users/toddd/Documents/Arduino/bilderrahmen/nuage_file_bridge_to_sd_test/nuage_file_bridge_to_sd_test.ino:22:
/Users/toddd/Documents/Arduino/libraries/SdFat/utility/ArduinoFiles.h:34:0: warning: "FILE_WRITE" redefined [enabled by default]
 #define FILE_WRITE (O_RDWR | O_CREAT | O_AT_END)
 ^
In file included from /Users/toddd/Documents/Arduino/bilderrahmen/nuage_file_bridge_to_sd_test/nuage_file_bridge_to_sd_test.ino:19:0:
/Users/toddd/Documents/Arduino/libraries/Bridge/src/FileIO.h:25:0: note: this is the location of the previous definition
 #define FILE_WRITE 1
 ^
In file included from /Users/toddd/Documents/Arduino/libraries/SdFat/utility/FatLib.h:22:0,
                 from /Users/toddd/Documents/Arduino/libraries/SdFat/SdFat.h:27,
                 from /Users/toddd/Documents/Arduino/bilderrahmen/nuage_file_bridge_to_sd_test/nuage_file_bridge_to_sd_test.ino:22:
/Users/toddd/Documents/Arduino/libraries/SdFat/utility/ArduinoFiles.h:118:7: error: redefinition of 'class File'
 class File : public FatFile, public Stream {
       ^
In file included from /Users/toddd/Documents/Arduino/bilderrahmen/nuage_file_bridge_to_sd_test/nuage_file_bridge_to_sd_test.ino:19:0:
/Users/toddd/Documents/Arduino/libraries/Bridge/src/FileIO.h:28:7: error: previous definition of 'class File'
 class File : public Stream {
       ^
In file included from /Users/toddd/Documents/Arduino/libraries/SdFat/utility/FatLib.h:24:0,
                 from /Users/toddd/Documents/Arduino/libraries/SdFat/SdFat.h:27,
                 from /Users/toddd/Documents/Arduino/bilderrahmen/nuage_file_bridge_to_sd_test/nuage_file_bridge_to_sd_test.ino:22:
/Users/toddd/Documents/Arduino/libraries/SdFat/utility/FatFileSystem.h: In member function 'File FatFileSystem::open(const char*, uint8_t)':
/Users/toddd/Documents/Arduino/libraries/SdFat/utility/FatFileSystem.h:84:13: error: 'class File' has no member named 'open'
     tmpFile.open(vwd(), path, mode);
             ^
nuage_file_bridge_to_sd_test: In function 'void setup()':
nuage_file_bridge_to_sd_test:60: warning: converting to non-pointer type 'int' from NULL 
     if (remoteFile == NULL) {
                       ^
Multiple libraries were found for "Bridge.h"
 Used: /Users/toddd/Documents/Arduino/libraries/Bridge
 Not used: /Users/toddd/Documents/Arduino/libraries/Bridge_1.6.3
 Not used: /Users/toddd/Documents/Arduino/libraries/Bridge.1.0.5
 Not used: /Users/toddd/Documents/Arduino/libraries/Bridge-1.6.3-paul
 Not used: /Applications/Arduino_1.8.1.app/Contents/Java/libraries/Bridge
Using library Bridge at version 1.0.5 in folder: /Users/toddd/Documents/Arduino/libraries/Bridge 
Using library SPI at version 1.0 in folder: /Applications/Arduino_1.8.1.app/Contents/Java/hardware/teensy/avr/libraries/SPI 
Using library SdFat in folder: /Users/toddd/Documents/Arduino/libraries/SdFat (legacy)
Error compiling for board Teensy 3.2 / 3.1.