Reputation: 3435
I cannot get static library linked against .exe application in MSVC-2013 for Windows Phone 8.0.
What I did:
File->New->Project->DirectX App (Windows Phone 8.0) -> Name it "MyApp".
This template creates nice application that compiles and run without problems.
Right click on solution->Add->New Project->Static Library (Windows Phone 8.0). Let's call it "MyLib".
Right click on MyApp -> Build Dependencies -> Project Dependencies -> Make it dependent on MyLib.
Still compiles and runs.
Go to MyLib.h and declare int my_function(int x)
.
Go to MyLib.cpp and define int my_function(int x) {return 0;}
.
#include "MyLib.h"
in MyApp's CubeRenderer.cpp.
Add int y = my_function(6);
in CubeRenderer::CubeRenderer()
in CubeRenderer.cpp.
This produces linker error.
error LNK2019: unresolved external symbol "int __cdecl my_function(int)" (?my_function@@YAHH@Z)
MyApp depends on MyLib, so I do not need to set in Linker->Input->Addidtional Dependencies
. Anyway, I have tried it and still get the error.
I have searched for ?my_function@@YAHH@Z
in MyLib.lib - and found it 5 times there.
Maybe I cannot use template named Static Library (Windows Phone 8.0)
and should use DLL (Windows Phone 8.0)
or Windows Runtime Component (Windows Phone 8.0)
?
Upvotes: 0
Views: 537
Reputation: 26
You need to add a Project to Project reference to make this build. You can add this by right clicking the project Add->References and click Add New Reference and add MyLib to MyApp as a project to project reference.
Upvotes: 1