![](/img/trans.png)
[英]Trying to use Windows Runtime Extensions in Windows Phone Static Library project (C++)
[英]How to use static library (windows phone 8)
我無法在Windows Phone 8.0的MSVC-2013中獲得與.exe應用程序鏈接的靜態庫。
我做了什么:
File-> New-> Project-> DirectX App(Windows Phone 8.0)->將其命名為“ MyApp”。
該模板創建了一個不錯的應用程序,可以毫無問題地進行編譯和運行。
右鍵單擊解決方案->添加->新項目->靜態庫(Windows Phone 8.0)。 我們稱之為“ MyLib”。
右鍵單擊MyApp->構建依賴關系->項目依賴關系->使它依賴於MyLib。
仍可編譯並運行。
轉到MyLib.h並聲明int my_function(int x)
。
轉到MyLib.cpp並定義int my_function(int x) {return 0;}
。
在MyApp的CubeRenderer.cpp中#include "MyLib.h"
。
加int y = my_function(6);
在CubeRenderer::CubeRenderer()
中的CubeRenderer::CubeRenderer()
中。
這會產生鏈接器錯誤。
error LNK2019: unresolved external symbol "int __cdecl my_function(int)" (?my_function@@YAHH@Z)
MyApp取決於MyLib,因此不需要在Linker->Input->Addidtional Dependencies
。 無論如何,我已經嘗試過了,但仍然收到錯誤消息。
我在MyLib.lib中搜索?my_function@@YAHH@Z
在那里找到了5次。
也許我不能使用名為Static Library (Windows Phone 8.0)
模板Static Library (Windows Phone 8.0)
而應使用DLL (Windows Phone 8.0)
或Windows Runtime Component (Windows Phone 8.0)
?
您需要將一個Project添加到Project引用中才能進行此構建。 您可以通過右鍵單擊項目的Add-> References並單擊Add New Reference並將MyLib作為項目添加到MyApp來添加到項目引用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.