Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22009

Check that all symbols defined in static library

$
0
0

I built some static library with no errors.
When I tried to link it to some app I realized that some symbols is undefined inside library.

I want to get error on library building step not on app.

In other words

$ cat mylib.h
void foo();
$ cat mylib.c
#include "mylib.h"
// no foo() implementation here;
$ cat test.c 
#include "mylib.h"

int main() {
    foo();
    return 0;
}
$ gcc mylib.c -c
$ ar crf libmylib.a *.o
$ gcc test.c -lmylib -L.
/tmp/cc7201uP.o: In function `main':
test.c:(.text+0xa): undefined reference to `foo'
collect2: error: ld returned 1 exit status

I want to get error at one of those step

$ gcc mylib.c -c
$ ar crf libmylib.a *.o

Is it possible, and what is good practice for such situations?

Updated: I tried $ nm --undefined-only *.a output is :

mylib.o:

It's little bit strange for me. I expect something like foo() inside output.


Viewing all articles
Browse latest Browse all 22009

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>