Author Topic: I get a linker error when building a program for an avr project  (Read 4933 times)

Offline arechavel

  • Single posting newcomer
  • *
  • Posts: 6
I get a linker error when building a program for an avr project
« on: February 24, 2012, 11:51:34 pm »
I created an avr project on a linux box using the gcc-avr complier

My linker settings are:
-mmcu=atmega1284p
-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref

I built the following c program:

#include <ctype.h>

int main(void)
{
    int a = 1;

    if(isdigit( a ))
    {
        a = 2;
    }

    return 0;
}


I got the error:

/home/arechavel/workspace/test2_project/main.c:10: undefined reference to `__ctype_b_loc'


Could you help me with this issue ???

thank you

ar

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7789
    • My Best Post
Re: I get a linker error when building a program for an avr project
« Reply #1 on: February 25, 2012, 12:15:51 am »
Step 1. Turn on Full Compiler Logging
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
Step 2. Post the build log on a different website that supports your Compiler.
           Ask what you are missing.
Step 3. Ask on this web-site how to add the missing items.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: I get a linker error when building a program for an avr project
« Reply #2 on: February 26, 2012, 08:02:41 am »
I tried Google a bit and I have found that you seem to have been "lucky" and that you have hit a problematic part of certain libc's. Problems with __ctype_b_loc() are reported repeatedly whenever ctype() tries to query locale settings. All reports seem to be rather old (2003 .. 2006) so that the problem should be gone now. It is possible that the AVR environment reproduces the bug. I have no experience with AVR programming. At any rate, it's not your bug, your code is okay.

Try to bypass ctype.h, use your own code. Also, there should be ctype.c somewhere around. Using this code instead of the code in libc was reported to solve the problem.

Offline arechavel

  • Single posting newcomer
  • *
  • Posts: 6
Re: I get a linker error when building a program for an avr project
« Reply #3 on: February 27, 2012, 11:40:00 pm »
My problem was in the setting tab -> complier and debugger -> selected complier should be GNU AVR GCC Compiler
it was GNUGCC Compiler

ar