Another try using CodeBlocks and avr-gcc

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After a previous post and attempting again to get CB to work with avr-gcc I made 'some' progress.
CodeBlocks will compile a simple C program for the PC and
it will execute as well (using Build/Run).

However, when I select the AVR-GCC compiler and attempt to
compile a very simple program I get:

Quote:
Compiling: main.c
In file included from /usr/include/inttypes.h:26:0,
from /usr/lib/gcc/avr/4.5.3/../../../avr/include/avr/sfr_defs.h:126,
from /usr/lib/gcc/avr/4.5.3/../../../avr/include/avr/io.h:99,
from main.c:4:
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

//the above is the error I get when attempting to compile a simple AVR program.

I don't think the PATH is set correctly, I am thinking that the predefs.h is not part of the AVR version (?).
So, once again I am in the ether and don't have a clue.
I hope someone can point me in the right direction.
Thanks.

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have to remove /usr/include and /usr/lib from compile/linker search path. See this post.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

snigelen: Thanks , I will give it a try and post what ever the
results. Might not get back to it today...

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

'Tis very odd. I installed the Atmel Toolchain for Linux 4.6.2. I actually cp -a'd it to /usr/local/avr as that's my "preferred place". I simply ensured that /usr/local/avr/bin was added to my default PATH then in Code::Blocks I just used Settings-Compiler&Debugger-GNU AVR GCC Compiler-Toolchain Executables to point to /usr/local/avr/bin

Then for a particular AVR project I just ensure that in Project-Settings-C/C++ Parser I just add a path there to where the stdio.h for AVR-LibC is located (rather curiously this means "../../../usr/local/avr/avr/include" on my machine - that's one directory above the ../../../usr/local/avr/avr/include/avr directory where io.h sits and that is all there was too it. In fact the code built OK without even doing this Parser path thing but the advantage of doing that is that the editor now "knows" where things like live.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tried the changes mentioned by snigelen and there was no change, same identical error.

Clawson: I don't have any idea on the status of the CodeBlock and AVR-GCC software setup
at this point in time. I must be setup in one fashion, if I start a new AVR project, then CodeBlocks
generates the startup file (main.c) which has “#include ” at the head of the file.
BTW I did install the avr-gcc from the Atmel web page.

Question(s): Would I be better to re-install everything and perhaps install 'build-essential first'?

I am sure this can work because so many others seem to have used it on Linux machines. I think
my problems are in the setup and defining the proper path setup which apparently I have
not been able to resolve.

So far, I have not found what I would expect to be the revelent help (.h) and include files.
I am still learning to use Linux (Ubuntu) and I will use the command line utility 'find' and
see if I can determine where if the proper files are located.

The only way to remove installed software is either use the Ubuntu Software center or
Synaptic applications. I think I am correct on that. I will mention again, I have never installed
the build-essential file(s) and I was not clear if that was actually required.

I have started thinking of using the CrossWorks IDE which I think runs on Linux. But, I am very
reluctant to do that as I am now just in the hobby mode. Somehow I have just got to figure this
out and get avr-gcc and CodeBlocks to run on this Linux box.

So thanks for you guys comments and help, I am beginning to question my ability to get this done.
I have used ICCAVR for a number of years without getting to an issue that could not be resolved,
especially with access to freaks.net. :-)

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

build-essential first'?


build-essential is a set of tools for building host programs. Not cross compiling for an alien target (though I guess it may deliver things like "make" if you haven't already got it).
Quote:

The only way to remove installed software is either use the Ubuntu Software center or
Synaptic applications.

Well no. You can "apt-get remove" and you can even use dpkg directly if you like.

Like I say this really should be simple. If for example you just type "avr-gcc -v" at a command prompt what do you see? This will check avr-gcc is installed and that there's a PATH to it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Clawson, thanks for your patient and help. I did verify that
avr-gcc is installed and think that the fact that CodeBlocks shows it in the list of compilers.

I did notice if I remove the #include include in the basic file, main.c created by CodeBlocks, then it appears to compile without errors but I do not see any listing that makes sense. There is a main.o but it doesn't seem to have anything usable.
I wanted to see where the avr*.h files looked like and their location. So, I used the 'find' command to see if I could locate. The actual command was:
$ find / -name 'avr*.h' > Mylist.txt. I understand that the
'/' allows searching directories below the starting directory. The following is the results:

Quote:
/usr/lib/gcc/avr/4.5.3/plugin/include/config/avr/avr-protos.h
/usr/lib/gcc/avr/4.5.3/plugin/include/config/avr/avr.h
/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/avrinterruptnames.h
/home/jerryl/Documents/LINUX/Atmel/avr-libc-1.7.0-delay.h
/home/jerryl/Documents/LINUX/Atmel/TAR_files/avr8-gnu-toolchain-linux_x86_64/lib/gcc/avr/4.6.2/plugin/include/config/avr/avr-protos.h
/home/jerryl/Documents/LINUX/Atmel/TAR_files/avr8-gnu-toolchain-linux_x86_64/lib/gcc/avr/4.6.2/plugin/include/config/avr/avr.h

So, it looks like that the libraries may not be installed (?) and/or there is no proper path for Codeblocks to locate.

I am curious about avr8-gnu ....... , does that look correct to you?

Thanks a million

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What makes you think there are "avr*.h" files? The headers for AVR devices in GCC are called things like iom16.h, iom328pa.h, iotn2313.h and so on.

If you want a fairly unique file to search for then try "-name sfr_defs.h" for example. Or how about "-name crtm16.o" to find the libraries.

If I try something similar to your find in Windows I see:

C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC>dir avr*.h /s
 Volume in drive C has no label.
 Volume Serial Number is E0DD-96FE
File Not Found

While if I search for a file such as sfr_defs.h I see:

C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC>dir sfr_defs.h /s
 Volume in drive C has no label.
 Volume Serial Number is E0DD-96FE

 Directory of C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.1.95\AVRToolchain\avr\include\avr

13/11/2012  13:52             8,892 sfr_defs.h
               1 File(s)          8,892 bytes

and if I search for crtm16.o I see:

C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC>dir crtm16.o /s
 Volume in drive C has no label.
 Volume Serial Number is E0DD-96FE

 Directory of C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.1.95\AVRToolchain\avr\lib\avr5

13/11/2012  13:52             4,260 crtm16.o
               1 File(s)          4,260 bytes

Doing something similar in my Linux host I see:

clawson@ws-czc1138h0b:/$ find /usr/local/ -name avr\*.h
/usr/local/avr/lib/gcc/avr/4.6.2/plugin/include/config/avr/avr.h
/usr/local/avr/lib/gcc/avr/4.6.2/plugin/include/config/avr/avr-protos.h
clawson@ws-czc1138h0b:/$ find /usr/local/ -name sfr_defs.h
/usr/local/avr/avr/include/avr/sfr_defs.h
clawson@ws-czc1138h0b:/$ find /usr/local/ -name crtm16.o
/usr/local/avr/avr/lib/avr5/crtm16.o

(I limited the search to within /usr/local/ as it would have taken days to search my entire file system!).

It does seem that the Linux build of Atmel's toolchain (unlike the Windows build of the same thing) does have some avr*.h files so I might predict that on your machine you will find sfr_defs.h in /usr/avr/include/avr/ and the crtm16.o file in /usr/avr/lib/avr5/

In C::B you therefore want to set the GNU AVR GCC Compiler path for Toolchain Executables to /usr/avr/bin/ and for each project set the C/C++ Parser path to /usr/avr/include/

If you then right click it should be able to fid and open that file and when you build it should build without error.

BTW I notice you have 4.5.3 - you may want to get 4.6.2 instead.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK clawson. I will continue to see if I can get the GCC/CB working. I just downloaded from Atmel the latest tool and also the H.files at Atmel.
I see that avr-8 ..... just signifies the AVR 8 bit devices.
The TAR file (I just downloaded)for the toolchain is 3.2.3.970 for the TAR file.

Can you inform me on the best location to unzip the header files and would I be better to delete the existing avr-gcc and re-install with the latest TAR or will the newer TAR file update/change with no problems.

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

the latest tool and also the H.files at Atmel

Eh? The .H (actually .h) files don't come separately. They are all part of the "toolchain" package. They constitute a lot of what is called AVR-LibC which is the compile time support package for avr-gcc.

As for location. It doesn't really matter. On my machine I think I just fid the "tar xvzf" in ~ but I later mv'd the whole toolchain to my preferred location which is /usr/local/avr but I guess I could have just done a "ln -s" in fact. Where the toolchain is located doesn't really matter as long as the build system you use knows where to look for it. (which you do in C::B by setting the path for "Toolchain Executables".

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I have been able to make some progress. I can now compile (very simple) test program with out errors.
My initial problem was I did not know exactly the path for the avr includes. Turns out the path is:
/usr/lib/avr/include/avr.

However , I don't seem to be able to get a main.hex file (?). I do get the main.o, object file
and using GHEX it appears to be correct just looking for a string placed in the code.

What I want to do, as a test , is to compile a simple test program and the copy the hex file to
the xp-pro PC and use atmel studio and perhaps a STK-500 or Dragon to verify that it did compile correctly.

I suspect using Avrdude on the Ubuntu PC might be another battle. One step at a time....

Another question is why does the app always access the codeblocks web site when ever I start/open a project?
Must be something in the setup I don't understand but not a hugh issue at this point.

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tubecut wrote:
My initial problem was I did not know exactly the path for the avr includes. Turns out the path is:
    /usr/lib/avr/include/avr
There should be no need to hard-code or even know this path at all. If you need that path explicitly, you very likely messed something up in your installation.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh yes, something messed up. All I did was install.
Any response to the other posted issues?

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tubecut wrote:
Well, I have been able to make some progress. I can now compile (very simple) test program with out errors.
My initial problem was I did not know exactly the path for the avr includes. Turns out the path is:
/usr/lib/avr/include/avr.

Another question is why does the app always access the codeblocks web site when ever I start/open a project? Must be something in the setup I don't understand but not a huge issue at this point.

You shouldn't have to specify that. You might ask questions on the CodeBlocks forum. Last time I checked they tended to a bit helpful.

I tried CodeBlocks and had issues with it, mostly setting up the AVR tool chain under windows. Switched to Codelite because I was using BeRTOS for ARM development and it seems to work fine.

Mucking around today, I've been able to get the AVR Visual Studio tool chain to work with Codelite. Big project compiles, links, runs, no problem. There are some odd unresolved file alias's though. But debugging and break points work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Resolved using this post:

http://lovingthepenguin.blogspot.fr/2012/01/fixing-codeblocks-avr-build-problems-on.html

On Ubuntu 12.04 and Code::Blocks 10.5

Summary:

    Open Settings > Compiler and debugger... > Global compiler settings Under Selected compiler, select "GNU AVR GCC Compiler"
    Select the "Search directories" tab
    Select the "Compiler" tab
    Select the /usr/include entry and click the "Delete" button
    Right next to the "Compiler" tab, select the "Linker" tab
    Select the /usr/lib entry and click the "Delete" button

Fred

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the reply Fred. I will take another stab at the CodeBlocks AVR installed on Ubuntu 12.04

So, just delete the paths?

I'll believe corporations
are people when Texas executes one.