PDA

View Full Version : c++/cli for cross platform



aurora
07-03-2008, 07:26 PM
A couple friends of mine have finally talked me into looking at using .nets c++/cli 's managed codes ability(?) for cross platform development. I had always been a nay sayer on c++/cli as much as I am against c# compared to pure Java. So I have been doing some reading this past week and am still unconvinced it's a good direction to go for cross platform development especially if I'm using OGL, possibly wxWidgets, and a ton of gpu optimizations.
Just wondering if anybody here had any comments pro or con on this route for CG app development (yes it's for my Oto Taca app)

Hopper
07-03-2008, 10:17 PM
In our shop, we don't consider C++ to be cross platform whatsoever. Even with GNU there's a ton of compiler directive manipulation and make file nightmares. We only use C++ for console utilities that have to be small and platform specific so we can use dynamic libs. Everything else is Java, even on our AIX clusters. JBoss clustering rocks ... but I guess that doesn't help you much now does it ...

We don't do graphics either, but just thought I'd give you my point of view.

A few of our guys have tried using the .NET cross platform stuff and it blows. It's not cross platform at all. Try writing a simple app and throw it over to an HPUX or AIX box and see what happens.

Lightwolf
07-04-2008, 02:46 AM
I wouldn't bother with it, mainly because I don't see the point.

I found C++/wxWidgets to be perfectly cross platform for what I do (which is graphics oriented) - and low level enough as well (I'm old-school).

@Hopper: Cmake is great for cross platform makefiles.

Cheers,
Mike

aurora
07-04-2008, 07:16 AM
I agree with you Mike. I see absolutely no real advantage to going that route but lots of recoding to get it to work with clr/cli. Nice concept but the only thing it saves me really is the lack of need for separate compilers for each platform and with todays emulators there is even ways to improve that issue.

Hopper, I have done more then my share of Java and agree Java is a great language for particular needs. Oto-Taka is deff not one of those. I need the speed/power that 'I' can leverage with c++. Plus the only other platform's I'm really after is those for Mac users and Linux. Thus making life even easier yet, for me that is.

GregMalick
07-04-2008, 12:35 PM
I found C++/wxWidgets to be perfectly cross platform for what I do (which is graphics oriented) - and low level enough as well (I'm old-school).


Aloha Mike,

You have me intrigued about wxWidget.
So I Googled wxWidget and found: this (http://sourceforge.net/project/showfiles.php?group_id=9863)

What's needed to setup and play with wxWidget?
wxAll?
wxMSW?
all those files listed?
Is there a user forum?
Could you help getting me started? :help:

GregMalick
07-04-2008, 12:41 PM
oooh....

I found /docs/msw/install.txt

that's a start. :boogiedow

aurora
07-04-2008, 02:36 PM
Looks like you found what your after, correct Greg?
I have links to a few good tutorials and a online book if you want them!

GregMalick
07-04-2008, 03:00 PM
Looks like you found what your after, correct Greg?
I have links to a few good tutorials and a online book if you want them!

That information would be fabulous. :thumbsup:
I've spent the past week wasting my time googling for information about making a custom control in VSExpress C++

I'm hoping wxWidget will give me the flexibility to create the GUI I want and make it cross-platform compatible.

aurora
07-04-2008, 03:16 PM
Heres the book, I'll have to hunt for the other links they are not where I though I stored them.
http://www.scribd.com/doc/2470492/Cross-Platform-GUI-Programming-with-wxWidgets

aurora
07-04-2008, 03:25 PM
Here they are, how about looking in the folder called wxWidgetRefs?
http://www.codeproject.com/KB/library/wxwidgets.aspx
http://wiki.wxwidgets.org/Guides_%26_Tutorials[
/URL]
http://wiki.wxwidgets.org/Microsoft_Visual_CPP_Guide
http://www.wxwidgets.org/docs/tutorials.htm
http://www.roebling.de/download.html
http://www.zetcode.com/

I have a few others but they are much more esoteric then these are and one of those is the link to wxDesigner.

Something else you might want to look at is [URL="http://www.fltk.org/"]FLTK (http://wiki.wxwidgets.org/Guides_%26_Tutorials). I've used it for almost all of my standalones and for prototyping, mainly becuase I have a ton of personal classes and wizards that helps me work fast with it. But I do think wxWidgets is more sound over all by far. I just have not gotten as comforatble with it as I am with fltk yet.

GregMalick
07-04-2008, 03:42 PM
Heres the book, I'll have to hunt for the other links they are not where I though I stored them.
http://www.scribd.com/doc/2470492/Cross-Platform-GUI-Programming-with-wxWidgets

Thanks, I'm reading the book now.
Hey it was originally developed in Scotland!

ahhhh... Scotland. :)

GregMalick
07-04-2008, 10:16 PM
I got wxWidgets compiled and the toolbar sample working.
Looks great!

This link was a great help (http://wiki.wxwidgets.org/MSVC)

Question:

Can an external program (not a dll) communicate to a LW plugin (perhaps via the Communication Ring or another method) ? :confused:

aurora
07-05-2008, 07:27 AM
Funny you should ask. I have been trying hard to make a mock up do just that. Oto-Taca will be a complete standalone product but basically is designed from my LW and scientific viz plugin/apps. What I would 'like' to have happen is to have a live connection to LW from a non LW-plugin app. So I have had miserable success. The route I have been working on is having the mock-up linked to a mock-up plugin which is also a LW plugin. What I need is a completely communicable abstract layer between the mock-up and LW and one would think sure no problem but alas its a problem. In the end Oto-Taca's ability to work with LW will depend on hopeful changes in LW10 or just simple write files out that can be opened in LW.
Greg we should ask this question in its own thread so maybe the Dev's can chime in!

Lightwolf
07-05-2008, 08:30 AM
Can an external program (not a dll) communicate to a LW plugin (perhaps via the Communication Ring or another method) ? :confused:
Cross platform?

Since the HUB API isn't published you'd need to roll your own connection.
One way would be to use TCP/IP (where have I heard that before? ;) ) - Otherwise, this may be a start: http://en.wikipedia.org/wiki/Inter-process_communication

Cheers,
Mike

GregMalick
07-05-2008, 10:39 AM
Cross platform?

Since the HUB API isn't published you'd need to roll your own connection.
One way would be to use TCP/IP (where have I heard that before? ;) ) - Otherwise, this may be a start: http://en.wikipedia.org/wiki/Inter-process_communication

Cheers,
Mike

Aloha Mike,

Thanks for the link. After reading that page, I don't think there's any otherwise about it. TCP/IP looks like the best way to go. All major platforms support it and it would provide support across a LAN/WAN and the internet. Your remark (colored blue) makes me think this must have been discussed to death before. I'll do some searches here and on the lw-plugins forum to see if this has already been dismissed as infeasible.

I've been doing a lot of pacing (thinking) this morning.

aurora
07-05-2008, 01:13 PM
Well right now it s for me since what I want to hook into is HV's more so then particle services and well now you know why my research is so limited in scope.

Lightwolf
07-05-2008, 04:51 PM
Your remark (colored blue) makes me think this must have been discussed to death before.
I should've been more clear... that was a side blow at the Hub :D

I think for small amounts of data it is fine, with larger chunks you could also look into a single shared library that shares data across processes.

Cheers,
Mike

GregMalick
07-05-2008, 05:21 PM
I should've been more clear... that was a side blow at the Hub :D

I think for small amounts of data it is fine, with larger chunks you could also look into a single shared library that shares data across processes.

Cheers,
Mike

I never use the hub - so that never occurred to me.
Would you have a link to something about the shared library suggestion?

Lightwolf
07-05-2008, 05:34 PM
Would you have a link to something about the shared library suggestion?
Let me take that back, a DLL would only use memory mapped files/ file mapping as well (all the DLL does is control access to it, but you don't need to use a DLL for that).

I've collected a few links though:

If you use boost/C++, this might help:
http://www.boost.org/doc/libs/1_35_0/doc/html/interprocess.html

File mapping (win32, OSX and Linux have a similar mechanisms):
http://msdn.microsoft.com/en-us/library/aa366556(VS.85).aspx

Cheers,
Mike

aurora
07-05-2008, 05:59 PM
boost rocks!!!

OK, so I'm kinda confused are you suggesting TCP/IP is better or ICP? I kinda like the thread communication concept really but since this is kinda new to me what the heck do I know:foreheads

GregMalick
07-05-2008, 09:20 PM
Well the way I'm reading this (http://en.wikipedia.org/wiki/Inter-process_communication) is that TCP/IP is simply one method you can use to implement an IPC. Since you mentioned massive amounts of shared data, Boost/C++ looks well suited to your needs.

Communicating across multiple machines on a LAN intrigues me. And since my data is less than 100 bytes, TCP/IP could work well - as long as it could do many messages very quickly.

I wish there was a comparison of pluses & minuses (especially Speed).

XML-RPC (http://en.wikipedia.org/wiki/XML-RPC) also looks very interesting.

GregMalick
07-05-2008, 09:34 PM
The following isn't multi-platform - but still a good read.
CodeProject (http://www.codeproject.com/KB/threads/Win32IPC.aspx)

Lightwolf
07-06-2008, 04:06 AM
The following isn't multi-platform - but still a good read.
CodeProject (http://www.codeproject.com/KB/threads/Win32IPC.aspx)
And you also have both mechanisms (but with a slightly different API) on Un*x based OSes.

From what I've seen, Boost abstracts those in a cross platform manner.

Cheers,
Mike

GregMalick
07-06-2008, 11:42 AM
Mike/Aurora,

The wxWidgets Sockets samples work great.
But I just realized :foreheads that the sxWidgets are in C++.
So is this unusable in a LW Master plugin?

Another issue is that I need this Master plugin to accept LW-commands from an external program. That means a server listener needs to be established in this plugin. Is that going to kill LW responsiveness?

I'll also need to embed a client into the plugin in order to send certain LW events back to the external program (that doesn't sound bad, though).

Any ideas would be greatly appreciated.

Lightwolf
07-06-2008, 12:22 PM
Mike/Aurora,

The wxWidgets Sockets samples work great.
But I just realized :foreheads that the sxWidgets are in C++.
So is this unusable in a LW Master plugin?

That shouldn't be a (big) problem. All of my plugins are C++.


Another issue is that I need this Master plugin to accept LW-commands from an external program. That means a server listener needs to be established in this plugin. Is that going to kill LW responsiveness?

Wait for 9.5.


I'll also need to embed a client into the plugin in order to send certain LW events back to the external program (that doesn't sound bad, though).

Yeha, that would just be a normal master handler.

Cheers,
Mike

GregMalick
07-07-2008, 02:44 AM
That shouldn't be a (big) problem. All of my plugins are C++.If I could find a simple LW C++ skeleton, all my plugins would be in C++ too. I'm just not clever enough to figure out how to get a LW C++ plugin going.


Wait for 9.5.
I'm in the beta and nothing in the SDK struck me as pertinent to this discussion.


Yeha, that would just be a normal master handler.Huh? :stumped: Are you saying that master handlers already have the capability of two way communication with a program external to LW? That's news to me.

Lightwolf
07-07-2008, 03:19 AM
If I could find a simple LW C++ skeleton, all my plugins would be in C++ too. I'm just not clever enough to figure out how to get a LW C++ plugin going.
If you want to, hook up at http://forums.db-w.com and I'll grant you access to my/our C++ wrapper for the SDK (still not in shape to be released publicly).


I'm in the beta and nothing in the SDK struck me as pertinent to this discussion.
Hm, if you are then we should move this discussion (or I'll PM you).

Huh? :stumped: Are you saying that master handlers already have the capability of two way communication with a program external to LW? That's news to me.
No, but they can catch events. Sending them out of LW if of course still your responsibility.

The ComRing also allows for some basic even handling (i.e. have your plugins send out events caught by other plugins, which in turn can send them out).

Cheers,
Mike

aurora
07-07-2008, 10:02 AM
I also use c++ exclusively for my plugins. Once you know the tricks its no problem and you get all the power.

I think Mike has the right idea of moving this to the OB section as there are a few potentials that we should discuss in that area!

aurora
07-07-2008, 10:10 AM
OK I have started a new thread entitled App->Plugin->LW comm you should know where to look:thumbsup:

GregMalick
07-07-2008, 10:58 AM
If you want to, hook up at http://forums.db-w.com and I'll grant you access to my/our C++ wrapper for the SDK (still not in shape to be released publicly).
Cheers,
Mike

If there's a single LW C++ plugin example - that would be awesome.

Lightwolf
07-07-2008, 11:06 AM
If there's a single LW C++ plugin example - that would be awesome.
For a basic plugin?

That depends on how far you want to go really.

I.e., this is a simple generic plugin using lwpp:


#include <lwpp/generic_handler.h>

class HelloWorld : public lwpp::LayoutGenericHandler
{
public:
int Activate()
{
lwpp::LWMessage::Info("Hello World!");
}
};

lwpp::LayoutGenericAdaptor<HelloWorld> hwInstance("HelloWorld");


If you just want to turn a vanilla .c plugin source to a .cpp (without actually making use of C++), the main thing to do is to define the callbacks properly to use LWInstance * (which is a void *) and then cast it to whatever your data is. The C style callback definitions using a pointer to the data struct isn't C++ compatible (but fine in C).

Cheers,
Mike

GregMalick
07-07-2008, 01:07 PM
What's this????


#include <lwpp/generic_handler.h>

Is that your wrapper?

Lightwolf
07-07-2008, 01:53 PM
What's this????


#include <lwpp/generic_handler.h>

Is that your wrapper?
Yes, lwpp (LightWrap++).

Another example is attached (basically the source code of my material Blender) - actually a .cpp file, but I renamed it for the upload.

Let me see if I can quickly take a LWSDK sample and turn that into something that is at least C++ compatible (not today though).

Cheers,
Mike

GregMalick
07-07-2008, 04:59 PM
Aloha Mike,

Thanks. Can I get access to look at the headers?

#include <lwpp/node_handler.h>
#include <lwpp/vparm.h>

:D

Lightwolf
07-07-2008, 05:12 PM
Aloha Mike,

Thanks. Can I get access to look at the headers?

#include <lwpp/node_handler.h>
#include <lwpp/vparm.h>

:D
Yes, (as mentioned before ;) ): Register at our forums (http://forums.db-w.com) and PM me if I'm not quick enough to bump your access status.

The only reason for it not being public is because it isn't finished. But it will be BSD licensed once released.

Cheers,
Mike

GregMalick
07-07-2008, 05:58 PM
Yes, (as mentioned before ;) ): Register at our forums (http://forums.db-w.com) and PM me if I'm not quick enough to bump your access status.

The only reason for it not being public is because it isn't finished. But it will be BSD licensed once released.

Cheers,
Mike

Done.

Lightwolf
07-07-2008, 06:02 PM
Done.
Now activate your account (you should have gotten an e-mail) and you have access.

Cheers,
Mike

GregMalick
07-07-2008, 06:29 PM
Done. I've downloaded the rar file. Time to uncompress, print, and do some light reading on the bus-ride home.

Lightwolf
07-07-2008, 06:39 PM
Done. I've downloaded the rar file. Time to uncompress, print, and do some light reading on the bus-ride home.
Do that.
I have worked a bit on the general docs in the past few weeks (as well as extending lwpp a bit). There'll be an update once I can catch a breath....

Also, make sure to read the messages on the forum. They give you an overview on the current state and a couple of extra pointers as well.

Cheers,
Mike

dulo
12-05-2008, 07:23 AM
Are you still interested in C++/CLI ? I followed the thread and you seem to have droped the Idea of CLI and stick with pure c++.
One year ago i started to write a CLI wrapper for the Lightwave SDK.
I ended with some testplugins implemented in C# and called by Lightwave from native C, but I have stopped working on it because of lack of time.
If you are interested I could send you some samples.
But you have to know that it isnt multiplatform at all !! Its restricted to Windows because mono lacks c++/CLI completely (just invoke .. ) and the way from native C into CLR is quite Tricky so its more or less impossible to port it to mono.

greetings

Dulo

aurora
12-05-2008, 09:08 AM
Thanks, but yeah I dropped that approach pretty dang quick. I ended up using wxWidgets for the gui API and wrote my own cross platform wrappers for multi-processing/threading. I'm still pretty much .net free in everything I do. For LW plugins I normally just do brute force c++ although I have used Mikes lwpp and love it!

Lightwolf
12-05-2008, 09:10 AM
For LW plugins I normally just do brute force c++ although I have used Mikes lwpp and love it!
Hey, thanks. :D
If there's anything you added I'd love to assimilate it :hey:

Cheers,
Mike

aurora
12-05-2008, 09:37 AM
I have a few things I would have loved to have had time to wrap and add but alas, school has been such a B***** this year. Then there's next year :D