Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a C .lib file platform specific?

I'm trying to use an API for a proprietary interface device on an embedded system (Freescale HCS08), and the provided files include headers (.h) and libraries (.lib). The header compiles fine with the rest of my code (standard C), but when trying to link against the library I get memory errors saying the file might be corrupted.

My understanding of libraries in C is somewhat limited as I work almost exclusively on embedded systems where magic things like stdio, files, and dlls don't exist; but would the (or any) library be platform specific? Does it contain fully (if there is any sort of level there) compiled code? Some of the other files provided are VS project files, so if it is the case that the .lib is platform-specific, it wouldn't be unexpected that linking a file meant for x86-Windows to an 8-bit compiler would fail; it could be just me.

like image 394
Nick T Avatar asked Dec 28 '22 12:12

Nick T


2 Answers

Not only is a .lib file CPU specific (there would be no way to link HCS08 code to x86 code), it is toolchain specific (CodeWarrior won't talk to SDCC, GCC/binutils won't talk to Visual Studio).

like image 197
Yann Ramin Avatar answered Jan 12 '23 03:01

Yann Ramin


Yes the .lib contains compiled code so it is platform-specific. If you have the source you should be able to re-compile it to your platform.

like image 37
bshields Avatar answered Jan 12 '23 02:01

bshields