Results 1 to 5 of 5

Thread: Only multi-threaded DLL libraries can be used with Ice!

  1. #1
    chenhong_sz is offline Registered User
    Join Date
    Nov 2003
    Location
    China.Shenzhen
    Posts
    35

    Only multi-threaded DLL libraries can be used with Ice!

    when i complie a project ,a error message shown:
    "Only multi-threaded DLL libraries can be used with Ice!'
    i found it defined as follow:
    # if !defined(_DLL) || !defined(_MT)
    # error "Only multi-threaded DLL libraries can be used with Ice!"
    # endif
    so i add _DLL,_MT in project->setting->c/c++->preprocessor definitions
    and rebuild, it look ok,but i don't know what its meaning. if when the program use multi-thread, and user must set the _DLL and _MT?

  2. #2
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    This just means the Ice libraries are built with /MD (release) or /MDd (debug) and you should do the same (using the appropriate drop-down list or checkbox, not by adding definitions).

    I also recommend you have a look at the Microsoft documentation, such as http://msdn.microsoft.com/library/de..._libraries.asp.

    Cheers,
    Bernard

  3. #3
    chenhong_sz is offline Registered User
    Join Date
    Nov 2003
    Location
    China.Shenzhen
    Posts
    35
    thank you your recommend.
    but now has a new question:
    http://www.zeroc.com/vbulletin/showt...=&threadid=816
    can you give me some advice?

  4. #4
    yrh79 is offline Registered User
    Join Date
    Apr 2005
    Posts
    7

    do i have to setup my project as a DLL? i can't link the program.

    i encounter the same problem, that it said "Only multi-threaded DLL libraries can be used with Ice!"
    so... does it mean that i have to setup my project as a DLL?
    i want to test the program given in the manual, here is my source:

    Code:
    //===========================================
    // Server.cpp : Definition of a console program's entry point
    //
    #include "stdafx.h"
    
    #include <Ice/Ice.h>
    #include <Printer.h>
    using namespace std;
    using namespace PrintSys;
    class PrinterI : public Printer {
    public:
    	virtual void printString(const string & s,
    		const Ice::Current &);
    };
    
    void
    PrinterI::
    printString(const string & s, const Ice::Current &)
    {
    	cout << s << endl;
    }
    
    int
    main(int argc, char* argv[])
    {
    	int status = 0;
    	Ice::CommunicatorPtr ic;
    	try {
    		ic = Ice::initialize(argc, argv);
    		Ice::ObjectAdapterPtr adapter
    			= ic->createObjectAdapterWithEndpoints(
    			"SimplePrinterAdapter", "default -p 10000");
    		Ice::ObjectPtr object = new PrinterI;
    		adapter->add(object,
    			Ice::stringToIdentity("SimplePrinter"));
    		adapter->activate();
    		ic->waitForShutdown();
    	} catch (const Ice::Exception & e) {
    		cerr << e << endl;
    		status = 1;
    	} catch (const char * msg) {
    		cerr << msg << endl;
    		status = 1;
    	}
    	if (ic) {
    		try {
    			ic->destroy();
    		} catch (const Ice::Exception & e)
    		{
    			cerr << e << endl;
    		}
    		status = 1;
    	}
    	return status;
    }
    
    //============================================
    
    // Client.cpp : Definition of a console program's entry point
    //
    
    #include "stdafx.h"
    
    #include <Ice/Ice.h>
    #include <Printer.h>
    using namespace std;
    using namespace PrintSys;
    
    int
    main(int argc, char * argv[])
    {
    	int status = 0;
    	Ice::CommunicatorPtr ic;
    	try {
    		ic = Ice::initialize(argc, argv);
    		Ice::ObjectPrx base = ic->stringToProxy(
    			"SimplePrinter:default -p 10000");
    		PrinterPrx printer = PrinterPrx::checkedCast(base);
    		if (!printer)
    			throw "Invalid proxy";
    		printer->printString("Hello World!");
    	} catch (const Ice::Exception & ex) {
    		cerr << ex << endl;
    		status = 1;
    	} catch (const char * msg) {
    		cerr << msg << endl;
    		status = 1;
    	}
    	if (ic)
    		ic->destroy();
    	return status;
    }
    //======================
    i set the project as "/MD"(multi-thread DLL), though my project was initaially a console program. despite of a few warnings, i get through the compile process, and then it wouldn't link.
    the messages was:
    Code:
    Linking ...
    Server.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl IceUtil::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class IceUtil::Exception const &)" (__imp_??6IceUtil@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@ABVException@0@@Z) ,it was referenced by function: __catch$_main$0
    ... many similar lines...
    Last edited by yrh79; 04-20-2005 at 02:34 AM.

  5. #5
    benoit's Avatar
    benoit is online now ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    No this doesn't mean that you need to build your project as a multi-threaded DLL. You just need to ensure that you're compiling your console application with the right runtime library: either the debug (build with /MDd) or release (build with /MD) multi-threaded C runtime library. And you also need to link with the correct Ice library: ice.lib (for release) and iced.lib (for debug). It looks like from the error message that you're not linking you application with the Ice library.

    Please take a look at the Visual C++ Ice demo projects for examples on how to setup a project.

    Benoit.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 10-25-2008, 09:30 PM
  2. Ice and single threaded libraries
    By Nis Baggesen in forum Help Center
    Replies: 4
    Last Post: 03-22-2005, 04:25 AM
  3. Replies: 4
    Last Post: 03-31-2004, 08:45 PM
  4. Replies: 3
    Last Post: 03-31-2004, 07:13 PM
  5. ICE calling a Single Threaded DLL
    By amrufon in forum Help Center
    Replies: 7
    Last Post: 08-04-2003, 09:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •