Archived
This forum has been archived. Please start a new discussion on GitHub.
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?
"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?
0
Comments
-
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/default.asp?url=/library/en-us/vccore98/html/_crt_c_run.2d.time_libraries.asp.
Cheers,
Bernard0 -
thank you your recommend.
but now has a new question:
http://www.zeroc.com/vbulletin/showthread.php?s=&threadid=816
can you give me some advice?0 -
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://=========================================== // 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: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...0 -
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.0