當我從IDE和命令行構建項目時,我有不同的編譯器行爲,這是我無法解釋的。從IDE和命令行構建C++ Builder項目有什麼區別?
詳細的問題的描述是相當大的,但它非常簡單。
我有一個C++ Builder項目,其中包含一個PAS文件(IncludeUnits.pas)。這個pas文件有幾個單位和inc文件列出。這些文件位於單獨的文件夾中,並且這些文件夾在庫&中列出,包括項目選項中的路徑。
文件夾佈局:
C:\演示\斌
C:\演示\項目
C:\演示\項目\ CBuilder5
C:\演示\項目\共同
Ç :\演示\源
C:\演示\源\共同
濱是輸出文件夾,項目/ CBuilder5持有項目(BPR-文件),項目/公共H包括pas-file(IncludeUnits.pas),Source和Source/Common保存其他文件(pas & inc)。我認爲這是非常平常的佈局。
C:\演示\項目\ COMMON \ IncludeUnits.pas:
unit IncludeUnits;
interface
uses
Test;
implementation
end.
C:\演示\來源\ Test.pas:
unit Test;
interface
{$I Test.inc}
implementation
end.
C:\演示\ Source \ Common \ Test.inc:
// this file is empty
如果我從C++ Builder IDE編譯這個項目 - 它會很好地編譯。 C++ Builder IDE在IDE設置集中沒有任何其他路徑。
現在,我想從命令行編譯它。首先,我發佈
bpr2mak.exe MyProject.bpr
命令。
這個命令創建MyProject.mak文件,在那裏我可以看到所有路徑(「.... \源」和「.... \來源\共同」是有問題的路徑):
...
INCLUDEPATH = $(BCB)\ include; $(BCB)\ include \ vcl; .. \ Common; .. \ .. \ Source; .. \ .. \ Source \ Common
LIBPATH = $(BCB)\ lib \ obj; $(BCB)\ lib; .. \ Common; .. \ .. \ Source; .. \ .. \ Source \ Common
...
現在,我運行make命令:
的make.exe -B -f 「MyProject.mak」
它給了我下面的輸出:
C:\ PROGRA〜1 \ Borland \ CBUILD〜2 \ BIN \ dcc32 -N2 .... \ Bin -N0 .... \ Bin - $ Y + - $ W - $ R -v -JPHNE -M -UC: \ PROGRA〜1 \ Borland的\ CBUILD〜2 \ BIN .. \包括; C:\ PROGRA〜1 \ Borland的\ CBUILD〜2 \ BIN .. \包括\ VCL; .. \ Commo n; .. \ .. \ Source; .. \ .. \ Source \ Common -D_DEBUG; _RTLDLL; NO_STRICT -OC:\ PROGRA〜1 \ Borland \ CBUILD \ 2 \ bin .. \ include; C:\ PROGRA〜 1 \ Borland \ CBUILD〜2 \ bin .. \ include \ vcl; .. \ Common; .. \ .. \ Source; .. \ .. \ Source \ Common --BCB .. \ Common \ IncludeUnits.PAS
(1)C:\ Demo \ Project \ Common \ IncludeUnits.pas(1)C:\ Demo C:\ Demo \ Project \ Common \ IncludeUnits.pas(1)C:\ Demo \ Project \ Common \ IncludeUnits.pas \ Project \ Common \ IncludeUnits.pas(1)C:\ Demo \ Project \ Common \ IncludeUnits.pas(6)C:\ Demo \ Source \ Test.pas(1)C:\ Demo \ Source \ Test.pas 5)不良反應:未找到文件:「Test.inc」
正如你所看到的 - 所有的搜索路徑傳遞到編譯器和文件(Test.inc)是所有在這裏 - 從Source \ Common文件夾中。但是編譯器仍然無法找到它?
當然,我使用bpr-file從文件夾中運行這兩個命令。而改變絕對路徑並沒有幫助。
將Test.inc從Source \ Common複製到Source 將幫助。將{$ I Test.inc}更改爲{$ I Common \ Test.inc} 也將幫助。
爲什麼?看來我錯過了一些東西。記住:從IDE編譯項目沒有問題,Test.inc被發現沒有複製或更改聲明。我錯過了一些開關製造或dcc32?
+1好主意:**複製並編輯模板文件**,...希望這會對我的特殊情況有所幫助 - 這是一種不同的類型 – Wolf 2014-06-04 15:10:46