www.digitalmars.com         C & C++   DMDScript  

c++.command-line - Building against dynamic RTL and STLport libraries

reply michael.champigny verizon.net writes:
I've switched from Borland to Digital Mars (I bought the CD version) and I'm
having trouble building a simple "Hello World" against the dynamic RTLs.
I'm a UNIX veteral but relatively new to Windows.

$ dmc -cpp -d -Aa -Ae -Ab -Ar -Aw -ND -NL -o -ff -DNDEBUG -DWIN32_LEAN_AND_MEAN
-DSTRICT -D_WIN32_WINNT=0x0500 -I\dm\stlport\stlport -I\dm\include
-oHelloWorld.exe HelloWorld.cc

Where HelloWorld.cc is your typical brain dead test case:

#include <iostream>

int main
{
std::cout << "Hello World!" << std::endl;
return 0;
}

I would like to avoid compiling in any static libraries, so I've added the "-ND"
switch. When I remove that switch, I'm able to build, but my executable is 363K
in size! Note that I have aggressive optimization options enabled too.

In addition, I need to build against multi-threaded libraries, as I'll be using
threads heavily. The "-ND" should set _DLL and _MT which is what I want. I'm
missing something very obvious here. Any ideas? I'm thinking there must be .dll
libraries to link against but I can only find .lib files on the CD. I take it
that these are stubs? I miss UNIX already...you mean I have to export my classes
and link against stubs? Ugh.

Off topic, but I'm a commercial software developer. How are developers handling
the shipping of commercial software built with DM? Could I ship DM dynamic
runtime libraries with my product? As I say, I'd like to avoid building
statically, and I would think there could be licensing problems (ie. like
linking statically against GPL software). The GPL gets around this by having an
less restrictive LGPL which allow dynamically linking against LGPL libraries.
Is there something similiar with DM?

I doubt that many of my customers would have the DM dynamic libraries already
installed. :-)

Please help if you can...I just got the CD and was hoping to get a dynamic build
tonight but I'm frustrated at this point.

Thanks!
Michael 
Jan 27 2004
parent reply "Walter" <walter digitalmars.com> writes:
I think this does what you want:
------------------------------------------------------
C:\cbx>type test.cpp
#include <iostream>

int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}


C:\cbx>sc test.cpp -I\dm\stlport\stlport -ND
link test,,,user32+kernel32/noi;


C:\cbx>test
Hello World!

C:\cbx\ztc>dir test.exe
 Volume in drive C has no label.
 Volume Serial Number is C83C-5D49

 Directory of C:\cbx\ztc

01/27/2004  09:55 PM            14,876 test.exe
               1 File(s)         14,876 bytes
               0 Dir(s)   3,269,705,728 bytes free

C:\cbx>
-------------------------------------------------------

<michael.champigny verizon.net> wrote in message
news:bv76ss$18pj$1 digitaldaemon.com...
 I've switched from Borland to Digital Mars (I bought the CD version) and

 having trouble building a simple "Hello World" against the dynamic RTLs.
 I'm a UNIX veteral but relatively new to Windows.

 $

N
 -DSTRICT -D_WIN32_WINNT=0x0500 -I\dm\stlport\stlport -I\dm\include
 -oHelloWorld.exe HelloWorld.cc

Don't need all those switches! And name the file with a .cpp extension, which is the usual practice for C++ files in windows.
 Where HelloWorld.cc is your typical brain dead test case:

 #include <iostream>

 int main

Forgot () after main.
 {
 std::cout << "Hello World!" << std::endl;
 return 0;
 }

 I would like to avoid compiling in any static libraries, so I've added the

 switch. When I remove that switch, I'm able to build, but my executable is

 in size! Note that I have aggressive optimization options enabled too.

Optimization switches don't do anything for already built libraries.
 In addition, I need to build against multi-threaded libraries, as I'll be

 threads heavily.

All dmc libraries are multithreaded.
 The "-ND" should set _DLL and _MT which is what I want. I'm
 missing something very obvious here. Any ideas? I'm thinking there must be

 libraries to link against but I can only find .lib files on the CD. I take

 that these are stubs? I miss UNIX already...you mean I have to export my

 and link against stubs? Ugh.

At link time, one links against .lib files. At run time, the operating system looks for the corresponding .dll. You'll find the dll's in \dm\bin.
 Off topic, but I'm a commercial software developer. How are developers

 the shipping of commercial software built with DM?

No problem, just remember that DM isn't liable for whatever you ship. Also, the DM license does not allow creation of software that, if it fails, would cause significant injury or property damage. The full license is on the CD.
 Could I ship DM dynamic
 runtime libraries with my product?

Yes.
 As I say, I'd like to avoid building
 statically, and I would think there could be licensing problems (ie. like
 linking statically against GPL software). The GPL gets around this by

 less restrictive LGPL which allow dynamically linking against LGPL

 Is there something similiar with DM?

DM doesn't have a 'viral' licensing issue. You can include the dll's needed by your app.
 I doubt that many of my customers would have the DM dynamic libraries

 installed. :-)

I'm sure that will change after you ship!
 Please help if you can...I just got the CD and was hoping to get a dynamic

 tonight but I'm frustrated at this point.

No prob.
Jan 27 2004
parent Michael Champigny <Michael_member pathlink.com> writes:
Thanks Walter!

It turns out the -NL switch was causing the grief, so I dropped it.

 dmc -cpp -d -Aa -Ae -Ab -Ar -Aw -ND -NL -o -ff -DNDEBUG -DWIN32_LEAN_AND_MEA


Don't need all those switches! And name the file with a .cpp extension,
which is the usual practice for C++ files in windows.

As an aside, the -L/nomap switch doesn't seem to work. The linker still generates map files. Actually, it turns out I do need all of these flags (except -NL). If I use "-A" alone (for strict ISO/ANSI compliance), my build breaks (seems to be related to an STLport issue..._STLP_VENDOR_CSTD::fgetws undefined identifier). Looks like a namespace issue with STLport default settings? I have to enable all the C++ behavior I need explicitly. It would be nice if DM had a new switch (-As) for turning on Standard C++ behavior (ie. exceptions, wide chars, RTTI, etc.). The symbol definitions are all necessary for my real code. Of course I don't need all these switches for "HelloWorld" but for my real code, which uses exceptions, RTTI, etc. I need them. Also, because my codebase is shared across many platforms, the .cc extension has to stay. The "-d" switch works nicely for projects where portability is a concern. Borland has a similiar switch. Thanks for the help...great compiler! Michael
Jan 28 2004