How to include .a file in Atmel Studio on Windows? - static-libraries

I'm trying to interface BME680 gas sensor module with AVR controller (Atmega644p to be specific) using Atmel Studio in Windows platform.
The BME680 does come with example functions multiple .h,.c files for configuration and one .a (static library). .h and .c files are calling some functions from static library as well, so we need to include all available .h, .c and .a files.
.a file was new to me and after basic web search I concluded that .a files are for Unix as .lib files are in Windows.
So can you find me a way to either:
convert my in hand .a file to .lib file?
or
to add .a file in Atmel studio in Windows platform?
Any help will be highly appreciated.
I did try to include .a file using following steps:
In Project=>Properties
click on the Toolchain tab Under XC8 Linker
click on Libraries In the Libraries (-l) window
click the "+" sign and add "libalgobsec" to the list In the Library
search path (-L) window
click on the "+" sign In the "Add Library search path (-L) dialog
click on the "..." button In the file dialog, navigate to the folder
that contains libalgobsec.a
Click okay.
Under Project Properties => XC8 Linker => Miscellaneous => Other
Objects, add: -u _fstat -u _read -u _write
But it gives this error: Compilation Error.

After 2 months of experiments, coordination with BOSCH and everything, here is the conclusion.
Pre-compiled library is only compatible with AVR controllers having Boot Memory of 256 Kbytes, and only following 4 controllers make it to list:
ATmega2561
ATmega2564RFR2
ATmega2560
ATmega256RFR2
So if you try to compile libalgobsec.a available in BSEC software for Atmega controllers with any other controller than mentioned above (in my case Atmega644P), it simply doesn't compile.

Related

Purpose of include folders in cross compiler

I have installed GCC cross compiler for Raspberry Pi to my Ubuntu 20.04 to opt folder. Now When I create new cross compile project I have list of include in my Eclipse project explorer:
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/arm-none-linux-gnueabihf/include
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/arm-none-linux-gnueabihf/libc/usr/include
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/10.2.1/usr/include
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/10.2.1/usr/include-fixed
How Eclipse knows these include folders?
What is purpose of all of these folders? What kind of includes they are defined for?
Suppose I need to use SDL2 library. Where I should place it's header and binary?
As explained in this article (which is a little dated) https://www.eclipse.org/community/eclipse_newsletter/2013/october/article4.php CDT will try to detect built-in compiler symbols and include paths running the compiler with special options and parse the output of this special run. The command will be probably something like: arm-linux-gnueabihf-cpp -v /dev/null -o /dev/null supposing the compiler you are using is arm-linux-gnueabihf-gcc.
All these folders contains include files like stdio.h , stdlib.h ... of libc , libm ... and also some arm specific header files.
If you are not 100% sure, install the cross compiled in a directory all by itself and add the include directory to your eclipse project.

Adding CMake Includes to the List so it appears in Xocde Project Navigator

When CMake is used to generate an Xcode project, the CMakeLists.txt file is included in the Project Navigator window so it is easy to click on and edit. I have written a CMake file that includes some utility functions in CMakeUtils.txt and is then included with INCLUDE(../CMakeUtils.txt). How can I make this file appear below the main cmake file in the Project Navigator?
If I add this file as a RESOURCE it will be included with the executable, and that's not right. How do I add a compile-time resource to be listed in Project Navigator but not included with the code?
For example, the following CMakeLists.txt file would contain the cmake file but not its includes. The associated test.cpp and CMakeUtils.txt files can be empty:
INCLUDE(CMakeUtils.txt)
CMAKE_MINIMUM_REQUIRED (VERSION 3.17.2)
PROJECT(demo_include)
ADD_LIBRARY(test test.cpp)

How to link my static .a library to a c Xcode(10.2.1) project

I have my own static c library eg. mylibrary.a , I have used it on a bunch of school projects from the terminal but I want to now use it with an Xcode(10.2.1) command line project for testing other projects.
I have tried putting the header file and .a file in the projects directory, adding the .a in the build phase menu under "link binary with libraries". I also tried linking it under "Other linker flags" by typing out my library's directory path. Thank you for your time.
It's old but maybe will work for you:
Go to your Project's Build Phases
Click on the "+" under "Link Binary With Libraries" to add a new library. Then click on the "Add Other" button.
Navigate to the static library file (.a) and add it.
https://www.chilkatsoft.com/xcode-link-static-lib
And then you should add your directory Build Settings > Library Search Path
Note: Not the full path, just the directory.

Eigen library + Code::Blocks

Trying to use Code::blocks with the library Eigen. Using windows vista. With some help from a forum I got this command to compile a sample program:
C:\Users\Me\Desktop\eigen>g++ -I C:\Users\Me\Desktop\eigen\eigen3
-o test2.exe C:\Users\Me\Desktop\eigen\test.cpp
But if I cd anywhere else (other than my folder containing test.cpp) and try to build, I get a permission denied error.
On code blocks I started a new project and went to Settings->Compiler->Linker settings->Link libraries-> and added C:\Users\Me\Desktop\eigen
And also added the same link under build options. I got this error:
C:\Users\Me\Desktop\GUI\vector\main.cpp|2|fatal error:
Eigen/Dense: No such file or directory|
The pages I followed were:
http://eigen.tuxfamily.org/dox/GettingStarted.html
https://github.com/Microsoft/AirSim/blob/master/docs/install_eigen.md
As eigen has already stated, all you have to do is copy the headers from the eigen folder to the include folder of your compiler (or just make sure your compiler can find your eigen folder).
Just copy the entire Eigen folder from drive/(where eigen is)/eigen/ to the include folder of code blocks in CodeBlocks\MinGW\include.
After that, all you have to do is make sure in Settings->Compiler in the Search directories tab, the compiler tab has the location to include and linker tab to lib, and the same goes for your build options.
There is absolutely no use of adding the Eigen folder to link libraries option of the linker tab, since Eigen has no libraries and works only with headers.

dev cpp win32 the program can't start because sqlite3.dll is missing

I am using dev c++ IDE which used ming gcc(i am not sure of it)
I wanted to use sqlite3 in my win32 c application
I downloaded sqlite3.dll and sqlite3.dev and used dlltool to create a .a file like libsqlite3.a and pasted in the lib folder of dev cpp and added this path in the project options -> parameters
i copied the header file sqlite3.h into the include folder(which i got from another website - http://www.opensource.apple.com/source/SQLite/SQLite-74/derived_source/sqlite3.h)
i executed the program and got the message 'the program can't start because sqlite3.dll is missing in your computer'
so i copied the sqlite3.dll into my working directory and then it worked
BUT
How to make the sqlite.* static while compiling?
I mean i thought by including the libsqlite3.a, the final exe will not be dependent of any external dll's.
So i want to know how to compile in a way that i will not be needing a dll and by doing so it makes my windows program standalone.
do i have a create a .lib file instead of .a file?
EDIT after answers and comments:
Besides, the devpak is working fine... yet i wanted to know how to include files to project or to create .a files so i am trying this way because if some components do not provide devpak then this will be the way we need to compile.. isn't it?
EDIT to show what i have done after the answer by CL and the two comments
This is how i have added the sqlite.c to project list
Here is the compile log
Compiler: Default compiler
Building Makefile:
"C:\Users\jayapalc\Documents\test-sqlite\Makefile.win"
Executing make...
make.exe -f "C:\Users\jayapalc\Documents\test-sqlite\Makefile.win" all
g++.exe -c sqlite3.c -o sqlite3.o -I"lib/gcc/mingw32/3.4.2/include"
-I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
sqlite3.c: In function `void strftimeFunc(sqlite3_context*, int,
sqlite3_value**)':
sqlite3.c:14727: error: invalid conversion from void*' tochar*'
The files i got in sqlite.org/sqlite-amalgamation-3071502.zip are
shell.c, sqlite3.h, sqlite3.c, sqlite3ext.h and i saw in other discussions that shell.c is not needed...
Besides, people were talking about gcc and g++... .
Apart from updating Dev-C++ itself, try this to compile sqlite.c as a C file:
Go to Project >> Project Options >> Files.
Find the C file we're talking about. Untick "Compile file as C++".
This should inform Dev-C++ that it should invoke gcc.exe, and not g++.exe.
If you don't want to compile sqlite yourself by adding it to your project, you can try passing the -static flag to GCC/G++ to force it to link libsqlite.a statically.
Just include the sqlite3.c file in your project.
You need only this filed, and it must be compiled as C, not C++.
Apparently, Dev-C++ does not allow mixing C and C++ source files in one project.
Instead, you could try to compile sqlite3.c as C and then include the generated .o file into the C++ project (on the Linker page).

Resources