NO

Author Topic: POLINK: error: Unresolved external symbol '_RomRec'.  (Read 4059 times)

gilliandell

  • Guest
POLINK: error: Unresolved external symbol '_RomRec'.
« on: August 15, 2015, 07:42:03 AM »
I used to work with Pelles C many years ago, just started using it again and I get these messages.

It's a X86 Console project.

I have several extren structures and variables in my include files and while building the project I get:

POLINK: error: Unresolved external symbol '_RomRec'.
POLINK: error: Unresolved external symbol '_ItemCnt'.
POLINK: error: Unresolved external symbol '_SaleRec'.

Complier tab the setting are:
Runtime Library: Single Threaded LIB 
Calling Conv: __cdel
Optimizations: none
Inlining: Default
"Define compatibility names" is checked

Does anybody have an idea

Thanks,

Gillian

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: POLINK: error: Unresolved external symbol '_RomRec'.
« Reply #1 on: August 15, 2015, 12:29:34 PM »
If it's an old project used to compile with previous versions the problem could be the C standard C11 (you'll find it under the compiler tab of project options) that requires explicit declaration of externals.
Another reason can be  a library compiled with previous runtime version.
BTW it's better if you post a small sample exposing the problem.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

gilliandell

  • Guest
Re: POLINK: error: Unresolved external symbol '_RomRec'.
« Reply #2 on: August 15, 2015, 04:17:43 PM »
This is the include file with all the extern vars

extern int TtlSale, StateCnt, UserCnt, aa,
           ItemCnt, PromoteCnt;
extern char  buf[BufSize+1];

I put it under inside "incdir" directory under the project's root directory.

This is the include definitions in one of the programs

# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include "incdir\prg_literals.h"
# include "incdir\prg_extern_vars.h"



gilliandell

  • Guest
Re: POLINK: error: Unresolved external symbol '_RomRec'.
« Reply #3 on: August 15, 2015, 04:31:53 PM »
After building you can see these vars as unresolved.

POLINK: error: Unresolved external symbol '_ItemCnt'.
POLINK: error: Unresolved external symbol '_buf'.
POLINK: error: Unresolved external symbol '_TtlSale'.
POLINK: error: Unresolved external symbol '_UserCnt'.

gilliandell

  • Guest
Re: POLINK: error: Unresolved external symbol '_RomRec'.
« Reply #4 on: August 15, 2015, 07:19:24 PM »
I started a new X86 Console project called "test".

Complier settings are:
Runtime Library: Single Threaded LIB
Calling Conv: __cdel
Optimizations: maximum speed
Inlining: Default
C standard: C11
"Define compatibility names" is checked


It has one program - main.c and on include file - extern_vars.h

main.c
--------

# include <stdio.h>
# include <stdlib.h>
# include "extern_vars.h"


int main (void)
{

  ItemCnt = 0;
   
}


extern_vars.h
------------------

extern int ItemCnt;


When building the project I get the same message:

Building main.obj.
Building test.exe.
POLINK: error: Unresolved external symbol '_ItemCnt'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.



Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: POLINK: error: Unresolved external symbol '_RomRec'.
« Reply #5 on: August 16, 2015, 01:47:00 AM »
Is not enough to declare as external a variable, you have also instantiate them.
On old compilers the extern variables were created in the common section during linking. Actually new standard compliance don't accept undefined variables.
See the example attached. We have 3 files:
Main.h
Code: [Select]
#include <stdio.h>
#include "extern_vars.h"

int main(int argc, char *argv[])
{
printf("The variable ItemCnt contains %d\n", ItemCnt);
return 0;
}

The include file "extern_vars.h"
Code: [Select]
extern int ItemCnt; //Here we only declare it as extern
And "instantiate.c"
Code: [Select]
#include <stdio.h>
#include "extern_vars.h"

int ItemCnt = 10; //Here we instantiate the variable

You can instantiate the variable in only one of the source files (.c) where you use them.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

gilliandell

  • Guest
Re: POLINK: error: Unresolved external symbol '_RomRec'.
« Reply #6 on: August 16, 2015, 03:26:58 AM »
Thanks a lot, that helped.
I also have an extern structure defined inside an include file, how do i instantiate it?

static struct Site
{
 char Sign[10];
 char Name[10];
 char StateName[StateSize + 1];
 char StateCode[StateCodeSize + 1];
 char SiteURL[SiteUrlSize + 1];
};
extern struct Site SiteRec[10];

gilliandell

  • Guest
Re: POLINK: error: Unresolved external symbol '_RomRec'.
« Reply #7 on: August 16, 2015, 03:47:21 AM »
I think i've managed to instantiate the extern structure.

I wrote this line inside instantiate.c

struct Site SiteRec[10];

Thanks,
Gillian

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: POLINK: error: Unresolved external symbol '_RomRec'.
« Reply #8 on: August 16, 2015, 01:28:12 PM »
I'm happy you solved.
You're welcome.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide