[LIB ] 請教﹕關於gcc和ifort的-L和-l參數的制定問題

看板LinuxDev作者 (said)時間17年前 (2006/12/19 18:34), 編輯推噓2(201)
留言3則, 2人參與, 最新討論串1/1
ifrot為﹕9.1.040﹔gcc為﹕3.2.3 用man察看其用法﹐發現好像gcc的-L和-l與ifort的意義不一樣。 對於gcc -l其明確指出﹕ The directories searched include several standard system directories plus any that you specify with -L 也就是說對於-l﹐gcc會先搜索所有制定的-L文件夾﹐並且﹕ The only difference between using an -l option and specifying a file name is that -l surrounds library with lib and .a and searches several directories. 這個意思是說-l和直接指定的libXXX.a的唯一區別是-l會搜索文件夾。 但是對於ifort﹐它的說明文件就含糊很多﹕ The standard libraries, like libc, are loaded with the -l loader option and not a full pathname. The wrong library can be loaded if there are files with names like libc.a or libc.so in the directories specified with the -L loader option, or in the default directories searched by the loader. 這樣好像ifort裡面-l不光指定了libXXX.a﹐連libXXX.so也制定了。並且根據我的觀察﹐ 好像在ifort裡面-L指定的目錄隻是對後面連接的-l有用。舉個例子來說﹕ -lsvml -L/usr/lib/gcc-lib -lg2c -L/opt/intel/mkl lmkl_ia32 如果在gcc的選項中﹐這個意思應該是說﹕ 先在/usr/lib/gcc-lib和/opt/intel/mkl目錄下找libsvml.a libg2c.a libmkl_ia32.a 三個靜態庫﹐如果找不到的話﹐就在系統默認的目錄下找。 如果在ifort的選項中﹐這個意思應該是說﹕ 現在系統的默認目錄下找libsvml.a或者libsvml.so﹔然後再在/usr/lib/gcc-lib找 libg2c.a或者libg2c.so﹔最後在/opt/intel/mkl目錄下找libmkl_ia32.a或者 libmkl_ia32.so 不知道我這樣理解對不對﹖ 還有一個是關於-Wl的意義﹐對於ifort是這樣的﹕ -Wl,<o1>[,<o2>,...] Passes options <o1>, <o2>, and so forth, to the linker for processing. If the linker is not invoked, these options are ignored. 不知道怎麼理解﹐那位能給個比較明白的例子﹖ 因為我的英文比較菜﹐所以不能很好的理解manual的意思。勞煩大家指正。謝謝 :) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.34.14.21

12/19 19:15, , 1F
參考 #43
12/19 19:15, 1F

12/20 21:46, , 2F
對於gcc我覺得我的理解沒有錯﹐但是對於ifort我不知道那樣
12/20 21:46, 2F

12/20 21:47, , 3F
理解有沒有問題﹖還是說ifort和gcc是一樣的﹖
12/20 21:47, 3F
文章代碼(AID): #15Xy0cKK (LinuxDev)