NO

Author Topic: Linker problem  (Read 2929 times)

Grincheux

  • Guest
Linker problem
« on: December 30, 2014, 08:34:29 PM »
Here is my problem !

Code: [Select]
#define WIN32_LEAN_AND_MEAN  /* speed up compilations */
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <tchar.h>
#include "SpiceUsr.h"
#include "main.h"


#define NELEMS(a)  (sizeof(a) / sizeof((a)[0]))


static void Main_OnPaint(HWND hwnd)
{
    PAINTSTRUCT ps;
    RECT rc;
HDC _hDC ;


char _szTmp[256] ;
int _iLen;


ConstSpiceChar  * versn;
versn = tkvrsn_c( "TOOLKIT" );
_iLen = wsprintf(_szTmp,"Toolkit version %s\n", versn );


    _hDC = BeginPaint(hwnd, &ps);
    GetClientRect(hwnd, &rc);
    TextOut(_hDC,150,200,_szTmp,_iLen) ;
    EndPaint(hwnd, &ps);
}
I use the NASA CSPICE toolkit in 64 bit version.
When linking I added the LIBCMT.lib library but I get the following errors :
Code: [Select]
Building main.obj.
Building main.res.
Building Spice Version.exe.
POLINK: error: Unresolved external symbol 'access'.
POLINK: error: Unresolved external symbol 'mktemp'.
POLINK: error: Unresolved external symbol 'fileno'.
POLINK: error: Unresolved external symbol 'isatty'.
POLINK: fatal error: 4 unresolved external(s).
*** Error code: 1 ***
Done.
I read a thread about linking errors but nothing solves my problem.

Please help me.
« Last Edit: December 30, 2014, 08:36:16 PM by Grincheux »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2097
Re: Linker problem
« Reply #1 on: December 30, 2014, 11:44:07 PM »
Have you used the old names compatibility switch on compiler?
These are not standard C functions so are defined with a prepended underscore, i.e. _access for access, _mktemp for mktemp etc
Enabling the switch /Go lets the compiler accept the other form.
What is not clear is if the wrong definitions are in your files or in the NASA toolkit, are you linking with other object files compiled with pellesc or precompiled?
If everything is compiled in PellesC (toolkit and apps) using the switch should solve the problem, if you are using precompiled static libs to solve the problem you have to code stub routines:
Code: [Select]
//Example for access
int access(const char *name, int mode)
{
        return _access(name, mode);
}

....     //do the same for the other missing functions
In this case the code will link to your routines.
If you are using precompiled DLL's (as seems the case because there is no underscore) you have to rebuild the stub library of DLL adding aliases for the missing routines pointing to the right functions. In basic you need a DEF file from DLL where manually add the functions making them point to the equivalent function. There should be some example from TimoVjl around.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide