I have few queries as mentioned below regarding command line options and its behavior in msvc:
1) How to build/create dynamic libraries ?
say I have two files mul.cpp
and sum.cpp
:
mul.cpp
#include "mul.h"
int mul(int a, int b)
{
return (a*b);
}
sum.cpp
#include "sum.h"
int sum(int a, int b)
{
return (a+b);
}
This is very generic platform independent implementations.
main.cpp
#include <iostream>
#include "mul.h"
#include "sum.h"
int main(int argc, char **argv)
{
std::cout << "mul(2,5) = " << mul(2,5) << std::endl;
std::cout << "sum(2,5) = " << sum(2,5) << std::endl;
return 0;
}
I want to create shared libraries sum.dll
and mul.dll
and finally link them with main.o
to generate executable using command prompt?
I came across a link which describes a solution
But it doesn't explains command line to use it.
So How can I create a dll
without worrying about manually creating .def
file or using __declspec(dllexport) for functions ?
As over the link it's mentioned that /DEF
or /DUMBIN
can be used for the same, But how to use it for this example ?
2) How can I implement the same example for debug build?