Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone. My question is same title. Yes problem when compile. Please help me.
This is a code of my program (in CPP):
C++
// Written by UKI COMPUTERS (ukicomputers.github.io - github.com/ukicomputers)
// Based on (C) UKI COMPUTERS Self-Protecting Author License 1.0 (https://github.com/ukicomputers/UKI-COMPUTERS-Self-Protecting-Authors-License)

#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "lcd_i2c_quotes/lcd_i2c.h"
#include "hardware/timer.h"
#include "keypad/pico_keypad4x4.h"
#include <cstddef>
using namespace std;

LCDI2C lcd(0x27 , 2, 16, 16, 17, 0);

#define sifra 7 

int pos = 0;    

char Data[sifra]; 
char Master[sifra] = "123456"; // ovo je sifra - u navodnicima. podrazumevana sifra je 123456. i mora imati 6 cifre.

int data_count = 0, master_count = 0;

bool Pass_is_good;
char customKey;

uint columns[4] = { 18, 19, 20, 21 };
uint rows[4] = { 10, 11, 12, 13 };
char matrix[16] = {
    '1', '2' , '3', 'A',
    '4', '5' , '6', 'B',
    '7', '8' , '9', 'C',
    '*', '0' , '#', 'D'
};
bool vrata = true;

#define bravica 16

int bravica_value = 0;

int main()
{
  
  stdio_init_all();
  gpio_init(bravica);
  gpio_set_dir(bravica, GPIO_OUT);

  bravica_value = 0 - bravica_value;
  gpio_put(bravica, bravica_value);
 
  lcd.init();
  lcd.lcd_clear();
  lcd.lcd_string("UKI COMPUTERS");
  lcd.lcd_set_cursor(0, 1);
  lcd.lcd_string("--Wait--");
  sleep_ms(3000);
  lcd.lcd_clear();
  return 0;

}

void Open()
{
  lcd.lcd_set_cursor(0, 0);
  lcd.lcd_string(" Enter Password");
  
  customKey = pico_keypad_get_key();
  if (customKey)
  {
    Data[data_count] = customKey;
    lcd.lcd_set_cursor(data_count, 1);
    lcd.lcd_string(Data);
    data_count++;
  }
}

void clearData()
{
  while (data_count != 0)
  { 
    Data[data_count--] = 0; 
  }
  return;
}

int loop()
{
  if (vrata== 0)
  {
    pico_keypad_init(columns, rows, matrix);
    char customKey;

    customKey = pico_keypad_get_key();

    if (customKey == '#')

    {
      lcd.lcd_clear();
      bravica_value = 1 - bravica_value;
      gpio_put(bravica, bravica_value);
      lcd.lcd_string("  Door is close");
      sleep_ms(3000);
      vrata= 1;
    }

    while(1){
      tight_loop_contents();
    }
  }
  else Open();

  if (data_count == sifra - 1)
  {
    if (!strcmp(Data, Master))
    {
      lcd.lcd_clear();
      bravica_value = 0 - bravica_value;
      gpio_put(bravica, bravica_value);
      lcd.lcd_string("  Door is Open");
      vrata= 0;
    }
    else
    {
      lcd.lcd_clear();
      lcd.lcd_string("  Wrong Password");
      sleep_ms(1000);
      vrata= 1;
    }
    clearData();
  }
}


I'am used a library from GitHub. This is link:
https://github.com/OSWA00/pico-keypad4x4

And i'am for lcd libary used from pico-examples i2c/lcd_i2c_quotes.

When i'am compile a code this error shows to me (after all):
c:/progra~2/gnuarm~1/102021~1.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/keypad.dir/C_/Compilers/pico/pico-sdk-master/src/rp2_common/pico_standard_link/crt0.S.obj: in function `__get_current_exception':
(.reset+0x9c): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [blink\keypad\CMakeFiles\keypad.dir\build.make:823: blink/keypad/keypad.elf] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1466: blink/keypad/CMakeFiles/keypad.dir/all] Error 2
mingw32-make: *** [Makefile:90: all] Error 2


How to reslove this error? Please help me.

What I have tried:

I'am tried all things. I'am same don't know what to do. Again please help me and thanks advance.
Posted
Updated 28-Oct-21 3:29am
Comments
[no name] 18-Oct-21 5:42am    
Let me just say, don't be fooled, some notes are written in Serbian language.
Greg Utas 18-Oct-21 8:16am    
They are? Serbian uses the Cyrillic alphabet. :)
[no name] 19-Oct-21 3:24am    
Да. Али ја сам написан на латинском српском :) :). Otherwise, serbian don't have a alphabet (that speak in english) but have azbuka.

Read the error message:
Quote:
master/src/rp2_common/pico_standard_link/crt0.S.obj: in function `__get_current_exception':
(.reset+0x9c): undefined reference to `main'

You application does not contain an entry point, and cannot be built into an executable file as a result.
 
Share this answer
 
Comments
[no name] 18-Oct-21 6:19am    
Ok. But how to do this? Otherwise, i'am in code set-up to start as:
int main()
{
...
}
OriginalGriff 18-Oct-21 6:25am    
Check your makefile and ensure that your file is linked in.
[no name] 19-Oct-21 3:27am    
Ok. But if'am good see :), problem is not in my code, problem in library. I'am tryed to add into library int main(){...} but this is not a helpful.
In this line:
C++
#include "keypad/pico_keypad4x4.h"


Replace with this:
C++
#include "keypad/pico_keypad4x4.c"


Beacuse, this library HAS NOT GOT a main function (.h file C++ in this thing calculate as program).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900