Adding standard C library files to Atmel Studio - c

I have Atmel Studio installed on my system, but when I want to use for example time.h of the stdio, it tells me the library does not exist!
So I downloaded this library:
http://download.savannah.gnu.org/releases/avr-libc/
Now, how can I include the whole library in my project?
After extracting, there are individual .h files and .c files that I can add in libc and include folders, but I'd like to add them all to my project (at least all of stdio, time, string...).
Thanks

Related

How are .a files handled on Windows machines using MinGW

I've seen from resources that .a files are static library files for WINDOWS Systems, and that .lib files are the equivalent but for UNIX systems. I'm beginning to try to import libraries in projects and saw that for SDL2 specifically, there are .a files that I include with my linking commands with minGW is there something under the hood that is going on for these files to be read and used on a Windows machine?
I've linkedthese successfully (and not-so-successfully a few hours ago),but this bugged me so I wanted to ask you all :)
On Windows machines using MinGW, .a files (also known as static library files) are handled by the linker (ld.exe) during the linking stage of the compilation process. The linker takes the object files (.o) generated by the compiler (gcc.exe) and combines them with the code and data stored in the .a files to create a single executable file. The linker also resolves any symbol references between the object files and the library code and data.

Extra Header Files Created After Build in IAR Workbench

I learn embedded programming with STM32F401RE in IAR Workbench.
I am confused about header file creation after build. Here below my question:
In the below file structure of IAR Workbench before build only a c file and there is no header file in the user folder
However after build process there are many header file in the user folder file.
My question is what is the purpose of the header file in it.
In addition to that question all headers files must be involved before build process?
Thanks.
Those are all header files that you have included in your main.c file, either directly or indirectly. Most at least are IAR library headers that come with the compiler. They are not created, but instead detected to be in use when you build your project.
For example, if you #include <stdio.h> in your source file, then stdio.h will be on that list. And all files that stdio.h includes will also be on that list. And then all includes from those included files are also on that list.
IAR library header files have typically have a lot of nested includes in them. Most likely you have at least one IAR library #include in your main.c file, or you have preincluded in a library header with your compiler command.

Force C compiler for extension capital C in Eclipse CDT

I'm having legacy Makefiles and would like to transfer them into Eclipse CDT Projects. Coming from windows, they have mixed .c as well as .C as extensions for C sources (while eclipse normally would treat capital ".C" as c++ files).
As they are checked into source control I'd like to avoid the hassle of renaming the source files.
As the files are linked into the workspace, I tried renaming the link to .c (leaving the target/original file as ".C"). CDT won't care and invoke the C++ compiler. Even worse, when I right-click on the file I get the settings for (only) the C compiler but what I change is irrelevant because still the C++ compiler with the project wide C++ settings is invoked.
Now, if there are only C files in the project I can set the project C++ settings under "Miscellaneous" to use -xc -std=c99 etc. and effectively force the g++ to behave like a proper C compiler - Which is not really beautiful and completely fails when there are other real .cpp files to be compiled as C++ within the same project.
Also, using project settings under C/C++ General/File Types and setting ".c" and ".C" to "C source file" doesn't seem to bother the CDT...
Am I overlooking something? Is this far outside the scope of CDT?

Including libraries in the custom code section in Simulink

I'm trying to Include some Libraries, like metis in the custom code library section in Simulink. Do you know what type of libraries Simulink excepts? Must they have the ending .a, .o, .dll or lib?
And can I include them into my custom c code with #include <metis.h>?
The library format should match the architecture on which you are going to compile the generated code. So .a or .so for GNU/Linux, .lib for Windows (you usually link against the .lib file not the .dll), and usually .dylib on Mac. You can also link in object files, (i.e. .o, .obj) but typically a software package will build some type of library for you to use.
If you are using any of the functions, types, etc. defined in any of the metis headers, then those headers need to be included in the generated code.
You can add #include "header_name.h" to the settings:
"Configuration Parameters->Simulation Target->Custom Code->Header File"
and:
"Configuration Parameters->Code Generation->Custom Code->Header File"
where header_name.h is replaced with the needed header file's name.
Since this question is tagged MATLAB Coder you can also use coder.cinclude('header_name.h'); in your MATLAB code to generate a #include "header_name.h" in the C code.
You may also need to augment the Include directories settings on the aforementioned Custom Code panes to allow the compiler to locate the headers.

How to create a makefile to use the mpir and mpfr libraries

I've recently written a C program which uses the public-domain mpir and mpfr libraries. I've been compiling it on Windows, using the Microsoft Visual C++ 10.0 compiler. To get that to work, I had to do the following:
Download / build the mpir and mpfr libraries from http://gladman.plushost.co.uk/oldsite/computing/gmp4win.php
Move the files mpir.h and mpfr.h into the Include directory for the Microsoft compiler
Move the files mpir.lib, mpir.pdb, mpfr.lib and mpfr.pdb into the lib directory for the Microsoft compiler
#include mpir.h and mpfr.h in the program
Compile using cl <..module names..> /link mpir.lib mpfr.lib
I now want to send the source / header files I've written to someone else, along with a makefile that they can use to compile the code and check that it works. Since that person won't have the mpir / mpfr libraries installed, and might not be using the same compiler, I'm not quite sure how to do this.
Here is what I can do:
Send them the binaries mpir.lib, mpir.pdb, mpfr.lib and mpfr.pdb as well as the source / header files.
Here is what I can't do:
Send them my entire Microsoft Visual C++ 10.0 setup
Ask them to stick files in their Include and lib directories (unless there's no other way)
Ideally, I should be able to send them the source/header files, together with the pertinent mpir/mpfr binaries, and a makefile which they can then run to build the program.
Thanks in advance for your help!
Why on earth are you adding those files to your compiler installation path?? The compiler has command line options for specifying search paths.
For instance,
cl /I"path/to/mpfr/header" <...filenames...> /link /LIBPATH:"path/to/mpfr/lib" mpir.lib mpfr.lib
You should only have to send your source code, mpir.h, mpir.lib, mpfr.h and mpfr.lib. The PDB files contain debugging information, and are not necessary for compilation.
Also, I don't know how to create a makefile, but a simple batch file with the command above should suffice for something so simple.

Resources