3

I am trying to use a software development kit to control a cMOS camera. The library which contains all of the functions to control the camera is called atcorem.lib. I have been trying to compile and link an example file included in the SDK which is supposed to print the serial number of the camera.

I've set things up in a Visual Studio 2013 console project, including pointing the project to Additional Include Directories, and the linker to Additional Library Directories, and Additional Dependencies. My code looks like this:

#include "stdafx.h"
#include "atcore.h"
#include <iostream> 

using namespace std;

int main(int argc, char* argv[])
{
    int i_retCode;
    cout << "Initialising ..." << endl << endl;
    i_retCode = AT_InitialiseLibrary();
    if (i_retCode != AT_SUCCESS) {
        cout << "Error initialising library" << endl << endl;
    }
    else {
        AT_64 iNumberDevices = 0;
        AT_GetInt(AT_HANDLE_SYSTEM, L"Device Count", &iNumberDevices);
        if (iNumberDevices <= 0) {
            cout << "No cameras detected" << endl;
        }
    }
    AT_FinaliseLibrary();
    return 0;
}

When I try to build, the program compiles, but I receive three lnk2019 unresolved external dependencies errors.

1>ConsoleApplication1.obj : error LNK2019: unresolved external symbol _AT_InitialiseLibrary@0 referenced in function _main
1>ConsoleApplication1.obj : error LNK2019: unresolved external symbol _AT_FinaliseLibrary@0 referenced in function _main
1>ConsoleApplication1.obj : error LNK2019: unresolved external symbol _AT_GetInt@12 referenced in function _main
1>C:\Users\CAMERA1\Documents\Visual Studio 2013\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe : fatal error LNK1120: 3 unresolved externals 

From using the /Verbose option with the linker, I know that it looks at atcorem.lib when it tries to resolve the functions, but doesn't seem to find them there.

Unused libraries:
1>    C:\Users\CAMERA1\Desktop\temp\SDK3\atcorem.lib
1>    C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib

etc.

From searching the web and various forums, I understand that C++ calling conventions can sometimes cause problems. These are new to me, so I've tried to play with them to understand if that is a problem here. The atcorem.h header uses WINAPI, and I can see from the _fun@ format that the linker is looking for these functions as __stdcall.

In atcorem.h, this looks like

#if defined(__WIN32__) || defined(_WIN32)
#include <windows.h>
#define AT_EXP_CONV WINAPI
#else 
#define AT_EXP_CONV
#endif

int AT_EXP_CONV AT_ex_format_function();

Which seems ok, based on claims that WINAPI uses __stdcall.

I have more information about the atcorem.lib from using dumpbin which I can provide if that is helpful.

Any help would be greatly appreciated. Thank you!

edit: Part of the dumpbin output. edit2: Dump of copy of atcorem.lib in desktop/temp/SDK3 directory.

Microsoft (R) COFF/PE Dumper Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file C:/Users/Camera1/Desktop/temp/SDK3\atcorem.lib

File Type: LIBRARY

Archive member name at 8: /               
54B6F19F time/date Wed Jan 14 17:45:51 2015
     uid
     gid
   0 mode
 862 size
correct header end

89 public symbols

 114E __IMPORT_DESCRIPTOR_atcore
 1374 __NULL_IMPORT_DESCRIPTOR
 14AA atcore_NULL_THUNK_DATA
 2322 AT_QueueBuffer
 2322 __imp_AT_QueueBuffer
 27CC AT_WaitBuffer
 27CC __imp_AT_WaitBuffer
 16CC AT_FillBufferMode
 16CC __imp_AT_FillBufferMode
 1E5A AT_InitialiseLibrary
 1E5A __imp_AT_InitialiseLibrary
 173A AT_FinaliseLibrary
 173A __imp_AT_FinaliseLibrary

...

ptbrown
  • 101
  • 2
  • 10
  • try `#pragma comment(lib, "C:\\Users\\CAMERA1\\Desktop\\temp\\SDK3\\atcorem.lib")` – Axalo Feb 01 '15 at 19:22
  • @Axalo, I tried adding this just below #include's above, but it didn't change the error. – ptbrown Feb 01 '15 at 19:30
  • Then `AT_InitialiseLibrary` and such are not defined in `atcorem.lib`. It's probably the wrong .lib or you simply missed one. – Axalo Feb 01 '15 at 19:32
  • @Axalo, I've added part of the output of dumpbin to my post which indicates (I think) that the function is in the library. I'm not sure I understand. Missed one of what? edit: note that I've copied the library to a different location since I used the dumpbin utility. – ptbrown Feb 01 '15 at 19:54
  • There are apparently two `atcorem.lib`s. `C:/Program Files\Andor SDK3\atcorem.lib` (the one you dumped) and `C:\Users\CAMERA1\Desktop\temp\SDK3\atcorem.lib` (which you should dump) – Axalo Feb 01 '15 at 20:04
  • Hi @Axalo, that is because I've copied the contents of the Andor SDK3 folder to my desktop to play with. I've edited my post to include the dump of the atcorem.lib that is actually being used. – ptbrown Feb 01 '15 at 20:10
  • I'm out of ideas but I found [this question](http://stackoverflow.com/questions/22686709/unresolved-external-symbol-but-dumpbin-says-its-ok) which seems to be similar to yours. – Axalo Feb 01 '15 at 20:16
  • The .lib file is only suitable for x64 projects. If you need to build the 32-bit version then you'll have to ask the owner for an updated .lib and .dll – Hans Passant Feb 02 '15 at 01:07
  • @HansPassant I believe I also have a 32-bit version of this library. I do not know very much about this. What am I doing above to specify 32-bit in the build? It sounds like maybe I need to do some more reading. – ptbrown Feb 02 '15 at 04:48
  • @HansPassant, direction Visual Studio to the 32-bit version of the library fixed the problem. My program now links. Thank you for your suggestion. – ptbrown Feb 02 '15 at 14:37

0 Answers0