Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / January 2005

Tip: Looking for answers? Try searching our database.

simple dll/lib question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ramsey - 25 Jan 2005 23:01 GMT
When I first started my project I was using stl for all the real
processing and managed c++ for all the pretty forms.

But after a while the project became too large to manage. Now I am
thinking of breaking up the project into dlls/lib files but I am
running into the following problems.

My project can be logically broken into 4 groups of code. 2 that use
stl and 2 that use managed c++.

First I wanted to make all the pieces dlls but I ran into the problem
of having to use some sort of COM layer for the groups of code that use
stl.

Second I tried making everything lib files but for some reason I kept
on getting linker errors when trying to convert the managed c++ code
into libs.

Third I tried making the stl code lib files and the managed code dlls
but I got this weird error in the file "objIdl.h" saying that the
IDataObject class is being redefined, but I never included this file or
used that class.

What I really want to know is what has worked for you when organizing a
project that uses stl and managed code.
Any help would be greatly appreciated.
Ramsey
Tamas Demjen - 26 Jan 2005 19:17 GMT
> What I really want to know is what has worked for you when organizing a
> project that uses stl and managed code.
> Any help would be greatly appreciated.

I've done this successfully. I have general purpose libraries written in
standard C++, which I can use in any unmanaged project, with any
compiler. It uses STL internally. Now I'm using that library inside a
C++/CLI project (managed) with VC++ 2005 Beta 1. The trick is to
recompile the LIB that uses STL inside with managed settings (CLI
support turned on), even though it's not using anything managed inside.
Then make the main application project mixed-mode, because it's not
going to work when it's pure managed. It was a pain to get it to work,
but it all depends on the compiler settings. You must use the same
standard library setting for the LIB and the main app project; which I
think must be Multi-threaded DLL (/MD or /MDd). After that they will be
compatible, and the LIB can be linked to a managed project.

This should also work with DLLs, but again, you must compile a special
DLL with managed extensions turned on. You can't use a DLL compiled
without CLI support. At least not if a DLL is exporting C++ and/or STL
types; because if it's a pure C-interface DLL, it doesn't matter then.

I can help with the project settings if you have problem. There's one
more trick. My mixed-mode application crashed immediately on startup
until I added this to the Linker/Input settings:
Force Symbol References: __DllMainCRTStartup@12
(/INCLUDE:"__DllMainCRTStartup@12" linker option)

Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.