問題描述
- 使用 C++ 控制臺命令行項目創建新解決方案
- 創建一個新項目,一個 C++ 靜態庫
- 使命令行項目依賴于庫
- 確保在配置 => 鏈接器 => 常規(默認情況下)中打開鏈接庫依賴項"
- Visual Studio 仍不會鏈接庫.
我該如何解決這個問題?它適用于 Visual Studio 2008.
How can I fix this? It worked in Visual Studio 2008.
推薦答案
這仍然有效,但 已在 VS 2010 中更改:
在 VS2010 中,我們停止支持定義隱式引用的項目依賴項,我們還引入了一種在項目級別定義項目依賴項的新方法.由于項目引用和項目依賴項是接近的概念,都適用于項目,因此在項目文件中以一致的方式將它們一起表示是有意義的.正如您將在下面的片段中看到的,項目引用定義和項目依賴項定義之間的唯一區別在于定義輸出程序集包含的元數據/排除到主項目鏈接命令行中/從主項目鏈接命令行中排除.盡管我們沒有刪除項目依賴項"對話框,但我們建議通過框架和引用"對話框定義新的項目依賴項.您需要將屬性頁 UI 中的引用程序集輸出"屬性設置為 false(對于項目依賴項)和 true(對于項目引用)."
"With VS2010, we stopped supporting project dependencies defining implicit references and we also introduced a new way of defining project dependencies at the project level. Since a project reference and a project dependency are close concepts, both applying to a project, it made sense to have them represented together, in a consistent way, in the project file. As you will see in the snippets below, the only difference between a project reference definition and a project dependency definition consists in metadata that defines the output assembly inclusion/exclusion into/from the main project link command line. Although we did not remove the "Project Dependencies" dialog, we recommend defining new project dependencies via the "Framework and References" dialog. You need to set the "Reference Assembly Output" property in the property page UI to false for a project dependency and to true for a project reference."
只需在控制臺項目上右鍵,選擇屬性->通用屬性->框架和引用->添加新引用",添加靜態庫項目;還要檢查右側的鏈接庫依賴項"是否為 True.似乎適用于調試和發布版本.你每天學習新的東西.;)
Just right-click on the console project, select "Properties->Common Properties->Framework and References->Add New Reference" and add the static library project; also check that "Link Library Dependencies" is True on the right hand side. Seems to work for debug and release builds. You learn something new every day. ;)
這篇關于Visual Studio 2010 不會像應該的那樣從屬于依賴項的項目中自動鏈接靜態庫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!