S
Scott Chang
Hi all,
I copied a set of VC++ version 6 source code of
the 'cppdll'(2 projects) from a website and put the
cppdll.cpp, cppdll.def, cpp.h, (as the 1st project) and
test.cpp (as the 2nd project) into my Microsoft VC++ .NET
2002 - Windows XP Pro PC:
//----cppdll.cpp----
#include "cppdll.h"
//prevent function name from being mangled
extern "C"
int cube(int num) {
return num * num * num;
}
//-----cppdll.def----
EXPORTS
cube
//-----cpp.h------
/*
this header is not required for this dll
to compile; but is required for the app
that will use this dll
*/
#ifndef CPPDLL_H
#define CPPDLL_H
//computes the square of the number
//prevent the function name from being mangled
extern "C"
int cube(int num);
#endif //CPPDLL_H
//------test.cpp------
#include <iostream>
#include "cppdll.h"
using namespace std;
int main() {
int num;
cout << "enter any number: ";
cin >> num;
cout << "cube of number is "
<< cube(num) << endl;
return 0;
}
===============================================
I did 'Build' successfully, clicked '! Start without
debugging' and the console had 'enter any number'
appeared. I typed in a number on the console and
pressed 'Enter' key and the console screen just
vanished!!!??? I do not know what it is wrong with my
program. Please help and tell me (1) what I should change
in the 'Configuration Properties' for each of the
cppdll.cpp, cppdll.def, cppdll.h and test.cpp files, and
(2) whether it is possible to use the native C++ input to
get the cube of the input number in the MC++ framework by
using a native C++ DLL.
Thanks in advance,
Scott Chang
I copied a set of VC++ version 6 source code of
the 'cppdll'(2 projects) from a website and put the
cppdll.cpp, cppdll.def, cpp.h, (as the 1st project) and
test.cpp (as the 2nd project) into my Microsoft VC++ .NET
2002 - Windows XP Pro PC:
//----cppdll.cpp----
#include "cppdll.h"
//prevent function name from being mangled
extern "C"
int cube(int num) {
return num * num * num;
}
//-----cppdll.def----
EXPORTS
cube
//-----cpp.h------
/*
this header is not required for this dll
to compile; but is required for the app
that will use this dll
*/
#ifndef CPPDLL_H
#define CPPDLL_H
//computes the square of the number
//prevent the function name from being mangled
extern "C"
int cube(int num);
#endif //CPPDLL_H
//------test.cpp------
#include <iostream>
#include "cppdll.h"
using namespace std;
int main() {
int num;
cout << "enter any number: ";
cin >> num;
cout << "cube of number is "
<< cube(num) << endl;
return 0;
}
===============================================
I did 'Build' successfully, clicked '! Start without
debugging' and the console had 'enter any number'
appeared. I typed in a number on the console and
pressed 'Enter' key and the console screen just
vanished!!!??? I do not know what it is wrong with my
program. Please help and tell me (1) what I should change
in the 'Configuration Properties' for each of the
cppdll.cpp, cppdll.def, cppdll.h and test.cpp files, and
(2) whether it is possible to use the native C++ input to
get the cube of the input number in the MC++ framework by
using a native C++ DLL.
Thanks in advance,
Scott Chang