Skip to content

Instantly share code, notes, and snippets.

@coffeebe4code
Last active September 26, 2021 01:02
Show Gist options
  • Save coffeebe4code/30549dc31d9c360016a09079a1995c75 to your computer and use it in GitHub Desktop.
Save coffeebe4code/30549dc31d9c360016a09079a1995c75 to your computer and use it in GitHub Desktop.
help question

I have two units of code (featureA.c, featureA.h) (featureB.c, featureB.h). featureB has an include to featureA.h because it uses a function there, when i do this, everything works out.

gcc -Wall -O0 -std=c11 -g  -o test.exe test.o featureA.o featureB.o -lpthread

However, now I want to distribute my libraries. When I attempt to make an example project with.

gcc -Wall -O0 -std=c11 -g  -o target/example.exe example/main.c lib/libfeatureA.a lib/libfeatureB.a -lpthread

It says that there is an undefined reference to the function i need in featureA from featureB.

Why does the linking not resolve this? Does this mean I should just deliver one giant library?

And follow up. What is the standard way to distribute .h files and libraries?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment