NO

Author Topic: POLINK: error: Unresolved external symbol  (Read 5926 times)

Mouse

  • Guest
POLINK: error: Unresolved external symbol
« on: October 25, 2005, 12:22:15 PM »
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:
Code: [Select]

#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:
Code: [Select]

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:
Code: [Select]

; 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?

mtx500

  • Guest
Re: POLINK: error: Unresolved external symbol
« Reply #1 on: October 25, 2005, 12:51:46 PM »
I don't know if this has to do with your problem, but ..

Quote from: "Mouse"

Here is my character.h file:
Code: [Select]

/*Work with Self Data/*



has a wrong comment end.

Mouse

  • Guest
POLINK: error: Unresolved external symbol
« Reply #2 on: October 25, 2005, 12:55:42 PM »
mtx500, not this problem.

Code: [Select]

/*Work with Self Data/*

I'm mistaked when post topic.

JohnF

  • Guest
POLINK: error: Unresolved external symbol
« Reply #3 on: October 25, 2005, 04:56:26 PM »
Quote from: "Mouse"
mtx500, not this problem.

Code: [Select]

/*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

Mouse

  • Guest
POLINK: error: Unresolved external symbol
« Reply #4 on: October 25, 2005, 09:55:05 PM »
Quote from: "JohnF"
number of bytes

What is this bytes? How can I calculate it?

JohnF

  • Guest
POLINK: error: Unresolved external symbol
« Reply #5 on: October 25, 2005, 11:12:44 PM »
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

Mouse

  • Guest
POLINK: error: Unresolved external symbol
« Reply #6 on: October 26, 2005, 07:48:12 AM »
Writing export of first tree functions:
Code: [Select]

"Char_GetCharName" = Char_GetCharName@4
"Char_SetCharName" = Char_SetCharName@12
"Char_GetCharID" = Char_GetCharID@4

 and see:
Code: [Select]

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:
Code: [Select]

"Char_GetCharName" = Char_GetCharName@4
"Char_SetCharName" = Char_SetCharName@12
"Char_GetCharID" = Char_GetCharID@4
"Char_SetCharID" = Char_SetCharID@12

I see:
Code: [Select]

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.

JohnF

  • Guest
POLINK: error: Unresolved external symbol
« Reply #7 on: October 26, 2005, 08:30:45 AM »
As an test I added this to one of my DLL's

Code: [Select]

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