Help creating DLL

Hello,

I've finished functions for the light version of my dll. I'd like to create a dll file out of my source in Visual Studio C++. I wrote the code in Code::Blocks.

I've started a new project in Visual Studio, added a header, and added a source file.

This is what I've put in my header..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef OGREWEAPONSTRIKES_H
#define OGREWEAPONSTRIKES_H
#include<string>


using std::string;
// this namespace is for holding classes and functions dealing with weapon strikes.

static __declspec(dllexport) void OgreRanSwordStrikesBtl(int OgreSwordStrikesID, int DamageAmount, int& EnemyHealth, string EnemyName);
static __declspec(dllexport) void OgreRanSwordStrikes(int OgreSwordStrikesID, int DamageAmount, string EnemyName);
static __declspec(dllexport) void OgreRanSwordStrikesMessage(int OgreSwordStrikesID, string EnemyName);
static __declspec(dllexport) void OgreRanClubStrikesBtl(int OgreClubStrikesID, int DamageAmount, int& EnemyHealth, string EnemyName);
static __declspec(dllexport) void OgreRanClubStrikes(int OgreClubStrikesID, int DamageAmount, string EnemyName);
static __declspec(dllexport) void OgreClubStrikesMessage (int OgreClubStrikesID, string EnemyName);

//This set of functions deal with Magic Attacks. There's Battle functions, and display functions!

static __declspec(dllexport) void OgreMagicFireBallBtl (int OgreFireBallID, int DamageAmount, int& EnemyHealth, string EnemyName);
static __declspec(dllexport) void OgreMagicFireBallStrikes (int OgreFireBallID, int DamageAmount, int& EnemyHealth, string EnemyName);
static __declspec(dllexport) void OgreMagicFireballMessage (int OgreFireBallID, string EnemyName);
static __declspec(dllexport) void OgreMagicLightningBtl (int OgreLightningID, int DamageAmount, int& EnemyHealth, string EnemyName);
static __declspec(dllexport) void OgreMagicLightningStrikes (int OgreLightningID, int DamageAmount, int& EnemyHealth, string EnemyName);
static __declspec(dllexport) void OgreMagicLightningMessage (int OgreLightningID, string EnemyName);

//This set of functions will facilitate damage based on dice roll and set damage value to that roll.
static __declspec(dllexport) void OgreD4Damage(int D4Amount, int& EnemyHealth);
static __declspec(dllexport) void OgreD6Damage (int D6Amount, int& EnemyHealth);
static __declspec(dllexport) void OgreD8Damage (int D8Amount, int& EnemyHealth);
static __declspec(dllexport) void OgreD10Damage (int D10Amount, int& EnemyHealth);
static __declspec(dllexport) void OgreD12Damage (int D12Amount, int& EnemyHealth);
static __declspec(dllexport) void OgreD20Damage (int D12Amount, int& EnemyHealth);
static __declspec(dllexport) void OgreD100Damage (int D100Amount, int& EnemyHealth);

//The Function Below facilitate to Dice Rolls, and retreiving a value alone.

static __declspec(dllexport) void OgreD4Roll (int D4Amount, int& D4Value);
static __declspec(dllexport) void OgreD6Roll (int D6Amount, int& D6Value);
static __declspec(dllexport) void OgreD8Roll (int D8Amount, int& D8Value);
static __declspec(dllexport) void OgreD10Roll (int D8Amount, int& D10Value);
static __declspec(dllexport) void OgreD12Roll (int D12Amount, int& D12Value);
static __declspec(dllexport) void OgreD20Roll (int D20Amount, int& D20Value);
static __declspec(dllexport) void OgreD100Roll (int D100Amount, int& D100Value);

#endif // OGREWEAPONSTRIKES_ 


I haven't added the code to the source file yet. I'm getting errors here, I'm wondering if that's normal. The errors are a bunch of these.

IntelliSense: dllexport/dllimport requires external linkage


as well as these two.

error LNK1120: 1 unresolved externals C:\Users\Jeremy\Documents\Visual Studio 2010\Projects\Ogre Titanium\OgreTitanium\Debug\OgreTitanium.exe OgreTitanium


error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\Jeremy\Documents\Visual Studio 2010\Projects\Ogre Titanium\OgreTitanium\OgreTitanium\MSVCRTD.lib(crtexe.obj) OgreTitanium


This is new waters to me, anyone got any insight?
another video on youtube said to do this after creating new dll project in visual studio

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include "stdafx.h"


#define DLL extern "C" __declspec(dllexport) 

#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
using std::string;
using namespace std;

//***The following code is for sword weapon strike functions. From battle to single message display.

//this is random sword strikes battle function. it's for random sword strikes. and dealing damage.
DLL void OgreRanSwordStrikesBtl(int OgreSwordStrikesID, int DamageAmount, int& EnemyHealth, string EnemyName){



if (OgreSwordStrikesID==1){
    //random attack display will determine which text will be displayed for the attack message.
    //if it's a 1 it will generate for light attacks, if it's a 2 it will generate for critical attacks.
    //This function also subtracts damage from enemy health.

    int RandomAttackDisplay;
    RandomAttackDisplay = (rand()%20)+1;
    EnemyHealth-=DamageAmount;

    switch (RandomAttackDisplay){

        case 1:
        cout << "A light slash doing minimal damage of " << DamageAmount << " to " << EnemyName <<"." <<endl;
        break;
        case 2:
        cout << "A light slash does minimal damage to " << EnemyName <<" " << DamageAmount <<"." << endl;
        break;
        case 3:
        cout << "A light slash cuts " << EnemyName << " for " << DamageAmount <<" damage." << endl;
        break;
        case 4:
        cout << "Sword grazes " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 5:
        cout << "Sword pokes " << EnemyName << " doing " << DamageAmount << " damage. " << endl;
        break;
        case 6:
        cout << "Sword lightly pokes " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 7:
        cout << "Blade grazes " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 8:
        cout << "Sword jabs " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 9:
        cout << "Sword lightly grazes " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 10:
        cout << "Sword barely grazes " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 11:
        cout << "Blade hardly grazes " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 12:
        cout << "Blade lightly jabs " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 13:
        cout << "Sword barely cuts " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 14:
        cout << "Sword hardly pokes " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 15:
        cout << "Sword barely cuts " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 16:
        cout << "Blade barely cuts " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 17:
        cout << "Blade hardly cuts " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 18:
        cout << "Blade lightly slides across " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 19:
        cout << "Sword lightly slides across " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        case 20:
        cout << "Sword hardly slides across " << EnemyName << " doing " << DamageAmount << " damage." << endl;
        break;
        default:
        cout << "There has been an error." << endl << "This is an internal error" << endl;
        cout << "please report the bug to creator." << endl;
    }
}

    else if (OgreSwordStrikesID==2){

        int RandomAttackDisplay;
        RandomAttackDisplay = (rand()%20)+1;
        EnemyHealth-=DamageAmount;

        switch (RandomAttackDisplay){
            case 1:
            cout << "Sword gashes " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 2:
            cout << "Sword slices " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 3:
            cout << "Sword crashes into " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 4:
            cout << "Sword deeply cuts " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 5:
            cout << "Blade deeply gouges " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 6:
            cout << "Sword gouges " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 7:
            cout << "Blade cuts deeply into " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 8:
            cout << "Blade deeply cuts " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 9:
            cout << "Sword slashes " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 10:
            cout << "Sword deeply gouges " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 11:
            cout << "Sword crashes into " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 12:
            cout << "Sword deeply slashes " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 13:
            cout << "Blade crashes into " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 14:
            cout << "Blade gouges " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 15:
            cout << "Blade gashes " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 16:
            cout << "Sword cuts deeply into " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 17:
            cout << "Blade deeply gouges " << EnemyName << " doing " << DamageAmount << " damage." << endl;
            break;
            case 18:
            cout << "Blade crashes into " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 19:
            cout << "Sword gouges " << EnemyName << " for " << DamageAmount << " damage." << endl;
            break;
            case 20:
            cout << "Sword slashes deeply into " << EnemyName << " doing " << DamageAmount << " damage";
            break;
            default:
            cout << "There has been an error within the function. Please report the bug to the creator." << endl;
        }
    }
    else {

    cout << "There has been a problem in OgreRanSwrodStrikesBtl." << endl;
    cout << "Please make sure that you have" << endl;
    cout << "passed the arguments into the function properly" << endl;
    cout << "Also make sure that the first argument is either 1 or 2" << endl;
    cout << "If you continue to have problems refer to the documentation" << endl;
    cout << "If problems persists feel free to contact the distributor" << endl;


    }

    }

I did that, and added DLL to the front of all my functions. Then it said to compile and build, I went build -> build ogre titanium. What happened was different than what happened in the video in the video in their project is at the bottom where it says show output from build a bunch of stuff rolled through,and it said build succeeded 1...I don't have that there I only have Error list, and don't know how to put the thing there they have....

anyway, when I went to build at the very bottom left of the screen it did say build succeeded. When I went through my debug folder where they went and retrieved there DLL they only had a few files from the build I would say...

I had a wack of files, but no dll...

I followed the video exactly as far as I can tell, with no success...

found it strange they didn't get me to prototype functions in a header file...

heres the link to the video..

http://www.youtube.com/watch?v=KUzEEVbEXrw&feature=results_main&playnext=1&list=PL71EFB6166B30C919

I don't even know if it's useful...
Never mind, I got it working haha. I'm right pumped..first dll down, much more learning to go!
Topic archived. No new replies allowed.