user49809: I have some code that works fine on Windows but is giving me errors on Ubuntu. I noticed that while Windows is running the code using avr-gcc, Ubuntu is trying to make it run using avr-g++. Any functions not defined within void setup() comes up as "was not declared in this scope". Is there a way to force it to use avr-gcc ?

user48274: In my case, i would tell you compile/upload your sketch Arduino on Ubuntu 17.10 like my owned.  
I have

Wemos D1 MINI Board based ESP8266 chip.
Define ttyUSB0 port like my Owned.

Before upload your sketch, you need Arduino Package for Ubuntu in Arduino Official Pages or if you have Arduino Package on your Aptitude Source list / PPA Repository of Arduino with following sudo apt-get install -y arduino. that's same to me.
After your Arduino Package installed, try to following commnand :
cd /path/installation/package/ //for change directory to Arduino Package

ARDUINO-DIR(pwd) //for make environment of Arduino directory

cd $HOME/Arduino/sketch/ //for change directory to your Arduino sketch

ls -l //for list all items in your folder

$ARDUINO-DIR/arduino --verify sketch.ino --board (board) --port (port) --verbose //for compile your sketch

$ARDUINO-DIR/arduino --upload sketch.ino --board (board) --port (port) --verbose //for upload your sketch

NOTE: 
e.g --board esp8266:esp8266:d1_mini //for WemosD1Mini board or
e.g --board arduino:avr:uno //for ArduinoUNO board.
e.g --port /dev/ttyUSB0 or /dev/ttyACM0 //if your define ttyUSB0 or ttyACM0 port you have.  
See Below to my verbose log appears a avr-gcc and a avr-g++ automatically called in arduino-builder binary to compile all my library defined.

Hope you can get it.  

49809: <p>I have some code that works fine on Windows but is giving me errors on Ubuntu. I noticed that while Windows is running the code using avr-gcc, Ubuntu is trying to make it run using avr-g++. Any functions not defined within void setup() comes up as "was not declared in this scope". Is there a way to force it to use avr-gcc ?</p>
 48274: <p>In my case, i would tell you compile/upload your sketch Arduino on Ubuntu 17.10 like my owned.  </p>

<p>I have</p>

<ul>
<li>Wemos D1 MINI Board based ESP8266 chip.</li>
<li>Define ttyUSB0 port like my Owned.</li>
</ul>

<p>Before upload your sketch, you need Arduino Package for Ubuntu in <a href="https://playground.arduino.cc/linux/ubuntu" rel="nofollow noreferrer">Arduino Official Pages</a> or if you have Arduino Package on your Aptitude Source list / PPA Repository of Arduino with following <code>sudo apt-get install -y arduino</code>. that's same to me.</p>

<p>After your Arduino Package installed, try to following commnand :</p>

<pre><code>cd /path/installation/package/ //for change directory to Arduino Package

ARDUINO-DIR(pwd) //for make environment of Arduino directory

cd $HOME/Arduino/sketch/ //for change directory to your Arduino sketch

ls -l //for list all items in your folder

$ARDUINO-DIR/arduino --verify sketch.ino --board (board) --port (port) --verbose //for compile your sketch

$ARDUINO-DIR/arduino --upload sketch.ino --board (board) --port (port) --verbose //for upload your sketch
</code></pre>

<p><strong>NOTE:</strong> </p>

<p>e.g --board esp8266:esp8266:d1_mini //for WemosD1Mini board or<br>
e.g --board arduino:avr:uno //for ArduinoUNO board.<br>
e.g --port /dev/ttyUSB0 or /dev/ttyACM0 //if your define ttyUSB0 or ttyACM0 port you have.  </p>

<p><strong>See Below</strong> to my verbose log appears a avr-gcc and a avr-g++ automatically called in arduino-builder binary to compile all my library defined.</p>

<p><a href="https://i.stack.imgur.com/nhBPA.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nhBPA.gif" alt="enter image description here"></a></p>

<p>Hope you can get it.  </p>
