-
Notifications
You must be signed in to change notification settings - Fork 806
Creating and Linking Against C Static Libraries
Meredith Monticello edited this page Mar 16, 2017
·
5 revisions
#Creating and Linking Against C++ Static Libraries
Follow the instructions below to have your Objective-C application project link against a C++ static library.
- In Visual Studio, right-click (1) on your solution and select Add (2) -> New Project... (3).
- Under Installed (1) -> Visual C++ (2) -> Windows (3) -> Universal (4), select Static Library (Universal Windows) (5).
- Name (1) your library project and click OK (2).
- When you're prompted to choose the platform version of your app, choose Windows 10 Anniversary Edition (10.0, Build 14393) (2) as the target version and Windows 10 (10.0, Build 10586) (1) as the minimum version. Note that the library target and minimum versions must be the same as the ones of your project that will link against the library.
Now that the library project has been added to your solution, you can edit it to add the functionality you need for your application. Once you're done, follow the steps below to link your Objective-C project against it.
- In Visual Studio, under your Objective-C project node that will be using the library, right-click on References (1) and select Add Reference... (2).
- Under Projects (1) -> Solution (2), check your library (3) and click OK (4). Note that if the library target and min versions do not match the ones of your project, you will get the Visual Studio error message Index (zero based) must be greater than or equal to zero and less than the size of the argument list when clicking on OK . To fix it, change the target and min version of either your library or your project so they match by right-clicking on them, selecting Properties->Configuration Properties->General and editing the Target Platform Version and Target Platform Min. Version fields.
- Right-click (1) on your Objective-C project and select Properties (2).
- Select Paths (3) under Configuration Properties (1) -> Clang (2).
- Add $(SolutionDir)\MyLib (1) to User Include Paths, where MyLib is the name of your library project. Add this path to all configurations of your project, by selecting each Configuration (2) and re-adding the same path. When you're done, click OK (3).
- For each source file that will use the library, right-click (1) on it, select Rename (2) and change the file extension to .mm so that it is compiled as Objective-C++.
That's it! You should now be able to include your C++ library in your .mm files using the include directive with double quotes (1) and call its C++ functions (2).
Project
Using the bridge
- Getting Started
- Using vsimporter
- Using the SDK
- Building From Source
- Adding Objective C to an Existing Project
- UI Guidance
- Changing the SDK Version of a Project
- Debugging
- Debugging Stack Traces from Crash Dumps
- Supported Third Party Libraries
- Creating and Linking Against C++ Static Libraries
- Packaging
Samples and Tutorials
- Quick Start Tutorial
- Building a To-Do List App
- Building a Calculator App
- Mixing and Matching UIKit and XAML
- IOS Bridge Samples Repo
Contributing
Links