Strange linker behaviour

Hello!

I'm encountering an issue i can't solve on my own. The problem in a nut shell: I got a class LiveReceiver with a static member method LoadLibrary(), which i have to call in order to initialize a given library. However, when i invoke the method, the linker complains about the method LoadLibraryA() does not exist.

Here're some code fragments.

The declaration of the class
1
2
3
4
5
6
7
8
9
class LiveReceiver
{
public:

    /**
    @brief	In order to use this class, you need to load the library once before
    @return	true on success, otherwise false
    */
    static bool             LoadLibrary();


Implementation of the method LoadLibrary()
1
2
3
4
5
6
7
8
bool LiveReceiver::LoadLibrary()
{
    if ( IC_InitLibrary(0) == IC_SUCCESS )
        libraryLoaded = true;
    else
        libraryLoaded = false;
    return libraryLoaded;
}


Invokation of the method
1
2
3
4
5
6
7
8
9
10
11
12
LiveReceiver* InitCam()
{
    LiveReceiver::LoadLibrary();
    LiveReceiver* receiver = LiveReceiver::Create(const_cast<char*>(CAM_NAME.c_str()));
    if ( receiver )
    {
        receiver->setColorFormat(Y800);
        receiver->setVideoFormat(const_cast<char*>(CAM_MODE.c_str()));
        receiver->enable();
    }
    return receiver;
}


And the linker output. Line 83 is where the method is called in the code snippet above.

obj\Debug\7_Systemtest\DynamicTest\DynamicTest.o||In function `Z7InitCamv':|
C:\Users\...\DynamicTest\DynamicTest.cpp|83|undefined reference to `LiveReceiver::LoadLibraryA()'|


I'm using Code::Blocks 12.11 with GNU GCC Compiler.

Strange thing is I have already used the class LiveReceiver and its method LoadLibrary for over 3 months, and it still works within other projects.

I think it wouldn't be too hard to simply create a new project and copy the content, but I wonder if someone has an explanation for the 'A' that is appended to the name of the method (seemingly for no reason).
I've already typed the name again and again, shifted the whole thing to another line, but what ever i do, the error occurs in the line where i the method is called. Thus it's not the result of some random anomaly (I think).

Asking google didn't help, because my problem is an "A" which can be found in any article ;)

Thanks in advance,
Elrat


You are including <windows.h> at some point, which has a #define macro defining LoadLibary as LoadLibraryA (because you are using a non-unicode format). Just as a side note, this is why #defines are bad. Anyway, simple fix: Change the name, or don't #include windows.h, or #undef LoadLibrary before you use the function.
LoadLibrary is a pre-processor directive which the compiler will replace with either LoadLibraryW if UNICODE is set, or LoadLibraryA. See WinBase.h I would suggest renaming your static class function to something other than ::LoadLibrary().
Last edited on
That's it! Thank you very much! :)
Topic archived. No new replies allowed.