in my homework i must use this command to compile my program:
gcc -o mtm_rentals -std=c99 -Wall -pedantic-errors -Werror -DNDEBUG mtm_ex2.c rentals.c list.c -L -lmtm
what i can change in that line are the files im writing after -DNDEBUG. when i do this the gcc says that there are undefined references to specific functions. now those functions are declared in an .h file and are implemented in a given file called libmtm.a
i concluded that it doesnt recognize libmtm.a, but our homework task says that the -lmtm flag(which is not declared anywhere) is supposed to link libmtm.a to the program.
what am i missing here? am i supposed to implement somehow the -lmtm flag?
thank you!
You are missing a
.(single dot) behind the-L.-lmtmwill link against alibmtmlibrary, this is correct. It’s not an-lmtmflag, it’s a-lflag concatenated withmtm, the library you want to link against. This library is searched in some predefined paths (like/usr/lib/) and additionally in the paths given by -L. Assuminglibmtmlives in your current directory, you need to add that to-L, which is done with a..