During development I periodically compiled and checked my library on mistakes. But now I have some problems with my DLL:
Quote
Building dllmain.obj.
Building charslist.obj.
Building charmain.obj.
Building selfdata.obj.
Building selfdata_work.obj.
Building character.dll.
POLINK: error: Unresolved external symbol '_Char_GetCharName'.
POLINK: error: Unresolved external symbol '_Char_SetCharName'.
POLINK: error: Unresolved external symbol '_Char_GetCharID'.
POLINK: error: Unresolved external symbol '_Char_SetCharID'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.
Why so?
Here is my character.h file:
#ifndef _CHARACTER_
#define _CHARACTER_
#ifndef WINAPI
#define WINAPI __stdcall
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <tchar.h>
#include <stdlib.h>
#include <stdio.h>
#include "lists.h"
#include "messages.h" // My Messages
/*Work with Self Data/*
char* WINAPI Char_GetCharName(PCHARDATA Char);
int WINAPI Char_SetCharName(HWND HWNDMain, PCHARDATA Char, char* NewCharName); /*CS Protected*/
DWORD WINAPI Char_GetCharID(PCHARDATA Char);
int WINAPI Char_SetCharID(HWND HWNDMain, PCHARDATA Char, DWORD NewCharID); /*CS Protected*/
#endif
Here is codes of my functions:
char* WINAPI Char_GetCharName(PCHARDATA Char)
{
if (Char == NULL) return 0;
return Char->SelfData.CharName;
}
int WINAPI Char_SetCharName(HWND HWNDMain, PCHARDATA Char, char* NewCharName)
{
if (Char == NULL) return 0;
Char_LockSelfData(Char);
Char->SelfData.CharName[30] = 0;
strncpy(Char->SelfData.CharName, NewCharName, 30);
Char_UnLockSelfData(Char);
SendMessage(HWNDMain, MY_MESSAGE, CWM_OnCHAR_NAME_CHANGED, (LPARAM) NewCharName);
return 1;
}
DWORD WINAPI Char_GetCharID(PCHARDATA Char)
{
if (Char == NULL) return 0;
return Char->SelfData.CharID;
}
int WINAPI Char_SetCharID(HWND HWNDMain, PCHARDATA Char, DWORD NewCharID)
{
if (Char == NULL) return 0;
Char_LockSelfData(Char);
Char->SelfData.CharID = NewCharID;
Char_UnLockSelfData(Char);
SendMessage(HWNDMain, MY_MESSAGE, CWM_OnCHAR_ID_CHANGED, (LPARAM) NewCharID);
return 1;
}
Here is my character.def file:
; This file was generated by the Win32 DLL Wizard.
; Syntax:
;
; NAME [appname]
; LIBRARY [libname]
; BASE address
; DESCRIPTION "text"
; STACKSIZE reserve[,commit]
; HEAPSIZE reserve[,commit]
; SECTIONS
; name [{EXECUTE|READ|WRITE|SHARED}]
; EXPORTS
; entryname[=internalname] [@ordinal] [DATA]
; VERSION major[.minor]
LIBRARY "character"
EXPORTS
;# Work with Self Data #;
Char_GetCharName
Char_SetCharName
Char_GetCharID
Char_SetCharID
The most interesting - if I 'm comment function Char_SetCharID (at character.def file) - library compiles with any errors.
Who can explain me were is mistake?
I don't know if this has to do with your problem, but ..
Quote from: "Mouse"
Here is my character.h file:
/*Work with Self Data/*
has a wrong comment end.
mtx500, not this problem.
/*Work with Self Data/*
I'm mistaked when post topic.
Quote from: "Mouse"mtx500, not this problem.
/*Work with Self Data/*
I'm mistaked when post topic.
Mouse, you could try making the def file like this. Where @12 is the number of bytes passed to the function.
EXPORTS
"Char_SetCharName"=_Char_SetCharName@12
etc.
John
Quote from: "JohnF"number of bytes
What is this bytes? How can I calculate it?
Quote from: "Mouse"Quote from: "JohnF"number of bytes
What is this bytes? How can I calculate it?
example
int FuncName(char * str, int var)
{
}
(char *) is 4 bytes
(int) is 4 bytes
Total 8 bytes
EXPORT
"FuncName"=_FuncName@8
John
Writing export of first tree functions:
"Char_GetCharName" = Char_GetCharName@4
"Char_SetCharName" = Char_SetCharName@12
"Char_GetCharID" = Char_GetCharID@4
and see:
Building dllmain.obj.
Building charslist.obj.
Building charmain.obj.
Building selfdata.obj.
Building selfdata_work.obj.
Building character.dll.
Creating object: D:\_pellesc\Projects\Work\Character\character.exp
Creating library: D:\_pellesc\Projects\Work\Character\character.lib
Done.
And when I'm add to export my fourth function:
"Char_GetCharName" = Char_GetCharName@4
"Char_SetCharName" = Char_SetCharName@12
"Char_GetCharID" = Char_GetCharID@4
"Char_SetCharID" = Char_SetCharID@12
I see:
Building dllmain.obj.
Building charslist.obj.
Building charmain.obj.
Building selfdata.obj.
Building selfdata_work.obj.
Building character.dll.
POLINK: fatal error: -3 unresolved external(s).
*** Error code: 1 ***
Done.
As an test I added this to one of my DLL's
typedef struct tagCHARDATA
{
char * CharName;
DWORD CharID;
}CHARDATA, *PCHARDATA;
char * WINAPI Char_GetCharName(PCHARDATA Char);
int WINAPI Char_SetCharName(HWND HWNDMain, PCHARDATA Char, char *NewCharName);
DWORD WINAPI Char_GetCharID(PCHARDATA Char);
int WINAPI Char_SetCharID(HWND HWNDMain, PCHARDATA Char, DWORD NewCharID);
char * WINAPI Char_GetCharName(PCHARDATA Char)
{
if (Char == NULL)
return 0;
return "OK";
}
int WINAPI Char_SetCharName(HWND HWNDMain, PCHARDATA Char, char *NewCharName)
{
if (Char == NULL)
return 0;
return 1;
}
DWORD WINAPI Char_GetCharID(PCHARDATA Char)
{
if (Char == NULL)
return 0;
return 1;
}
int WINAPI Char_SetCharID(HWND HWNDMain, PCHARDATA Char, DWORD NewCharID)
{
if (Char == NULL)
return 0;
return 1;
}
Then added this to the def file.
"Char_GetCharName" = _Char_GetCharName@4
"Char_SetCharName" = _Char_SetCharName@12
"Char_GetCharID" = _Char_GetCharID@4
"Char_SetCharID" = _Char_SetCharID@12
All compiled ok.
John