Tools, FAQ, Tutorials:
"MyLib.lib" - C++ Class and Static Library
How to create a C++ class and build it into a static library?
✍: FYIcenter.com
If you want to create a C++ class and build it into a static library,
you can follow this tutorial:
1. Create the header file, MyLib.h, with a text editor:
// MyLib.h
// Copyright (c) FYIcenter.com
namespace fyi {
class MyLib {
public: static void printHello();
};
}
2. Create the class source code file, MyLib.cpp, with a text editor:
// MyLib.cpp
// Copyright (c) FYIcenter.com
#include "MyLib.h"
#include <iostream>
using namespace std;
namespace fyi {
void MyLib::printHello() {
cout << "Hello world! - From MyLib" << endl;
}
}
3. Compile and build the static library:
C:\fyicenter>cl /c /EHsc MyLib.cpp Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25019 for x86 Copyright (C) Microsoft Corporation. All rights reserved. MyLib.cpp C:\fyicenter>lib MyLib.obj Microsoft (R) Library Manager Version 14.10.25019.0 Copyright (C) Microsoft Corporation. All rights reserved.
4. Distribute the header file, MyLib.h, and the library file, MyLib.lib, to others to use.
⇒ "MyLibApp.cpp" - Call C++ Class from Static Library
⇐ "link" - Link Object Files (*.obj)
2023-06-19, ∼2449🔥, 0💬
Popular Posts:
Can Multiple Paragraphs Be Included in a List Item? Yes. You can include multiple paragraphs in a si...
How to use .NET CLR Types in Azure API Policy? By default, Azure imports many basic .NET CLR (Common...
How to include additional claims in Azure AD v2.0 id_tokens? If you want to include additional claim...
What is EPUB 2.0 Metadata "dc:creator" and "dc:contributor" elements? EPUB 2.0 Metadata "dc:creator"...
How to use the "forward-request" Policy Statement to call the backend service for an Azure API servi...