Tools, FAQ, Tutorials:
"MyLibApp.cpp" - Call C++ Class from Static Library
How to call a function from a C++ class provided in a static library?
✍: FYIcenter.com
If you want to call a function from a C++ class provided in a static library,
you can follow this tutorial:
1. Specify the namespace of the C++ class:
using namespace fyi;
2. Reference the function with the class name prefix:
MyLib::printHello();
3. See the following full source code example, MyLibApp.cpp:
// MyLibApp.cpp
// Copyright (c) FYIcenter.com
#include "MyLib.h"
using namespace fyi;
int main() {
MyLib::printHello();
}
4. Compile and run the example, MyLibApp.exe:
C:\fyicenter>cl /EHsc MyLibApp.cpp MyLib.lib Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25019 for x86 Copyright (C) Microsoft Corporation. All rights reserved. MyLibApp.cpp Microsoft (R) Incremental Linker Version 14.10.25019.0 Copyright (C) Microsoft Corporation. All rights reserved. /out:MyLibApp.exe MyLibApp.obj MyLib.lib C:\fyicenter>MyLibApp.exe Hello world! - From MyLib
⇒ Error on Building C++/CLI Programs
⇐ "MyLib.lib" - C++ Class and Static Library
2023-06-19, ∼2246🔥, 0💬
Popular Posts:
What's Wrong with "while ($c=fgetc($f)) {}" in PHP? If you are using "while ($c=fgetc($f)) {}" to lo...
Tools, FAQ, Tutorials: JSON Validator JSON-XML Converter XML-JSON Converter JSON FAQ/Tutorials Pytho...
How to read Atom validation errors at w3.org? If your Atom feed has errors, the Atom validator at w3...
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
Where to find tutorials on JSON (JavaScript Object Notation) text string format? I want to know how ...