Author Topic: Simple Implicit linking of a .lib file ...  (Read 5707 times)

Offline kccasey

  • Single posting newcomer
  • *
  • Posts: 6
Simple Implicit linking of a .lib file ...
« on: March 01, 2012, 08:13:36 pm »
First .. this code blocks is excellent .... many kudos to the writers.

This is a shortened version of my program that I would like to build and run in code blocks version 10.5
I have added RP2005 to Project\build settings\Linker Settings.
I have added the path that contains the .h and .lib to the Search directories .. under every tab.

Currently I am getting the error
obj\Release\main.o:main.cpp:(.text.startup+0x26) || undefined reference to `RP_OpenDIO(char*, unsigned long*)@8'

Seems the method signature matches the one in the .h file.
I do not know what compiler my .LIB was compiled on .... wonder if I simply cannot use that .LIB?
I have RP2005.lib and RP2005.h in the same directory of the main source file.

This line is in RP2005.h
__declspec(dllexport) unsigned long __stdcall RP_OpenDIO(char *SN, unsigned long *hDIO);

#include "RP2005.h"
unsigned long hDIO;
char mystring2[] = "RP0000HV";
int main()
{
    RP_OpenDIO( mystring2 , &hDIO);
    return 0;
}

any suggestions on how I can make this work?

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Simple Implicit linking of a .lib file ...
« Reply #1 on: March 02, 2012, 04:07:51 pm »
The error comes from the linker. The source has compiled okay, so that the header file has been found. Possible causes for the error:
(1) The library has not been found. How did you add the library to the linker settings? Use the "..." and add using the Open File dialog. This will ensure that add the library along with the path and drive. Also, you will be sure that the library is there.
(2) The library does not contain RP_OpenDIO(), at lest, it does not contain it for your compiler and linker. This can be caused by different name mangilg used by the compiler that compiled the library. Look at the hex listing of the library and search "RP_OpenDIO@8". It must not be "_RP_OpenDIO@8" or "RP_OpenDIO_@8" or something similar.