Archived

This forum has been archived. Please start a new discussion on GitHub.

Ice 3.5.1 and C++/CLI

Howdy,

I am attempting a very simple test.
I have a particular .ice file which looks like
#ifndef _MESSAGE_ICE_
#define _MESSAGE_ICE_

module messaging {

class Message
{
    string clientId;
    string origin;
    string destination;
    string messageType;
    string suffix;
};

sequence<Message> MessageSeq;

class NonQueuedMsg extends messaging::Message {};

};

#endif

I generated the cpp and .h files for this .ice file just fine.
I added --dll-export ENABLE_DLL and --underscore to the options in the VS2013 addin as well.

I am attempting to compile just these two files but with c++/clr option turned on.
Unfortunately, when I compile them, I get this error.
Error	7	error LNK2028: unresolved token (0A00098D) "class IceUtil::Shared * __cdecl IceInternal::upCast(class IceInternal::ObjectFactoryManager *)" (?upCast@IceInternal@@$$FYAPEAVShared@IceUtil@@PEAVObjectFactoryManager@1@@Z) referenced in function "public: __cdecl IceInternal::Handle<class IceInternal::ObjectFactoryManager>::Handle<class IceInternal::ObjectFactoryManager>(class IceInternal::Handle<class IceInternal::ObjectFactoryManager> const &)" (??0?$Handle@VObjectFactoryManager@IceInternal@@@IceInternal@@$$FQEAA@AEBV01@@Z)

Compiling without the CLR flag on works fine and the target dll is built.

Is there a problem with compiling slice2cpp generated files into assemblies that need clr option enabled? Has anyone else been able to compile slice2cpp generated files with the /clr option on?

Any assistance would be fantastic, thank you.

PS:
I had trouble using your forum search to find topics related to CLI. I think the forum search is broken or not working quite so well.

Comments

  • xdm
    xdm La Coruña, Spain
    You cannot compile the C++ code with /clr, this is for C++/CLI code.

    Besides you can find other issues if you pool Ice headers in C++/CLI code as the one described here
  • benoit
    benoit Rennes, France
    Hi,

    As José pointed out we don't really support compiling the generated C++ code with /clr.

    Could detail a little more what you're trying to do? Did you consider to instead generate C# code for your Slice types and use it from C++/CLI? Or your application is mostly C++ and you want to call into some .NET assemblies?

    Note that we also support the WinRT platform with C++/CX on Windows.

    Cheers,
    Benoit.
  • I reproduce the bug on the evictor_filesystem client demo

    I have the same problem on C++/CLI projects
    with VS2013 + ICE 3.5.1 (link with ZeroC\Ice-3.5.1\lib\vc120)

    When compiling the evictor_filesystem c++ client demo with /clr option
    the project don't link:
    error LNK2001: symbole externe non résolu "class IceUtil::Shared * __cdecl IceInternal::upCast(class IceInternal::ObjectFactoryManager *)" (?upCast@IceInternal@@$$FYAPAVShared@IceUtil@@PAVObjectFactoryManager@1@@Z)

    missing ObjectFactoryManagerF.cpp?
  • Try this fix

    I fix linking problem in ObjectFactoryManagerF.h :

    IceUtil::Shared* upCast(ObjectFactoryManager* p) { return (IceUtil::Shared*) p; };

    can you please remove this code from ObjectFactoryManager.cpp :
    IceUtil::Shared* IceInternal::upCast(ObjectFactoryManager* p) { return p; }