Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //sampleDLL.h
- #ifndef sampleDLL_H_
- #define sampleDLL_H_
- #include <iostream>
- #if defined DLL_EXPORT
- #define DECLDIR __declspec(dllexport)
- #else
- #define DECLDIR __declspec(dllimport)
- #endif
- extern "C"
- {
- DECLDIR int Add( int a, int b );
- DECLDIR void Function( void );
- }
- #endif
- //sampleDLL.cpp
- #define DLL_EXPORT
- #include <iostream>
- #include "sampleDLL.h"
- extern "C"
- {
- DECLDIR int Add( int a, int b ) {
- return( a + b );
- }
- DECLDIR void Function( void ) {
- std::cout << "DLL Called!" << std::endl;
- }
- }
- //sampleDLL.def
- LIBRARY "sampleDLL"
- EXPORTS
- Add @1
- Function @2
- //sampleAPP.cpp
- #pragma comment(lib, "sampleDLL.lib")
- #include <iostream>
- #include "sampleDLL.h"
- int main() {
- Function();
- std::cout << Add(22, 38) << std::endl;
- system("pause");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement