LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

c++ dll load problem for usrp1.

Hello,

I am making a program that USRP1 can work with Labview 2011 using “call library function”. The main program of USRP1’s software is usrp hardware driver (UHD) which includes uhd.dll file with several example exe files. Also, they open all source files which written C++. However, I am totally new in C++.

So I need some help to do work with this.

 

Here is the source code of the USRP example program which just find the device and return the serial number.

 

--------------------------------------------------------------------------------------------------------------------------------------

#include <uhd/utils/safe_main.hpp>

#include <uhd/device.hpp>

#include <boost/program_options.hpp>

#include <boost/format.hpp>

#include <iostream>

#include <cstdlib>

 

namespace po = boost::program_options;

 

int UHD_SAFE_MAIN(int argc, char *argv[]){

    po::options_description desc("Allowed options");

    desc.add_options()

        ("help", "help message")

        ("args", po::value<std::string>()->default_value(""), "device address args")

    ;

 

    po::variables_map vm;

    po::store(po::parse_command_line(argc, argv, desc), vm);

    po::notify(vm);

 

    //print the help message

    if (vm.count("help")){

        std::cout << boost::format("UHD Find Devices %s") % desc << std::endl;

        return EXIT_FAILURE;

    }

 

    //discover the usrps and print the results

    uhd::device_addrs_t device_addrs = uhd::device::find(vm["args"].as<std::string>());

 

    if (device_addrs.size() == 0){

        std::cerr << "No UHD Devices Found" << std::endl;

        return EXIT_FAILURE;

    }

 

    for (size_t i = 0; i < device_addrs.size(); i++){

        std::cout << "--------------------------------------------------" << std::endl;

        std::cout << "-- UHD Device " << i << std::endl;

        std::cout << "--------------------------------------------------" << std::endl;

        std::cout << device_addrs[i].to_pp_string() << std::endl << std::endl;

        //uhd::device::make(device_addrs[i]); //test make

    }

 

    return EXIT_SUCCESS;

}

----------------------------------------------------------------------------------------------

 

At first, I checked the function name of UHD.dll and dependency of this exe file using dependency work program.  The function name shows

 

“??0device_addr_t@uhd@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z “

Like this.. But when I double click this, I can see

“uhd::device_addr_t::device_addr_t” 

 

1.jpg

 

 

However, if I put “uhd::device_addr_t::device_addr_t” in function name in call library node, I cannot run my vi due to node cannot find function name. If I put  “??0device_addr_t@uhd@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z “,  I am then enable to run the vi. But return 1097 error.

 

 

Anyway, I keep working to check manual of the uhd.dll’s class using

 

http://files.ettus.com/manual/classuhd_1_1device__addr__t.html

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------

Detailed Description

Mapping of key/value pairs for locating devices on the system. When left empty, the device discovery routines will search all available transports on the system (ethernet, usb...).

To narrow down the discovery process to a particular device, specify a transport key/value pair specific to your device.

  • Ex, to find a usrp2: my_dev_addr["addr"] = [resolvable_hostname_or_ip]

The device address can also be used to pass arguments into the transport layer control to set (for example) buffer sizes.

An arguments string, is a way to represent a device address using a single string with delimiter characters.

  • Ex: addr=192.168.10.2
  • Ex: addr=192.168.10.2, recv_buff_size=1e6

Constructor & Destructor Documentation

uhd::device_addr_t::device_addr_t ( const std::string &  args = "" )  

Create a device address from an args string.

Parameters
args the arguments string

 

Member Function Documentation

template<typename T >
T uhd::device_addr_t::cast ( const std::string &  key,
    const T &  def 
  )   const
inline

Lexically cast a parameter to the specified type, or use the default value if the key is not found.

Parameters
key the key as one of the address parameters
def the value to use when key is not present
Returns
the casted value as type T or the default
Exceptions
error when the parameter cannot be casted
std::string uhd::device_addr_t::to_pp_string ( void    ) const

Convert a device address into a pretty print string.

Returns
a printable string representing the device address
std::string uhd::device_addr_t::to_string ( void    ) const

Convert the device address into an args string. The args string contains delimiter symbols.

Returns
a string with delimiter markup
-------------------------------------------------------------------------------------------------------------------------------------------
From here.. I have totally no idea what can I do.. It seems find "std::string uhd::device_addr_t::to_string" and "std::string uhd::device_addr_t::to_pp_string" function, and call these first and the return value of these function use as the input of function, " uhd::device_addr_t::device_addr_t" .
But still it shows the error message.
Please help to solve this problem..
Regards,
Anthony
0 Kudos
Message 1 of 4
(3,533 Views)
You need to find a c++ forum. This is for a programming language called LabVIEW.
0 Kudos
Message 2 of 4
(3,520 Views)

I am going to make a post in MSDN, but basically, I am making Labview program to use "call dll library function node". I already checked several posts and documantation, but still I am struggling to use this function.

 

That's why I asked here.

 

Thanks. 

 

0 Kudos
Message 3 of 4
(3,507 Views)

The uhd API seems to be C++ (uhd:: namespace)!! The Call Library Node can not directly interface to C++ since there is no commonly accepted ABI standard for C++, each compiler uses its own ABI specification. You would have to get a standard C wrapper for the uhd interface in DLL form in order to access it with the Call Library Node. Maybe your uhd library also provides that but it is not very likely and in that case you would have to create the wrapper DLL yourself, which requires you to write C code and use a C++ compiler.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(3,482 Views)