GNU or MS? 此link非彼link !

來源:互聯網
上載者:User

補上今天引發環境變數大研究的case。。。

----------------  分割線 -------------------

 

今天手動調侯捷的深入淺出MFC中的範例。

結果make過程中遇到奇怪錯誤:

 

link: invalid option -- s
Try `link --help' for more information.

 

看了下範例裡的GENERIC.MAK 的相關幾行:

 

generic.exe : generic.obj generic.res
    link /MACHINE:I386 -subsystem:windows generic.res generic.obj /
         libc.lib kernel32.lib user32.lib gdi32.lib

我懷疑是/machine -subsystem等參數的問題

上網查了一番,倒搞清了很多細節問題,比如:

  Project Settings->Link參數的設定

  速查:Linker Reference  - msdn

  速查:VC++Project Setting中各參數解釋

 

照著資料,發現咋這裡的link參數這麼奇怪呢

資料上明明是/SUBSYSTEM

這裡咋成了-subsystem

 

疑惑中,嘗試將-subsystem改成/SUBSYSTEM再試

結果錯誤變了:

 

kernel32.lib user32.lib gdi32.lib
link: extra operand `generic.res'
Try `link --help' for more information.

這下徹底傻眼。

暈了一份來鐘,好吧,那就按提示說的,看看協助裡說些啥吧。

 

這一打協助,立即囧掉。

 

Usage: link FILE1 FILE2
  or:  link OPTION
Call the link function to create a link named FILE2 to an existing FILE1.

      --help     display this help and exit
      --version  output version information and exit

Report bugs to <bug-coreutils@gnu.org>.

 

我的天哪,搞了半天我是在用GNU的linker在連結。

 

去系統的環境變數找了一番,發現原來是它搞的鬼:

 

%SystemRoot%/system32;%SystemRoot%;%SystemRoot%/system32/Wbem;C:/cygwin/bin;%MSSdk%/Bin;%MSSdk%/Bin/WinNT;F:/Microsoft Visual Studio/Common/MSDev98

 

將紅色部分移到最後,問題解決。

 

 

環境變數,以後得小心哪!!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.