gcc l 选项命令?
gcc l option order?
gcc -g -O2 -Wall -I/usr/local/include MyAddressBook.pb-c.c addressbooktest.c -lprotobuf-c -o test
有效,但是
gcc -g -O2 -Wall -I/usr/local/include -lprotobuf-c -o addressbooktest addressbooktest.c MyAddressBook.pb-c.c
没有。
man gcc
表示
For the most part, the order you use doesn't matter.
Order does matter when you use several options of the same kind; for example, if you specify -L
more than once, the directories are searched in the order specified. Also, the placement of
the -l option is significant.
但是我无法理解 -L 和 -l 选项的使用如何改变编译逻辑。
我如何知道在哪里使用 -L、-l 选项?
当你使用
gcc -g -O2 -Wall -I/usr/local/include -lprotobuf-c -o addressbooktest addressbooktest.c MyAddressBook.pb-c.c
链接器(这是一个单独的程序,由gcc
front-end程序调用)运行,它会找到库protobuf-c
但由于(还)没有人使用它的任何功能,它将被忽略。
gcc -g -O2 -Wall -I/usr/local/include MyAddressBook.pb-c.c addressbooktest.c -lprotobuf-c -o test
有效,但是
gcc -g -O2 -Wall -I/usr/local/include -lprotobuf-c -o addressbooktest addressbooktest.c MyAddressBook.pb-c.c
没有。
man gcc
表示
For the most part, the order you use doesn't matter. Order does matter when you use several options of the same kind; for example, if you specify -L more than once, the directories are searched in the order specified. Also, the placement of the -l option is significant.
但是我无法理解 -L 和 -l 选项的使用如何改变编译逻辑。
我如何知道在哪里使用 -L、-l 选项?
当你使用
gcc -g -O2 -Wall -I/usr/local/include -lprotobuf-c -o addressbooktest addressbooktest.c MyAddressBook.pb-c.c
链接器(这是一个单独的程序,由gcc
front-end程序调用)运行,它会找到库protobuf-c
但由于(还)没有人使用它的任何功能,它将被忽略。