Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [C++]Using a class from a DLL  (Read 605 times)

DJ

  • Bay Watcher
    • View Profile
[C++]Using a class from a DLL
« on: January 04, 2013, 02:37:02 pm »

OK, so I haven't programmed in quite a while, and I just came back to an old project. Anyway, I've run into a problem with using a Textbox class.

SDL_Sprite.h, which is in SDL Sprite.dll:
Spoiler (click to show/hide)
Main:
Spoiler (click to show/hide)
I can use Sprite and Display classes just fine, and I wrote them before my hiatus. It says Textbox is an undeclared identifier, though, and this is a new class. I can't for the life of me figure out why Textbox isn't working when Sprite and Display are. I have a feeling I'm missing something really obvious here, but I just can't figure it out :(
Logged
Urist, President has immigrated to your fortress!
Urist, President mandates the Dwarven Bill of Rights.

Cue magma.
Ah, the Magma Carta...

eerr

  • Bay Watcher
    • View Profile
Re: [C++]Using a class from a DLL
« Reply #1 on: January 04, 2013, 04:23:51 pm »

Code: [Select]
#ifndef SPRITE
#define SPRITE

#include "Stdafx.h"
#include "Anim.h"
#include "Backdrop.h"

#define SPRDLL

#ifdef SPRDLL
#define SPRITE_API __declspec(dllexport)
#else
#define SPRITE_API __declspec(dllimport)
#endif

namespace sprite
{

class SPRITE_API Sprite
{
private:
string name;
Anim* actv_anim;
vector<Anim*> anims;
Uint32 timer;
SDL_Rect coord;
public:
Sprite(string source);
Sprite();
void change_anim(string anim_name);
Frame* get_frame();
SDL_Rect get_coord();
void set_coord(int, int);
};

class SPRITE_API Display
{
private:
SDL_Surface* screen;
vector<Sprite*> sprites;
Backdrop* bkg;
SDL_Rect camera;
void init_video();
public:
Display();
void update();
void add_sprite(Sprite*);
void init_bkg(string);
};

class SPRITE_API Textbox
{
private:
Sprite* font;
string text;
SDL_Rect pos;
SDL_Surface* img;
void update();
public:
Textbox(string, string, SDL_Rect);
SDL_Rect get_coord();
void set_coord(int, int);
SDL_Surface* get_img();
void set_text(string);
string get_text();
};

}

#endif
Main:
Code: [Select]
#include "SDL Sprite.h"
#include <stdio.h>
#include <iostream>
#include <fstream>

using namespace sprite;

Sprite* test;
Textbox* testtext;

int main(int arcg, char **argv)
{
Display screen;
string teststr = "test.txt";
test = new Sprite(teststr);
screen.add_sprite(test);
screen.init_bkg("test_bkg.txt");
test->set_coord(300, 200);
for(int i = 0; i < 300; i++) screen.update();
return 0;
}
The code is like blocked by the spoiler or something- I need to be able to read it.
Logged

DJ

  • Bay Watcher
    • View Profile
Re: [C++]Using a class from a DLL
« Reply #2 on: January 04, 2013, 04:29:15 pm »

Wait, what? It shows up fine here ???
Logged
Urist, President has immigrated to your fortress!
Urist, President mandates the Dwarven Bill of Rights.

Cue magma.
Ah, the Magma Carta...

DJ

  • Bay Watcher
    • View Profile
Re: [C++]Using a class from a DLL
« Reply #3 on: January 04, 2013, 06:26:09 pm »

Nvm, I figured it out. I didn't update both SDL_Sprite.h files.
Logged
Urist, President has immigrated to your fortress!
Urist, President mandates the Dwarven Bill of Rights.

Cue magma.
Ah, the Magma Carta...