I want to include third-party C++ libraries in my C++/CLI application.
What is/are the standard method(s) for doing this?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s very little to it, C++/CLI was explicitly created to support this scenario. Just pick a project template from the CLR node to get started. You’ll have to tell the linker to link the .lib files and #include the headers in your C++/CLI source code.
The only wrinkle you can run into is that the #include headers might contain declarations that can be misinterpreted by the C++/CLI compilers. C function declarations for example. Best thing to do is to the tell the compiler explicitly about it. Like this:
The #pragma comment in that snippet tells the linker to also link the .lib file of the 3rd party library. Saves you from having to do it explicitly in the linker’s Additional Dependencies setting.
That’s all.