Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Convert M$VC console app to U++
Convert M$VC console app to U++ [message #38194] Wed, 05 December 2012 14:32 Go to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
I have a small console app done in M$VC.
Can it be converted to U++ ?

Errors with these 5 lines:

#using <System.dll>
using namespace System;
using namespace System::IO::Ports;
using namespace System::Threading;
using namespace System::IO;

#using <System.dll>
managed targeted code requires a '/clr' option

Commenting that line the other 4:

C:\MyApps\Ccheck\Ccheck.cpp(8) : error C2871: 'System' : a namespace with this name does not exist
C:\MyApps\Ccheck\Ccheck.cpp(9) : error C2653: 'System' : is not a class or namespace name
C:\MyApps\Ccheck\Ccheck.cpp(9) : error C2871: 'Ports' : a namespace with this name does not exist
C:\MyApps\Ccheck\Ccheck.cpp(10) : error C2653: 'System' : is not a class or namespace name
C:\MyApps\Ccheck\Ccheck.cpp(10) : error C2871: 'Threading' : a namespace with this name does not exist
C:\MyApps\Ccheck\Ccheck.cpp(11) : error C2653: 'System' : is not a class or namespace name
C:\MyApps\Ccheck\Ccheck.cpp(11) : error C2871: 'IO' : a namespace with this name does not exist


This app just checks the Comm Ports for GPS receivers.

Here is a link to the U++ Ccheck package and also COMcheck_2.exe
<a href="http://www.nlneilson.com/apps/COMcheck_2.zip" target="_blank"></a>

[Updated on: Wed, 05 December 2012 14:42]

Report message to a moderator

Re: Convert M$VC console app to U++ [message #38195 is a reply to message #38194] Wed, 05 December 2012 14:47 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
That is not standard C++, it is C++/CLI, a similar but incompatible .NET interoperability language from Microsoft.

I am not sure if U++ works with C++/CLI.

But by adding the /clr compilation option, maybe you can get it to compile under TheIDE.
Re: Convert M$VC console app to U++ [message #38196 is a reply to message #38194] Wed, 05 December 2012 15:37 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Hello, Neil.
nlneilson wrote on Wed, 05 December 2012 14:32

I have a small console app done in M$VC.
Can it be converted to U++ ?


It's possible to build Managed C++ with U++ TheIDE.
Just add "-clr" compiler option to U++ package with managed C++ source code and use "CLR" build flag for main package configuration.

Changed Ccheck package attached to the message.
  • Attachment: Ccheck.zip
    (Size: 2.92KB, Downloaded 464 times)
Re: Convert M$VC console app to U++ [message #38197 is a reply to message #38196] Wed, 05 December 2012 15:52 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
THANKS Sender Ghost!

Worked great first try.
I will read up on the link Managed C++ with U++ TheIDE
Re: Convert M$VC console app to U++ [message #38204 is a reply to message #38197] Thu, 06 December 2012 00:38 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
The help on this forum is great.

I just sent another $20.
Re: Convert M$VC console app to U++ [message #38206 is a reply to message #38194] Thu, 06 December 2012 02:33 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
This is very interesting.

So it's possible to use all the power of U++ with .NET libraries.
Re: Convert M$VC console app to U++ [message #38282 is a reply to message #38196] Sun, 09 December 2012 00:14 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
I tried to add a main top window and an EditField.
Now it gives this error:
C:\MyApps\C3\main.cpp(32) : error C2872: 'String' : ambiguous symbol
        could be 'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::String'
        or       'c:\upp\uppsrc\core\String.h(306) : Upp::String'


Another new app was created and the Ccheck.cpp code was pasted in.
There was a similar error with Thread until commented out
// using namespace System::Threading;

System::String^ Com; gets rid of the ambiguous error
Com is local here but may need to convert to Upp::String later.

Get this error now and no idea what is required.
Linking...
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
C:\upp\out\MyApps\MSC9.Clr.Gui.Mt\C3.exe : fatal error LNK1120: 1 unresolved externals

  • Attachment: C3.zip
    (Size: 3.02KB, Downloaded 224 times)

[Updated on: Sun, 09 December 2012 01:38]

Report message to a moderator

Re: Convert M$VC console app to U++ [message #38289 is a reply to message #38282] Sun, 09 December 2012 06:42 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
I put the Ccheck.cpp code (except the main) into a header file.
It compiles OK and can access a small function added to that file.

It runs OK for the small function in optimal and debug but cannot debug into the code.

"Exception: E0434352 at 7607B9BC"

Sender Ghost's mod to Ccheck runs OK in optimal and also debug.
But trying to run in debugger throws a similar exception pop-up and also a dos box:

index.php?t=getfile&id=3975&private=0

line 192 runs the first function in the managed code.

Is this my error or does U++ have a problem debugging into managed code?
Re: Convert M$VC console app to U++ [message #38295 is a reply to message #38289] Sun, 09 December 2012 14:03 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Personally, I don't recommend to mix U++ and managed C++ source code in the same U++ package, if you want to debug it from TheIDE.
Instead, you could create separate U++ package with managed C++ source code for which you could create Microsoft Visual C++ project for debugging purposes.

Changed C3.zip archive attached to the message, which includes C3 and C3Managed U++ packages.
  • Attachment: C3.zip
    (Size: 4.64KB, Downloaded 228 times)

[Updated on: Sun, 09 December 2012 15:42]

Report message to a moderator

Re: Convert M$VC console app to U++ [message #38303 is a reply to message #38295] Sun, 09 December 2012 18:36 Go to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Thank you very much Sender Ghost.

Changing the code so it works is appreciated.
It works.

When the code is added to a much bigger app that app can be debugged and only if the managed code is called would there be a problem. The managed code can be debugged in M$VC++ if necessary if I understand correctly. No problem as the basic code for GPS has been used in my apps for years without a problem.

It's just that the serial code I have been using works on Win XP but not Win7. The M$VC++ serial/port code works on all without a problem and is much faster and less errors and hang ups..

It will take me some time to understand how your code works.

Again THANK YOU!

Previous Topic: Final Compilation for Windows. How to create the .exe 101
Next Topic: Connecting to PostgreSQL DB without reference file
Goto Forum:
  


Current Time: Fri Apr 19 10:59:52 CEST 2024

Total time taken to generate the page: 0.03669 seconds