# NodeHandle initRemappings() error (win_ros)

I'm trying to run my first MSVC-compiled ROS project by following the instructions from here: http://wiki.ros.org/win_ros/hydro/Msv...

The project involves building the 'hello world' talker from source - pretty straightforward.

I'm using Visual Studio Express 2012. I've been very careful to follow all the suggestions as far as project settings go. Yes, ROS_MASTER_URI is defined. The project compiles and links just fine, both in Debug and Release configurations. However, when I run the Release version from Visual Studio, I get an "access violation reading location 0x0" error with the following stack trace:

roscpp.dll!ros::NodeHandle::initRemappings(const std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > & remappings) Line 195 C++

roscpp.dll!ros::NodeHandle::NodeHandle(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & ns, const std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > & remappings) Line 85 C++

RosSample.exe!main(int argc, char * * argv) Line 64 C++

msvcr110.dll!_initterm(void (void) * * pfbegin, void (void) * * pfend) Line 889 C


This is my source code, minus all the lengthy comments (Line 64 in the above stack trace refers to the ros::NodeHandle n; statement):

#include "stdafx.h"
#include "ros/ros.h"
#include "std_msgs/String.h"

int main(int argc, char **argv)
{
ros::init(argc, argv, "talker");

ros::NodeHandle n;

ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);

ros::Rate loop_rate(10);

int count = 0;
while (ros::ok())
{

std_msgs::String msg;

std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();

ROS_INFO("%s", msg.data.c_str());

chatter_pub.publish(msg);

ros::spinOnce();

loop_rate.sleep();

++count;
}
return 0;
}


Looking at the NodeHandle source code ( http://docs.ros.org/diamondback/api/r... ), the only things that I can begin to suspect are references to the remappings map in the NodeHandle constructor and initRemappings function, but that map should have been created using the M_String default constructor.

BTW, I tried running the Debug configuration build of my project and that one fails too, but even earlier, inside ros::init().

Any help greatly appreciated!

EDIT: win_ros explicitly mentions that it is "for native Windows development with the Microsoft Visual C++ Compilers 2010. Currently supporting either Windows SDK 7.1 (cl/nmake) or Visual Studio 10.0." I suspect this may be my problem, since I'm using VS 2012. Someone on here had a similar problem that was fixed by changing to the VS2010 platform toolset. I've yet to try that, but I ...

edit retag close merge delete