Collect2.exe: error: ld returned 1 exit status *** [.pio\build\ATmega64\firmware.elf] Error 1

hello
I am working on glcd ks0108 by using platformio
how can i fixed this error:
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\ATmega64\firmware.elf] Error 1

The error message says that in main() you have called GLCD_Setup(). It appears that the latter function is not known to main(). You are missing a library perhaps? Or a source file? Or perhaps it’s a spelling mistake in the name?

Have a look at the files in your project and see if you have this function, and if so, is the file part of src or include for the project source files, or, in the appropriate lib directory if it’s a library.

HTH

Cheers,
Norm.

Big red flag number 1: You are in main.cpp and the function you’re looking at is likely implemented in a .c files. Hence you need to take care of name-mangling, that is, add extern "C" declaration in the headers so that C++ code sees the C implementation with it’s C symbol names. See here. An alternative to C+±hardening each header file that exposes C functions is to just

extern "C" {
  #include <ks0108\KS0108.h>
  #include <ks0108\Font5x8.h>
}

in the main.cpp file instead.

Big red flag number 2: If you have the standard platformio.ini with the framework = arduino line, the Arduino framework is compiled in and will want to define the main() function, users are supposed to implement setup() and loop(). You would however (re)-implement main() in this case and have unnecessary overhead from the Arduino framework. If you are not using the Arduino framework, make sure framework = arduino is removed from the platformio.ini. And when you’re not using the C++ framework Arduino, and all of your other code is in .c, it’s probably most comfortable for you to rename main.cpp in main.c, through which the above changes are not necessary.