Mlagma
Mlagma

Reputation: 1260

Unresolved external symbols in Visual Studio 2013 when using UHD

I can't seem to get a very simple program to compile in Visual Studio 2013. My goal is to incorporate UHD into a C++ program (UHD Driver and Libraries for Windows). I downloaded and installed the Windows UHD package.Since the library also depends on Boost, I also downloaded the appropriate Boost library. After that, I wrote a quick test program in Visual Studio 2013:

#include "stdafx.h"
#include <iostream>
#include <uhd\usrp\multi_usrp.hpp>
#include <uhd\types\device_addr.hpp>

using namespace uhd;

int main(void)
{
   device_addr_t hint;
   device_addrs_t dev_addrs = device::find(hint);
   system("pause");
   return 0;
}

In case anyone is interested, this program should locate any USRPs attached to a host PC. I defined the appropriate include paths in Visual Studio: Include Paths. Library Include Paths.

To be clear, I included two paths to the header files: C:\Program Files (x86)\UHD\include and C:\Program Files (x86)\boost_1_55_0

and one path to the library: C:\Program Files (x86)\UHD\lib

When I wrote the above program, Visual Studio recognized the additional include files, recognized device_addr_t as a typedef, and didn't throw any errors. However, when I built the program, I received these errors:

Error   3   error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class std::vector<class uhd::device_addr_t,class std::allocator<class uhd::device_addr_t> > __cdecl uhd::device::find(class uhd::device_addr_t const &)" (__imp_?find@device@uhd@@SA?AV?$vector@Vdevice_addr_t@uhd@@V?$allocator@Vdevice_addr_t@uhd@@@std@@@std@@ABVdevice_addr_t@2@@Z) referenced in function _main    C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj   uhd_test

Error   2   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall uhd::device_addr_t::~device_addr_t(void)" (__imp_??1device_addr_t@uhd@@QAE@XZ) referenced in function "public: void * __thiscall uhd::device_addr_t::`scalar deleting destructor'(unsigned int)" (??_Gdevice_addr_t@uhd@@QAEPAXI@Z) C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj   uhd_test

Error   1   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall uhd::device_addr_t::device_addr_t(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0device_addr_t@uhd@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main   C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj   uhd_test


Error   4   error LNK1120: 3 unresolved externals   C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\Debug\uhd_test.exe  uhd_test

I've encountered these errors before in other programs, but I was able to resolve them relatively easily; either I would misspell a crucial include, or there would be an issue with a template class. However, in this instance, I can't seem to resolve the issue.

Any constructive input would be appreciated.

NOTE: In addition to defining the library directory path, I've explicitly added the UHD library, and I receive the same errors.

Upvotes: 2

Views: 1850

Answers (2)

mgarey
mgarey

Reputation: 752

I followed exactly what David Greene said, and I ended up with the same errors. Eventually I figured out that I had downloaded the 64-bit UHD, but I was using Visual Studio 2013 Express, which was a 32-bit compiler. Downloading the 32-bit version of UHD for Visual Studio 2013 solved the problem. For anyone else having this problem, double check that the compiler matches which version of UHD you install.

Upvotes: 0

dgreene
dgreene

Reputation: 235

I got your example working. Here's the software versions I used since you didn't mention much in your description:

  • Microsoft Visual Studio 2013
  • VC++ Redistributable Package for VS2013 (vcredist_x86)
  • UHD 003.007.002, VS2013, Win32
  • Boost 1.56, lib32-msvc-12.0 binary package

Here are the project configuration properties you need to set in your VS2013 applications:

C/C++ -> General -> Additional Include Directories

  • C:\local\boost_1_56_0
  • C:\Program Files (x86)\uhd\include

Linker -> General -> Additional Library Directories

  • C:\local\boost_1_56_0\lib32-msvc-12.0
  • C:\Program Files (x86)\uhd\lib

Linker -> Input -> Additional Dependencies

  • uhd.lib

I think the last step is what's tripping you up, good luck!

Upvotes: 4

Related Questions