Click here to Skip to main content
15,911,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Anyone I need some advice and would like to be directed in the right direction if possible. Pin
FISH7864-Mar-09 16:45
FISH7864-Mar-09 16:45 
GeneralRe: Anyone I need some advice and would like to be directed in the right direction if possible. Pin
Stephen Hewitt4-Mar-09 16:49
Stephen Hewitt4-Mar-09 16:49 
GeneralRe: Anyone I need some advice and would like to be directed in the right direction if possible. Pin
FISH7864-Mar-09 17:07
FISH7864-Mar-09 17:07 
GeneralRe: Anyone I need some advice and would like to be directed in the right direction if possible. Pin
Stephen Hewitt4-Mar-09 17:19
Stephen Hewitt4-Mar-09 17:19 
GeneralRe: Anyone I need some advice and would like to be directed in the right direction if possible. Pin
FISH7864-Mar-09 17:22
FISH7864-Mar-09 17:22 
QuestionProblem reading xml string into data table Pin
Renukapadhamanaban4-Mar-09 12:36
Renukapadhamanaban4-Mar-09 12:36 
QuestionHttpSendRequest Pin
Steve Thresher4-Mar-09 12:26
Steve Thresher4-Mar-09 12:26 
QuestionHelp Accessing Functions in a Dll Pin
Naturality4-Mar-09 10:17
Naturality4-Mar-09 10:17 
Hi,
I recently started my first project based around DLLs and have run into a little trouble.

I followed this tutorial: http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c9855

The code is split up into a header file and a source file.

It consists of a namespace, which contains variables and a class.

I am linking implicitly.

In a test program I can access the variables fine, no problems there, but when I use a function from the class, I get linker errors, eg:
<pre>1>ELQTest.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl ELQ::Functions::CreateRot(void)" (?CreateRot@Functions@ELQ@@SA_NXZ) referenced in function _SDL_main</pre>


Now for some code:

DLL Header:

#ifndef _ELQDLL_H_
#define _ELQDLL_H_
#include <SDL.h>
#include <cmath>
#include <windows.h>
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")

#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

namespace ELQ{
extern "C"{
#pragma data_seg (".globals")
DECLDIR bool keyboard[27], open;
DECLDIR double sins[720], coss[720], v, posx, posy, posz, f, h;
DECLDIR int WIDTH, HEIGHT, DEPTH, BPP, q, speed, theta, *map, o, lx1, ly1, lx2, ly2, lx3, ly3;

class Functions{
public:
static bool CreateRot();
};
}
}
#endif


DLL Source:
#include "ELQDLL.h"
#define DLL_EXPORT

#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

namespace ELQ{
extern "C"{
#pragma data_seg (".globals")
DECLDIR bool keyboard[27], open = false;
DECLDIR double sins[720], coss[720], v, posx, posy, posz, f = 10, h;
DECLDIR int WIDTH, HEIGHT = 10, DEPTH, BPP, q, speed, theta, *map = NULL, o, lx1, ly1, lx2, ly2, lx3, ly3;

DECLDIR bool CreateRot(){
for(int x = 0; x < 720; x++){
sins[x] = sin((x-360)*0.017);
}
}
}


#include "stdafx.h"
#include "ELQDLL.h"
#include <iostream>

SDL_Surface *screen;

int main(int argc, char *argv[]){
if(ELQ::Functions::CreateRot())
system("PAUSE");
return 0;
}



Any idea what could be wrong?

I've played around with all sorts of combinations of class definitions, export/import symbols etc, yet cannot get this to work.

Look forward to your input,

Thanks,
Nat.


PS: Oh, I should say that when I compile the DLL, I get a stream of inconsistency messages, could this be related?

"Sir, I protest. I am NOT a merry man!"
AnswerRe: Help Accessing Functions in a Dll Pin
Stuart Dootson4-Mar-09 10:28
professionalStuart Dootson4-Mar-09 10:28 
GeneralRe: Help Accessing Functions in a Dll Pin
Naturality5-Mar-09 5:17
Naturality5-Mar-09 5:17 
GeneralRe: Help Accessing Functions in a Dll Pin
Stuart Dootson5-Mar-09 15:56
professionalStuart Dootson5-Mar-09 15:56 
QuestionHow can I have tow different view type of the same document in a SDI Doc-View based app? Pin
Joseph Marzbani4-Mar-09 9:41
Joseph Marzbani4-Mar-09 9:41 
AnswerRe: How can I have tow different view type of the same document in a SDI Doc-View based app? Pin
Stuart Dootson4-Mar-09 10:22
professionalStuart Dootson4-Mar-09 10:22 
GeneralRe: How can I have tow different view type of the same document in a SDI Doc-View based app? Pin
Joseph Marzbani4-Mar-09 18:09
Joseph Marzbani4-Mar-09 18:09 
AnswerRe: How can I have tow different view type of the same document in a SDI Doc-View based app? Pin
«_Superman_»4-Mar-09 17:16
professional«_Superman_»4-Mar-09 17:16 
QuestionConfused Pin
su_penguin4-Mar-09 8:40
su_penguin4-Mar-09 8:40 
AnswerRe: Confused Pin
Adam Maras4-Mar-09 9:04
Adam Maras4-Mar-09 9:04 
GeneralRe: Confused Pin
su_penguin4-Mar-09 9:32
su_penguin4-Mar-09 9:32 
GeneralRe: Confused Pin
CPallini4-Mar-09 10:10
mveCPallini4-Mar-09 10:10 
GeneralRe: Confused Pin
«_Superman_»4-Mar-09 17:20
professional«_Superman_»4-Mar-09 17:20 
AnswerRe: Confused Pin
Jijo.Raj4-Mar-09 16:38
Jijo.Raj4-Mar-09 16:38 
QuestionInfantile question? Pin
Ric Ashton4-Mar-09 8:00
Ric Ashton4-Mar-09 8:00 
AnswerRe: Infantile question? Pin
Eytukan4-Mar-09 8:04
Eytukan4-Mar-09 8:04 
AnswerRe: Infantile question? Pin
Adam Maras4-Mar-09 8:05
Adam Maras4-Mar-09 8:05 
GeneralRe: Infantile question? Pin
CPallini4-Mar-09 10:02
mveCPallini4-Mar-09 10:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.