libA.a (archive file): Unknown format, not a static library!

35 views
Skip to first unread message

anshul mahajan

unread,
Mar 11, 2020, 7:03:19 AM3/11/20
to emscripten-discuss
Hi All,

I am trying to build my project using emcc but while building if I provide staitc lib : libA.a ,  it it giving me error "Unknown format, not a static library!'.

In my case libA.a is dependent on libB.a. 

building step for libB.a :

1) generating object file i.e .o files of all the cpp files
2) creating libB.a : running "emar" command for : emar -r {list of .o files}

building libA.a
1) generating object file i.e .o files of all the cpp files
2) creating libB.a : emcc -L ./ -llibB(dependent lib)  -o./libA.a {list of .o files}


My question here is : does anyone knows how to create static lib(.a) when the static lib are dependent on other static lib.  i.e I have all the .o files and .a file which I need to use for creating new lib. 

Regards,
Anshul

Floh

unread,
Mar 12, 2020, 9:04:56 AM3/12/20
to emscripten-discuss
AFAIK static libs (.a files) are just simple file archives (thus the .a file extension) of .o files, basically several .o files appended to the same .a file. This means there's no linking taking place when creating a static library, and thus using another static library as dependency doesn't make much sense.

Only when build a DLL or executable, both libA.a and libB.a must be provided as linker inputs.

High-level build-systems like cmake somewhat obscure this (for instance in cmake it makes sense to provide one static library as dependency of another static library, but this only affects cmake's own dependency tree, for instance if libA is provided as cmake dependency of libB, only libB must be provided as dependency to executables and DLLs, and cmake will automatically add the libA dependency).
Reply all
Reply to author
Forward
0 new messages