Page 1 of 1

C library linkage problem

Posted: Thu Jun 04, 2009 3:53 pm
by kkennett
I wrote this simple program:
______________________________

#include <stdio.h>
#include <windows.h>
#include "phidget21.h"

CPhidgetAccelerometerHandle theAccel;

int main(int argc, char **argv)
{
int err = CPhidgetAccelerometer_create(&theAccel);
if (err)
{
printf("Error = %d during create.\r\n",err);
return -1;
}

CPhidget_close((CPhidgetHandle)theAccel);

return 0;
}
______________________________

When I built it I get:

1>Linking...
1>main.obj : error LNK2019: unresolved external symbol __imp__CPhidget_close@4 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__CPhidgetAccelerometer_create@4 referenced in function _main
1>C:\Dev\phid1\Debug\phid1.exe : fatal error LNK1120: 2 unresolved externals

I looked in the phidget21.h header, and see:

__declspec (dllimport)
int __stdcall CPhidgetAccelerometer_create (CPhidgetAccelerometerHandle * phid);

using __stdcall will make the export as indicated in the error message.

Did I do something wrong or is the library linked differently from what its header says it is linked as.

Re: C library linkage problem

Posted: Thu Jun 04, 2009 5:12 pm
by kkennett
ok. my bad.

i was trying to link a 32-bit program with the 64-bit libraries.

sorry!~