NO

Author Topic: POLINK: error: Unresolved external symbol 'function-name'  (Read 3761 times)

towersb

  • Guest
POLINK: error: Unresolved external symbol 'function-name'
« on: June 30, 2016, 09:56:57 AM »
I am trying to build a prototype application using one main program and (so far) three external functions.  Each module is defined as a project in one workspace and the three external function projects in the workspace are set as dependent on the main program.  Each function signature has a header file and those header files are included in the main program.  All the modules compile separately.  However when building the workspace from the main program I always get POLINK errors stating that the external functions are unresolved.  All of the prototype function programs/methods are simple stubs.  The workspace display shows all of the programs in the display.  What am I doing wrong?  How can I get the linker to resolve the external function calls from the main program?   I have looked at the Pelles C help but cannot find an answer or a sample to work from. Any help is appreciated. Thanks in advance.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: POLINK: error: Unresolved external symbol 'function-name'
« Reply #1 on: June 30, 2016, 01:11:54 PM »
Post a simple minimal project that shows your problem.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Scripter

  • Guest
Re: POLINK: error: Unresolved external symbol 'function-name'
« Reply #2 on: June 30, 2016, 01:33:45 PM »
I am trying to build a prototype application using one main program and (so far) three external functions.  Each module is defined as a project in one workspace and the three external function projects in the workspace are set as dependent on the main program.  Each function signature has a header file and those header files are included in the main program.  All the modules compile separately.  However when building the workspace from the main program I always get POLINK errors stating that the external functions are unresolved.  All of the prototype function programs/methods are simple stubs.  The workspace display shows all of the programs in the display.  What am I doing wrong?  How can I get the linker to resolve the external function calls from the main program?   I have looked at the Pelles C help but cannot find an answer or a sample to work from. Any help is appreciated. Thanks in advance.

In all likelihood it's not drawing upon the correct libraries. If you are including Windows.h in your project there are dozens of them...

In each project open the Project Options panel ...
On the main tab make sure to enable Pelles C and Microsoft extensions.

For 32 bit projects using libraries you probably want the calling convention set to STDCALL and FASTCALL for 64bit.

On the compiler tab in "Define Preprocessor Symbols" add .. WIN32_DEFAULT_LIBS

Then try it again.

The WIN32_DEFAULT_LIBS is a Pelles C specific trick that will automatically link with the correct libraries when you include one of the Windows headers.

A better plan than relying upon the project settings is to specify the calling convention in each of your library functions, like this...
Code: [Select]

In the header...
INT _stdcall Snastic(INT A, INT B);

In the library...
INT _stdcall Snastic(INT A, INT B)
  {
     return A + B;
   }