Home Help Center

Compiling slice2cpp-generated-code on Win. XP Pro

catalincatalin Member ✭✭
Hi!

I guess this has been asked before, but I could not find the thread. Sorry.

I have installed ICE on Win. XP Pro. I have the .NET 2003 compiler (academic version), but I haven't used it before.

1) within the .Net 2003 IDE:

Should I create console projects in order to compile the code generated by slice2cpp? If so, does anyone have a recepie for the steps to be taken in order to integrate the generated code into such an application?

2) If I want my applications to be "platform independent" should I install make for Windows and call the compiler from the make files? If so, does anyone know how to call this particular compiler from a Makefile? I understand the compiler's name is cl.exe, but what options do I have to pass to it?

3) Should I install another C++ compiler for Windows? If so which one?

Thanks a lot,
Catalin

Comments

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Catalin,

    You can use Visual C++ 6.0, 7.0 (aka .NET 2002) or 7.1 (aka .NET 2003) with Ice ... they all work equally well.
    We actually provide 2 build systems with Ice, one Visual Studio-based, and one GNU-make based. Writing makefiles that work with both gmake and nmake is probably impossible; but you may be able to use gmake everywhere.

    The Ice Visual Studio build system is written for Visual C++ 6.0, and is converted automatically to Visual C++ 7.0/7.1 format when you first open it.
    The Ice demos show how to integrate slice2cpp into a Visual Studio build system, and also which flags you should pass to the C++ compiler.

    Cheers,
    Bernard
  • catalincatalin Member ✭✭
    > The Ice demos show how to integrate slice2cpp into a Visual Studio build system, and also which flags you should pass to the C++ compiler.

    Can you elaborate on this?

    I imagine I would have to take the following steps, but how?

    1) Create a new console win32 project

    2) Add the .ice file to the project's resources

    3) Make the IDE to run it through slice2cpp

    4) Add the .cpp and .h files generated by slice2cpp to the project

    5) set some flags to for the compiler

    6) build the project

    When poking around the demos I can see lots of properties set in many windows, but I do not know how to set them. I haven't found any of them to refer to slice2cpp yet.

    I know this isn't an ICE question directly, but I guess it would be benefic for many beginers to receive some guidance from others who have done this before. That way we can get (almost) straigth to ICEing.

    I'm used to compiling on Linux, and even though I could install gmake on windows, I am not sure wheather I will be able to compile the make-based version of ICE (and applications later on) simply by changing gcc to cl.exe in the makefiles.

    Thanks again,
    Catalin
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    If you are not familiar with the VC++ IDE, but are very familiar with GNU make, then perhaps it would indeed be easier for you to use gmake for both Windows and Linux.

    For the most part, the Makefiles would be just the same. However, there are some differences. such as DLLs vs. shared libraries. If you know GNU make well, then you can use if-statements in the Makefiles to have separate rules for Unix/Linux and Windows.

    As for using the Windows IDE, you could look at any of the demos, and go through each project setup windows step-by-step. Alternatively, you can just copy the .dsp file, and then edit it with your favorite editor. I know that this is not exactly Windows-style, but it is much quicker than changing lots of settings in lots of different project setting windows. The editing is mostly search&replace for filenames. For example, if your Slice definition is in Foo.ice, and you used Hello.dsp as basis for your project file, just replace "Hello" with "Foo" in Foo.dsp (which is initially a copy of Hello.dsp).

    This might sound like a hack, but believe me, it's more efficient than using all the dialogs in the Windows IDE :-)
  • catalincatalin Member ✭✭
    Originally posted by marc
    If you are not familiar with the VC++ IDE, but are very familiar with GNU make, then perhaps it would indeed be easier for you to use gmake for both Windows and Linux.

    I don't mind learning to use VC++. I used Delphi some years ago, it had project files too.

    It would be very nice if you or somebody else could post a stepwise recepie for how to set up an ICE project for VC++. It doesn't have to be in complete detail, only specific enough in order to be able to do it by consulting the MSDN documentation.

    Directions like "create a new X project" (where X is the kind of the project), "set the following variables", etc. would help a lot on the way. If it is of interest I could summarise later on my experience and post a message for other VC++ beginers.
    For the most part, the Makefiles would be just the same. However, there are some differences. such as DLLs vs. shared libraries. If you know GNU make well, then you can use if-statements in the Makefiles to have separate rules for Unix/Linux and Windows.

    Then I probably still have to learn what flags the cl.exe compiler needs, as they most likely are not POXIS-like.
    As for using the Windows IDE, you could look at any of the demos, and go through each project setup windows step-by-step. Alternatively, you can just copy the .dsp file, and then edit it with your favorite editor. I know that this is not exactly Windows-style, but it is much quicker than changing lots of settings in lots of different project setting windows. The editing is mostly search&replace for filenames. For example, if your Slice definition is in Foo.ice, and you used Hello.dsp as basis for your project file, just replace "Hello" with "Foo" in Foo.dsp (which is initially a copy of Hello.dsp).

    This might sound like a hack, but believe me, it's more efficient than using all the dialogs in the Windows IDE :-)

    I don't mind hacking, but it isn't trivial either. The solution descriptive file will have to point to the right project files, and the latter have a weird code, looking like Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "helloC". How do I generate that kind of codes? Also I'll have to update quite a bit in the project files, as I would like not to have to put my files under the demo-directory.

    Anyways, thanks for your help.
    Catalin
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Create a New Visual Studio .NET Project

    Hello Catalin,

    This is already my second post ... I accidentally bumped into the reset button while typing the first one before I was able to post it.

    Basically, I understand your problem because I went through the same thing a few months back. Basically, this is a tutorial on how to setup a clean ICE project using WinXP Pro and Visual Studio .NET 2003.

    First off, you must install VS.NET prior to installing ICE. Reversing this order will cause your system not to find the include and library files and you'll have to muck around with the VS.NET setting to set the paths.

    So start a new project, click on File->New->Project to get the New Project dialog box. On the Project Types tree view, select Visual C++ Projects and this will change the entries in the Templates list. Scroll down on the Template list and select Win32 Project, type in your project name and click on the Ok button.

    This will popup the Win32 Application Wizard dialog box. Make sure that you click on the Application Settings tab and set the Console application radio button and the Empty project check box then click on the finish button. This will create the directory and the solution file for your project.

    to be continued ...

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Creating and Adding your Slice file

    Next step is to create your slice definition file. Unfortunately, there is a wierdness in VS.NET that won't allow you to add an unrecognized file into the resource file tree.

    To work around this, go to the directory where VS.NET created your project and create the .ICE file manually. What you then do is go back to your VS.NET project and go to the Solution Explorer window. Under your project, there is a Resource Files folder tree, right-click it and select Add->Add Existing Item from the context menu. Navigate to where you put your .ICE file and add it to the project.

    Your .ICE file should now be listed in as a resource file, select and right-click it again to display the context menu. Click on the Properties menu item to display its dialog box. In the tree listbox, select Custom Build Step to change the right panel to the appropriate dialog. In the right panel, click on Command Line and type
    slice2cpp printer.ice
    , replacing printer.ice with the filename. Since slice2cpp will generate both (in my case) printer.cpp and printer.h, add them to the Outputs text box.

    You can then build your application so that VS.NET will invoke slice2cpp to generate the output file. If there are no problems, the output files will be created and you can add them to the Solution Explorer's entries for Source Files and Header Files.

    to be continued ...

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Project Configuration

    Unfortunately, my wife called me up to say that were leaving in 20 minutes. So, I won't be explain stuff anymore but just post my configuration settings. Maybe later on when I feel a little industrious, I may update these with explanations why the settings were so.

    So to get to the project configuration screen, in the Solution Explorer pane, righ-click on your project name and select Properties. This will popup your project's propery dialog box.

    Just follow my settings.

    Alex

    NOTE: All of these settings are for DEBUG mode.
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    C/C++ General Settings

    One of the things that you must not forget is to set the values for Additional Include Directories to your current project directory.

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    C/C++ Optimizations

    I once fooled around with the settings here and when I run my application, it kept throwing funky error messages. So I just leave this now un-optimized.

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    C/C++ Code Generation

    Be guided by the attached image. Nuff said. ;)

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    C/C++ Language

    You must enable the runtime type info. Otherwise, your ICE application won't compile.

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    C/C++ Command Line

    You'll notice that I'm skipping some items. Its because you can leave them as default and also my wife just called up again to remind me to pack up. :)

    Make sure that you have similar setting as displayed in the attached image.

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Linker General Settings

    Here are the setting for the linker. You'll notice that my project name is IceServer so you should ignore any names that's similar to that and replace it with your project name.

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Linker Input settings

    Be reminded that the dialog boxes are for debug version of my system. To build the release version, change the Additional Dependencies entries in the Release configuration dialog box to
    Ice.lib IceUtil.lib

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Linker System settings

    This setting only applies if your making a console application. When building DLL's or Window's application, the values for the SubSystem text box should be Windows.

    Also, changing the SubSystem entry to another value will just cause your build to fail. For some stupid reason, Microsoft keep insisting on using a console subsystem when building with Unicode.

    Alex
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Linker Command Line setting

    As usual, I jumped over the item which you can leave as default. The last thing though is that you should have a similar linker command line values as with the attached image.

    After saving this, you should be able to build your ICE application. :)

    Good luck and happy coding.

    Alex

    P.S.
    The wife is already giving me the evil eye. ;)
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    This is great! Thanks a lot for your help!
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    Hi Alex,

    thanks a lot for putting this together! I was going to do something like this, but haven't found the time yet.

    With your permission, I might put something together as a PDF document that is based on your example and and add it to the distribution. Would that be OK with you?

    Cheers,

    Michi.
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    No problem.

    It would really be helpfull for me too if these are included in the official PDF file. I sort of use it to give ICE introductions to other developers in our company. :)

    Alex
  • catalincatalin Member ✭✭
    Hi!

    Thanks for your detailed reply. I will try it out as soon as possible. Give my regards to your wife. I guess you exceeded your 20 minutes!

    Catalin
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Actually, It took me only 21. She called at around 9:10pm (my timezone) and I posted the last image at 9:31pm.

    If you would think about it, I was still within the 20 minute time limit cause it took more than a minute to explain to her that I only need a few more minutes to upload the images.

    I for one is very happy that my wife don't read this forum. lol.

    Alex
Sign In or Register to comment.