C_INCLUDE_PATH,LIBRARY_PATH,LD_LIBRARY_PATH

利用系統的環境變量。
對於頭文件的搜索路徑:

C_INCLUDE_PATH=<your include path>;
export C_INCLUDE_PATH

對於庫文件的搜索路徑:

LIBRARY_PATH=<your lib path>;
export LIBRARY_PATH

對於鏈接程序ld使用的庫文件搜索路徑:

LD_LIBRARY_PATH=<your ldlib path>;
export LD_LIBRARY_PATH


LIBRARY_PATH is used by gcc before compilation to search for directories containing libraries that need to be linked to your program.

LD_LIBRARY_PATH is used by your program to search for directories containing the libraries after it has been successfully compiled and linked.

EDIT:As pointed below, your libraries can be static or shared. If it is static then the code is copied over into your program and you don't need to search for the library after your program is compiled and linked. If your library is shared then it needs to be dynamically linked to your program and that's when LD_LIBRARY_PATH comes into play.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章