C++ DLL Incorporation

willc0de4food

New member
Joined
Apr 9, 2005
Messages
2
Location
/usr/src/MI
Programming Experience
1-3
Hey, i have a problem where i can write a dll in MSVC++ and use it in VB .NET but when i try to write one in Dev-C++, it fails and pretends i dont have a [dllname].def file :( so i was wondering if anyone could tell me what i'm doing wrong or how to fix this problem. the DLL's name comes out as circlearea_devcpp.dll. here's my VB Code:
VB.NET:
Private Declare Function ReturnVersion Lib "C:\Documents and Settings\Tim Hansen\My Documents\Visual Studio Projects\circlearea_devcpp.dll" () As Long
    Private Declare Function circlearea Lib "C:\Documents and Settings\Tim Hansen\My Documents\Visual Studio Projects\circlearea_devcpp.dll" (ByVal area As Double) As Double


    Private Sub About_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles About.Click
        ' Report Version Number
        Call MsgBox(ReturnVersion())
    End Sub

    Private Sub Bye_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bye.Click
        Application.Exit()
    End Sub

    Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calculate.Click

        Dim area, radius As Double

        radius = InputBox.Text
        ' call to dll for area calculation
        area = circlearea(radius)

        OutputBox.Text = Str$(area)

    End Sub

    Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear.Click
        InputBox.ResetText()
        OutputBox.ResetText()
    End Sub
here's my C++ Code:
VB.NET:
#include "stdafx.h"
#include <windows.h>

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    return TRUE;
}


int ReturnVersion(void)
{
	int version = 1;
	return version;
}

double circlearea(double radius)
{
	double area;

	area = 3.1415926535 * (radius * radius);

	return area;
}
and then Dev-C++ generates a .def file and i've tried writing it myself which doesn't work either :(
here's theirs, filename - libcirclearea_devcpp.def:
VB.NET:
; dlltool --base-file C:\DOCUME~1\TIMHAN~1\LOCALS~1\Temp/cca03420.base
 --output-exp circlearea_devcpp.exp --dllname circlearea_devcpp.dll --output-def
libcirclearea_devcpp.def --no-export-all-symbols --add-stdcall-alias
--exclude-symbol=DllMainCRTStartup@12 
--def C:\DOCUME~1\TIMHAN~1\LOCALS~1\Temp/cca03420.def --output-lib
libcirclearea_devcpp.a
EXPORTS
and mine, filename - circlearea_devcpp.def:
VB.NET:
EXPORTS
      ReturnVersion
      circlearea
any thoughts? thanks
 
if any of us here new how to help you we would have, there isnt always someone here who can answer all the questions
 
Back
Top