I'm trying to use ros in cpp with Visual Studio 2012. I wrote the publisher and subscriber tutorial (http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29) and first, I configure the project as says in the guide (http://wiki.ros.org/win_ros/hydro/Msvc%20SDK%20Projects).
Then i compiled an linked the publisher, but when I tried to run it, ros::init(argc,argv,"talker") throws an exception... The console says that I ROS_MASTER_URI is not defined but I've got it defined
There are 2 images here:
https://www.dropbox.com/s/o12m0l38gaxiugi/error1.png -
https://www.dropbox.com/s/ocdmf0wj6rj0962/error.png
Can anyone helps me?
Thanks in advance
So, I had the same issue, although I didn't set the ROS_MASTER_URI globally.
I managed to get around this specific issue by adding
ROS_MASTER_URI=http://localhost:11311
to the debugging environment variables (Project->Properties->Configuration Properties->Debugging->Environment).
However, after implementing the above I got an uncaught exception (Unhandled exception at 0x768bc41f in ros_demo.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0028f0e4..).
That went away when I built, compiled and ran the project in release mode (which matched my ROS SDK build).
I got the idea for the release/debug build from here:
xstring isn't an OSG specific object, so the error is elsewhere in the
3rd party dependency chain. As I know nothing about your OS and
software setup I can't speculate what this might be.
In general though this type of error could well be a linking issue -
for instance Visual Studio is hopeless at handling different libs
being built debug and release and will crash randomly.
That was fun to discover..
Related
I would like to add a small feature to QuantLib and compile it together with SWIG bindings to use in a C# project in Visual Studio 2010. I am however having problems at almost every turn. What are the steps involved in building QuantLib in Visual Studio 2010, creating the SWIG bindings, and building the C# project?
I downloaded QuantLib from http://sourceforge.net/projects/quantlib/files/
I downloaded Boost from http://sourceforge.net/projects/boost/files/boost/1.49.0/
I downloaded the QuantLib+SWIG bindings from http://sourceforge.net/projects/quantlib/files/QuantLib/1.0/bindings/QuantLib-SWIG-1.0.zip/download
I set an environment variable QL_DIR to "C:\pathToFolder\QuantLib-1.2\lib" (computer > properties > advanced system settings > advanced > environment variables)
I ran the swig.cmd file located in C:\pathToFolder\QuantLib-SWIG-1.0\CSharp
I opened QuantLib_vc9.sln in Visual Studio 2010
For the NQuantLibc project:
I included my Boost and QuantLib directories in the header directories.
I included my QuantLib/lib directory in the library directories.
I successfully built the NQuantLibc project
For the NQuantLib_vc9 project:
I made it dependent on the NQuantLibc project.
I successfully built the NQuantLib_vc9 project.
For the EquityOption_vc9 project:
I made it dependent on the NQuantLib_vc9 project.
I successfully built the EquityOption_vc9 project.
When I try to run the EquityOption_vc9 project, I get a TypeInitializationException, "An attempt was made to load a program with an incorrect format."
Here's the full exception:
System.TypeInitializationException was unhandled
Message=The type initializer for 'QuantLib.NQuantLibcPINVOKE' threw an exception.
Source=NQuantLib
TypeName=QuantLib.NQuantLibcPINVOKE
StackTrace:
at QuantLib.NQuantLibcPINVOKE.new_Date__SWIG_1(Int32 jarg1, Int32 jarg2, Int32 jarg3)
at QuantLib.Date..ctor(Int32 d, Month m, Int32 y) in C:\Users\JRobinson\Desktop\QuantLib-SWIG-1.0\CSharp\csharp\Date.cs:line 48
at EquityOptionTest.EquityOption.Main(String[] args) in C:\Users\JRobinson\Desktop\QuantLib-SWIG-1.0\CSharp\examples\EquityOption.cs:line 43
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.TypeInitializationException
Message=The type initializer for 'SWIGExceptionHelper' threw an exception.
Source=NQuantLib
TypeName=SWIGExceptionHelper
StackTrace:
at QuantLib.NQuantLibcPINVOKE.SWIGExceptionHelper..ctor()
at QuantLib.NQuantLibcPINVOKE..cctor() in C:\Users\JRobinson\Desktop\QuantLib-SWIG-1.0\CSharp\csharp\NQuantLibcPINVOKE.cs:line 126
InnerException: System.BadImageFormatException
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=NQuantLib
StackTrace:
at [long string removed]
at QuantLib.NQuantLibcPINVOKE.SWIGExceptionHelper..cctor() in C:\Users\JRobinson\Desktop\QuantLib-SWIG-1.0\CSharp\csharp\NQuantLibcPINVOKE.cs:line 106
InnerException:
Note that I built everything with the Debug configuation. I also tried this using the Release configuration. It didn't work.
I wish I could find a complete set of instructions detailing how to build this type of project. I found some instructions here, Compiling Quantlib via SWIG for C# but i couldn't get it to work.
The QuantLib page contains instructions for building QuantLib in Visual Studio 2010, http://quantlib.org/install/vc10.shtml but I need help creating the SWIG bindings.
Resolver Systems has pre-built C# bindings that work for me. http://www.resolversystems.com/products/quantlib-binary/ I was able to run QuantLib code in C# just fine with this package. My problem is that I need to add a small feature to the QuantLib code for use in my C# project. This is the reason I need to re-build QuantLib and re-create the SWIG bindings.
I know about QLNet, the C# port of QuantLib, http://sourceforge.net/projects/qlnet/, but this project is missing some pieces and I think that it is no longer being actively developed. Specifically, I need to be able to price options that pay discrete dividends. QLNet is missing some of the code for this. I tried porting the necessary code from QuantLib to QLNet, but my C++ must be rusty because I was getting incorrect output.
Note that the small feature I need to add to QuantLib is the ability to handle fractional days. I was able to add this feature to QLNet, and it is a small feature indeed. This tiny edit is delaying my project. I would greatly appreciate help on this issue.
There indeed seems to be a problem with the SWIG wrappers as distributed and .Net 4.0.
I'm not working on that platform, so I can't speak based on personal experience. However, the issue was discussed recently on the QuantLib mailing list, and the solution contributed there by Mark Gillis was reported to work. You can read the relevant thread at http://thread.gmane.org/gmane.comp.finance.quantlib.user/8238. Hope this helps...
I struggled with this exact error message a little while back, and visited this page, as Google search might say, "many times".
In the end, my error was fairly benign, but it took me a while to sort it out.
I was using C# wrappers by SWIG to access QuantLib C++ library. I used Excel DNA Integration to make my Quantlib.xll, and I also built a few .exes that access Quantlib.
Various situations would cause this error to appear for me, most especially
Running the .exes off of my desktop ("sometimes")
Distributing my XLL to other users (always).
In the end, I discovered that the distribution that I was getting from the bin folder of my VS2010 (and 12, 13, 15) projects included NQuantLib (the C# wrapper code) but did not include NQuantLibc (the C++ unmanaged code being called).
The XLL and the exes worked on my machine sometimes because I probably helped them (via changing my path?) to find the missing C++ code, but I did not recall that step in the process.
Once I figured it out (using a StackOverflow hint to check the "inner exception" on the error when running the code on another machine and opening up VS to debug when it bombed), the problem went away.
A bit of ignorance on my part that cost me a bit of time but earned me a bit of experience:
this error, for me, was caused by not putting the unmanaged (C++) library where the managed (C#) library could find it.
Hey guys so I have combed the internet trying to find a solution to my problems I had decided I want to learn to opencv and am having a hell of a time to get a basic hello world program working.
So I'll start of with I downloaded the OpenCV2.1 from sourceforge
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/
I am currently running Visual studio 2010 on Windows 7, 32 bit.
So I installed ran the OpenCV2.1.exe file and added OpenCV to my path enviroment, I then build the libraries using cmake and ran through the following instructions
http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010_CMake
When i build the code in the tutorial abovei get a sucesfull build but when I try and start the program i get the "The application was unable to start correctly 0xc150002" error. Anyone have any thought ?
EDIT:
I looked at the event log and this is the information i get
Activation context generation failed for "C:\OpenCV2.1\bin\cxcore210d.dll". Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.
Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
C:\OpenCV2.1\bin\cxcore210d.dll
Had the same problem. Indeed I did rebuild the Dlls, but in the PATH environment variable of Windows the old DLLs C:\OpenCV2.1\bin; were before the new built DLLs C:\OpenCV2.1\build\bin\Debug; which meant that always the old were loaded ... Now it works
I'm trying to profile a C++ project in Embarcadero RAD Studio 2010. To do this I wanted to use AQTime, but I'm running into a bit of a problem.
I can compile and run the application in release mode. But when I compile in debug mode, using the settings mentioned at http://smartbear.com/support/viewarticle/18053/, I get an access violation.
... faulted with message: 'access
violation at 0x062324bd: read of
address 0x62324bd'. Process stopped.
Use Step or Run to continue.
It seems to come when I load a bunch of dll's at the startup. But since it goes well in release mode I can't seem to figure out what could be the cause.
When the access violation occurs I get thrown out into assembly and that isn't one of the languages I'm fluent in ;)
EDIT : When scanning the .exe with Dependency Walker I get a message saying that the following files can't be found
CC32100MT.DLL
INET140.BPL
RTL140.BPL
VCL140.BPL
IESHIMS.DLL
Could this be the problem somehow? Are these debugspecific or is Dependency Walker not giving me correct information? The same files are said to be missing when I try a release compiled version to.
I'm running on Windows 7 x64, if that could be part of the issue. I have had problems before with the symlink-look-alike (user/AppData/Local...) that MS used for some folders. Notably when I ran an apache server and the htdocs folder actually wasn't located where the server thought it was (and where it appeared to be) :)
Have you tried disabling dynamic rtl which can be found in the C++ builder linker options pane?
I set up the environment according to this tutorial:
http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010
However the picture they want you to use is no longer there, so I just saved the supplied screen shot with the same name as the original file.
Builds fine, Begins to run but then I get a runtime error
Here is the runtime error:
OpenCV_HelloWorld.exe - Application Error : The application was unable to start correctly (0xc0150002). Click OK to close the application.
I looked in Event Viewer and found that it also set off a another error but did not announce
Here is the unannounced error:
Activation context generation failed for "C:\OpenCV2.1\bin\cxcore210d.dll". Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.
As you can see it says to use sxstrace.exe however I don't appear to have that program. After a quick Google I read that the program was included in the Microsoft Windows Platform SDK, so I'm downloading the most relevant version (windows 7 version for c# and .net) and installing that to follow up on that, I'll post what I find as it comes.
Any help is very much appreciated
Unexpectedly the project builds and runs now. The only modifications made were removing spaces in the c++ directory and linker options from the tutorial. External changes were the completed installation of the windows platform SDK, however OpenCV has no dependencies with windows platform sdk. I am unsure how it was resolved, but it's no longer a problem.
I met a lot of problems when I'm trying to compile with VS2008 on Vista. Because I'm new to VS2008 and new to programming in Windows, I'm totally lost when errors happen.
My problem is as following:
The vs2008 has anyway been installed and I tried to build a open source app
and the compilation stopped due to errors. In the output window I see:
1>fatal error C1900: Il mismatch between 'P1' version '20080116' and 'P2' version '20070207'
Totally mess for me!!!
Found a thread on this error: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9abfefe0-56bd-4a82-ae14-b08f262972bd
Sounds like you need to install VS2008 Service Pack 1. You should probably also make sure you're up to date with the latest .NET releases.
P1 and P2 refer to the "passes" made by the compiler over your code. Microsoft's C++ compiler is a two-pass compiler. The first pass generates data (in some kind of intermediate form) that's given to the second pass for actual conversion to machine code.
These are implemented in c1.dll and c2.dll.
The error is essentially complaining that you've got mismatched versions. Try a repair install, or install VS2008 Service Pack 1.