How to use .a library file in arm keil - arm

Now I am using the stm32F103 chip, using a .a library file in the keil environment, the compilation is no problem, but the MCU cannot run as soon as I run it

The problem may not be about .a file. Before uploading, check if "reset after flash" option in the debug section.

Related

Why mbed generating bin file different size online compiler and off line compile (export gcc_arm makefile)

When build project on online ide genereted bin file size 21k but exported project that export settings Make-GCC-ARM, build with make command on linux terminal generated file size 52k.And how can reduce offline generated bin file size?
Thanks.
Online Mbed Compiler uses ARMC6 toolchain to compile the code. While you are using GCC_ARM to compile locally. Different toolchains compile code differently hence the binary size difference.
If you use ARMC6 toolchain locally to compile, the binary size will be very close to the one generated by an online compiler.

How to cross compile GSL library for arm-none-eabi-gcc?

I need to use the GSL library in my program on LPCXpresso 4367(ARM CORTEX M4). I tried to follow the library linking procedure for LPC xpresso but the MCU linker is giving me these errors:
MCUXpressoIDE_10.3.0_2200\workspace\test1\Debug/../src/test1.c:53: undefined reference to 'gsl_linalg_LU_decomp'
MCUXpressoIDE_10.3.0_2200\workspace\test1\Debug/../src/test1.c:56: undefined reference to 'gsl_matrix_alloc'
MCUXpressoIDE_10.3.0_2200\workspace\test1\Debug/../src/test1.c:57: undefined reference to 'gsl_linalg_LU_invert'
and so on for other functions as well.
I have the libgsl.a and libgslcblas.a precompiled libraries for windows which works perfectly on codeblocks on windows with GCC compiler.
I read that I need to crosscompile library for the arm-none-eabi-gcc toolchain. But can someone please provide me the procedure as well?
the libgsl.a and libgslcblas.a precompiled libraries for windows
Those won't do for ARM.
In order to work on another platform, these libs need to be compiled from source code with the proper compiler (and settings - Cortex-M4F requires Thumb2 instruction set).
As the libraries are precompiled for Windows they don't work for ARM (as it is said in the other answer)
You need to cross compile the libraries first. If you install the GSL libraries following this procedure, you only need to change the parameters in the ./config according to your platform, for example I used:
./config --host=arm-linux-gnueabihf --prefix=/home/yourname/gsl_arm
Inside the .zip file with the gsl-2.5 files, there is a file called INSTALL. There you can find more details on the options for cross compiling.
Make sure to make clean before if you have already compiled the library for different settings. After cross-compiling the library when you run make check on the terminal you will probably get errors, but still it works. Continue with make install and you are ready to use it.

Where to find the startup code in IAR Embedded Workbench for ARM project?

I am currently developing a makefile that uses IAR toolchain for ARM to build a project on an eclipse based IDE. I have successfully compiled all source files but in order to link the object files, I need to have the startup code for IAR. I can't seem to find where it is in any sample IAR projects using IAR IDE or eclipse with IAR plugin.
my target is: s32k144
There is a GettingStarted project for s32k144 that can be downloaded from inside the IAR ide. In the directory for this project there is a sub-directory called Startup and in this directory there is a specialized cstartup.s file and a low_level_init.c file. In addition to this, the config sub-directory contains a linker configuration file for this chip. For some reason this linker configuration places the code in ram and not in flash but that is probably easy to fix.

header source file needed after compilation?

If I make headerfile.h and then headerfile.c with the source code for the functions. Once I compile the main C file sampleprogram.c
cc -o sampleprogram headerfile.c sampleprogram.c
Is that source file for the header still needed?
Is headerfile.c and sampleprogram.c compiled and linked together?
Do you need to include the headerfile.h along with sampleprogram if you were to put the program on a usb drive and put it on a different computer?
Headers are not required to execute a program or to use a shared/static library. However, headers are required to write code that uses the interface of a library. Usually, under RedHat distros, you'd have rpms that install the library (libuv) and rpms that install the headers (libuv-devel).
Therefore, without headers, you can execute a program, or you can link against a library. However, if you want to write code that uses the API of a library, you need the headers on your system.
If you compile a program and put it on a USB drive, all you need is the executable. However, you might need to recompile your program as the compiler targeted the specific architecture of the system it ran on. If you move the executable to another computer, it might not work.
Short answer:
No, it is not needed.
Longer answer:
No it is not needed, because when you use #include, the content of the header file will basically be pasted in to the C file. Because of that, the executable will not need the header file nor the c file to run (they are compiled into the executable already by the compiler)

Creating a library for openwrt environment

I am working on a project where in I create a C library(compiled through Makefile), then I write another C program (that uses the above C library ) and compile. I did all the above in a linux x86_64 system and it worked. Unfortunately I had to do all these things in a device that uses openwrt environment.Having not been too familiar with openwrt, what I did is placed the library that i created in linux, in openwrt's lib folder and tried to compile it, but because the architecture of linux of openwrt is not same, it threw the following error
could not read symbols: File format not recognized
Now, my question is. How can i create the above library for openwrt environment. Do I need to use a makefile, a cross compiler(if yes, which one) or use some other option?
From the wikipedia page of OpenWrt (https://en.wikipedia.org/wiki/OpenWrt):
The OpenWrt build system ...
Provides an integrated cross-compiler toolchain (gcc, ld, uClibc etc.)
so yes, you need to cross compile, please follow the instructions at:
https://wiki.openwrt.org/doc/devel/crosscompile
However, You will need to know the architecture of your OpenWrt box ...

Resources