collect2.exe: error: ld returned 1 exit status exit status 1

According Whopr/driver - GCC Wiki (whopr/driver - GCC Wiki) Id.exe should give complete transparency.

But in my case this is not true.
What is my case?

I am more a mechanic than a software engineer. So programming is not my favorite occupation.
I got attached file to automate an indexer for my mill.
I was able to compile and upload my application to Arduino Uno. Arduino version was by then 1.8.2.
In the mean time I have updated to version 1.8.9. Now my application fails to compile. Nothing has been changed to those files. I get a lot of errors like i.e.

undefined reference to `Wlcd::clear()

but Wlcd::clear() is present in Wlcd.cpp.

So other error statements are obvious incorrect.

Compiling has been cut off by the statement mentioned in the subject.

Now I am a bit lost. Collect2 and ld don’t give an answer.

Is someone be able to help me?

Wagner Mello.zip (9.86 KB)

Change the structure

\---Wagner Mello
    \---Indexer
        |   Indexer.ino
        |
        \---src
            +---Wlcd
            |       Wlcd.cpp
            |       Wlcd.h
            |
            \---Wstepper
                    Wstepper.cpp
                    Wstepper.h

Change your includes
In the ino:

#include "src\Wlcd\Wlcd.h"
#include "src\Wstepper\Wstepper.h"
#include <EEPROM.h>

Note on above that you don’t need to include Arduino.h and don’t need the full path to EEPROM.h.

Further, in the respective cpp files

#include "Wlcd.h"

and

#include "Wstepper.h"

Thanks Sterretje for reply. I have altered the files according your proposal. but helas, I get new errors calling the cpp-files.

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries N:\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10809 -build-path C:\Users\HENKWE~1\AppData\Local\Temp\arduino_build_72801 -warnings=more -build-cache C:\Users\HENKWE~1\AppData\Local\Temp\arduino_cache_875013 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose N:\Arduino\Wagner Mello\Indexer\Indexer.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries N:\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10809 -build-path C:\Users\HENKWE~1\AppData\Local\Temp\arduino_build_72801 -warnings=more -build-cache C:\Users\HENKWE~1\AppData\Local\Temp\arduino_cache_875013 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose N:\Arduino\Wagner Mello\Indexer\Indexer.ino
Using board ‘uno’ from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core ‘arduino’ from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used…
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard” “C:\Users\HENKWE~1\AppData\Local\Temp\arduino_build_72801\sketch\Indexer.ino.cpp” -o nul
Indexer:16:28: error: src\Wlcd\Wlcd.h: No such file or directory
compilation terminated.
exit status 1
src\Wlcd\Wlcd.h: No such file or directory

It is a bit strange that the compiler cannot find Wlcd.h because in prereferences.txt the default sketch location is sketchbook.path=N:\Arduino.
It also doesn’t help if I change the altered statements in indexer.ino to “Wagner Mello\src\Wlcd\Wlcd.h” and "Wagner Mello\src\Wstepper\Wstepper.h

By just change the altered statement in indexer.ino to “N:\Arduino\Wagner Mello\src\Wlcd\Wlcd.h” and “N:\Arduino\Wagner Mello\src\Wstepper\Wstepper.h” the compiling will go on till it stops with following.

C:\Users\HENKWE~1\AppData\Local\Temp\ccls7mpP.ltrans1.ltrans.o: In function _GLOBAL__sub_I_lcd':* *N:\Arduino\Wagner Mello\Indexer/Indexer.ino:20: undefined reference to Wlcd::Wlcd(int)’
N:\Arduino\Wagner Mello\Indexer/Indexer.ino:21: undefined reference to `WStepper::WStepper()’
collect2.exe: error: ld returned 1 exit status
Bibliotheek EEPROM op versie 2.0 in map: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\EEPROM wordt gebruikt
exit status 1
Fout bij het compileren voor board Arduino/Genuino Uno

So some more thinkings are needed to solve this problem.

Wagner Mello.zip (9.65 KB)

preferences.txt (3.72 KB)

HenkWeebers: Indexer:16:28: error: src\Wlcd\Wlcd.h: No such file or directory

This should work if you have the exact folder structure proposed by sterretje.

Which version of the Arduino IDE are you using?

A minor nitpick: you should always use / instead of \ as a path separator. \ works find on Windows and so it's not the cause of your problem, but using \ as a path separator makes it so your code won't compile on Linux or macOS.

HenkWeebers: By just change the altered statement in indexer.ino to "N:\Arduino\Wagner Mello\src\Wlcd\Wlcd.h"

And now we see the problem. You didn't create the correct folder structure. The correct folder structure should have the src folder under the Indexer folder and the file at N:\Arduino\Wagner Mello\Indexer\src\Wlcd\Wlcd.h

HenkWeebers: By just change the altered statement in indexer.ino to "N:\Arduino\Wagner Mello\src\Wlcd\Wlcd.h" and "N:\Arduino\Wagner Mello\src\Wstepper\Wstepper.h" the compiling will go on till it stops with following.

C:\Users\HENKWE~1\AppData\Local\Temp\ccls7mpP.ltrans1.ltrans.o: In function `GLOBAL_sub_I_lcd': N:\Arduino\Wagner Mello\Indexer/Indexer.ino:20: undefined reference to `Wlcd::Wlcd(int)' N:\Arduino\Wagner Mello\Indexer/Indexer.ino:21: undefined reference to `WStepper::WStepper()' [/quote] This is the expected result. Although you can #include a file from any arbitrary location on your computer, the Arduino IDE will not cause the source files in that location to be compiles. So the declarations of those objects contained in the .h file are present but the definitions of them contained in the .cpp files were not compiled. The Arduino IDE has special handling of the src subfolder of the sketch folder in that it does recursive compilation of that folder.