"-L" adds a directory to the list of paths which will be searched. "-l" specifies the name (mostly) of the object library to look for. Thus..I also came across a site that showed two parameters for gcc as -L/home/pi/cpp and -lbcm2835. I noticed that bcm2835 is not a directory anywhere. What do these two parameters mean?
Code:
$ gcc -o c c.c -L /wrk -lfoo
Code:
$ g++ -o c c.cpp -L . -lfoo
You'd expect to write "-llibfoo.a" but for historic reasons the "lib" prefix is automatically added. Also there are two kinds of object library - static (eg: libfoo.a) and shared (eg: libfoo.so). Very loosely, you specify neither the ".so" nor the ".a" because the linker will use whichever it finds. It is possible to tell the linker exactly which kind to use if both kinds exist but you don't need that complexity just now! The compiler also knows where system stuff is without you having to tell it: use 'gcc' for C code and 'g++' for C++ code.
Incidentally, "-I" does the same as "-L" but for header files (again with some quirks).
Code:
$ gcc main.c -L/home/pi/cpp and -lbcm2835
Statistics: Posted by swampdog — Thu Mar 14, 2024 4:52 pm