Search

VS11 build/lib.exe will not allow the creation of c++ static library that calls WinRT apis (with 8175 & BETAREL) by evangineer

Closed
as Fixed Help for as Fixed

2
0
Sign in
to vote
Type: Bug
ID: 722313
Opened: 2/1/2012 2:25:25 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
VS11 IDE (build rules) and lib.exe prevent the creation of statically linked libraries that call WinRT apis. This is fundamental to separation of concerns, data hiding, and reuse.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 11 Developer Preview

Steps to reproduce

Attempt to create either a 'C++|Windows Metro Style|Blank Static Library' OR a 'C++|Win32|static library' project that can call NetworkInformation::GetHostNames() (as an example) an return the first host name as a std::string. I am encountering MSB8016 - This project does not support the current Configuration Type (StaticLibary). The conf-type must be Application or DynamicLibrary for "Immersive" projects.

If I use the compiler, I can get it to compile, but the librarian (lib.exe) produces a LNK1326 - archiving OBJ compiled with /ZW into static lib is not supported.

Microsoft Visual Studio 11
Version 11.0.50110.2 PREREL

and

Microsoft Visual Studio 11
Version 11.0.50214.1 BETAREL

Product Language

English

Operating System

Windows 8

Operating System Language

English

Actual results

I have lots of legacy C++ code. I want to create a platform abstraction layer in the form of static libs that provide system API access with platform-independent interfaces. I want to wrap the legacy code in a WinRT component dll which will abide by all of the metro rules. I also want to be able to share the bulk of the legacy code between desktop and metro application builds. Please enable the IDE and librarian to support static libs that can call metro apis. For example...

#include <string>

using namespace Windows::Networking::Connectivity;
class hostname
{
hostname(void);
~hostname(void);
public:
static std::wstring get();
};

std::wstring hostname::get()
{
auto names = NetworkInformation::GetHostNames();

return std::wstring(names->Size > 0 ? names->GetAt(0)->DisplayName->Data() : L"");
}

Expected results

IDE and lib.exe would create a .lib with my code that could be linked into various winRT applications.
File Attachments
0 attachments
Sign in to post a comment.
Posted by evangineer on 4/6/2012 at 10:08 AM
Below the comment was left by 'Microsoft' that this will be fixed in the next major release. Does this mean VS12 or will a build of VS11 fix this issue?

this defect (decision) to prevent the creation of static libraries is very disruptive to our development for Win8 and Metro.
Posted by OmniGSoft on 3/2/2012 at 9:54 AM
Hi VS 11 Team:
It looks like this bug is still in the VS 11 Beta.
When we build a static library with WinRT calls in the source code, the compiler still gives error message "error LNK1326: archiving OBJ compiled with /ZW into static lib is not supported".

Is there a work around for this?
OmniGSoft
Posted by thefans on 3/2/2012 at 8:30 AM
Is this fix included in Visual Studio 11 Beta? Because the problem still exists.
Posted by Microsoft on 2/9/2012 at 8:36 PM
We have resolved the problem and the fix will be included in our next major release. Thank you very much for the report.
Posted by MS-Moderator07 [Feedback Moderator] on 2/1/2012 at 6:19 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 2/1/2012 at 2:43 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.