www.digitalmars.com         C & C++   DMDScript  

c++.command-line - compiling and linking modules

reply manuel <manuel_member pathlink.com> writes:
I have downloaded digital mars c++ compiler for Windows 32, in the readme file
it is explaned how to compile a simple program with one file (that contains
main). Now suppose that i have 2 or 3 files

//m1.h
class A{
public:
void makeAThing();
};

//m1.cpp
#include "m1.h"
void A::makeAThing(){ };

//prog.cpp
#include "m1.h"
int main(){
A a;
a.makeAThing();
}

how can I compile and link the project?

How can i compile a project, if prog include m1 and m1 include m2?
//m2.h
class B{
public:
void makeAThing();
};

//m2.cpp
#include "m2.h"
void B::makeAThing() { }

//m1.h
#include "m2.h"
class A{
B b;
public:
void makeAThing();
};

//m1.cpp
#include "m1.h"
void A::makeAThing() { }

//prog.cpp
#include "m1.h"
int main(){
A a;
a.makeAThing();
}
Dec 17 2002
next sibling parent user domain.invalid writes:
Create a make file. smake.exe is included (isn't it?) but you are 
free to use any 'make' you want.

Or do a good investment and buy the cd as a christmas present for 
your self! It's really cheap for what you get!

manuel wrote:
 I have downloaded digital mars c++ compiler for Windows 32, in the readme file
 it is explaned how to compile a simple program with one file (that contains
 main). Now suppose that i have 2 or 3 files
 
 //m1.h
 class A{
 public:
 void makeAThing();
 };
 
 //m1.cpp
 #include "m1.h"
 void A::makeAThing(){ };
 
 //prog.cpp
 #include "m1.h"
 int main(){
 A a;
 a.makeAThing();
 }
 
 how can I compile and link the project?
 
 How can i compile a project, if prog include m1 and m1 include m2?
 //m2.h
 class B{
 public:
 void makeAThing();
 };
 
 //m2.cpp
 #include "m2.h"
 void B::makeAThing() { }
 
 //m1.h
 #include "m2.h"
 class A{
 B b;
 public:
 void makeAThing();
 };
 
 //m1.cpp
 #include "m1.h"
 void A::makeAThing() { }
 
 //prog.cpp
 #include "m1.h"
 int main(){
 A a;
 a.makeAThing();
 }
 
 
Dec 17 2002
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
"manuel" <manuel_member pathlink.com> wrote in message
news:atnq9n$10cc$1 digitaldaemon.com...
 I have downloaded digital mars c++ compiler for Windows 32, in the readme
file
 it is explaned how to compile a simple program with one file (that
contains
 main). Now suppose that i have 2 or 3 files

 //m1.h
 class A{
 public:
 void makeAThing();
 };

 //m1.cpp
 #include "m1.h"
 void A::makeAThing(){ };

 //prog.cpp
 #include "m1.h"
 int main(){
 A a;
 a.makeAThing();
 }

 how can I compile and link the project?
sc -c prog.cpp sc -c m1.cpp sc prog.obj m1.obj
Dec 17 2002
next sibling parent reply "Rajiv Bhagwat" <dataflow vsnl.com> writes:
Do this instead: It is lot less typing<g>

sc prog1 m1


"Walter" <walter digitalmars.com> wrote in message
news:atogog$1got$1 digitaldaemon.com...
 "manuel" <manuel_member pathlink.com> wrote in message
 news:atnq9n$10cc$1 digitaldaemon.com...
 I have downloaded digital mars c++ compiler for Windows 32, in the
readme
 file
 it is explaned how to compile a simple program with one file (that
contains
 main). Now suppose that i have 2 or 3 files

 //m1.h
 class A{
 public:
 void makeAThing();
 };

 //m1.cpp
 #include "m1.h"
 void A::makeAThing(){ };

 //prog.cpp
 #include "m1.h"
 int main(){
 A a;
 a.makeAThing();
 }

 how can I compile and link the project?
sc -c prog.cpp sc -c m1.cpp sc prog.obj m1.obj
Dec 18 2002
parent manuel <manuel_member pathlink.com> writes:
when I input the command sc prog1 m1, the compiler send  this message:
fatal error: unable to open 'm1.h'


In article <atpd3g$257n$1 digitaldaemon.com>, Rajiv Bhagwat says...
Do this instead: It is lot less typing<g>

sc prog1 m1


"Walter" <walter digitalmars.com> wrote in message
news:atogog$1got$1 digitaldaemon.com...
 "manuel" <manuel_member pathlink.com> wrote in message
 news:atnq9n$10cc$1 digitaldaemon.com...
 I have downloaded digital mars c++ compiler for Windows 32, in the
readme
 file
 it is explaned how to compile a simple program with one file (that
contains
 main). Now suppose that i have 2 or 3 files

 //m1.h
 class A{
 public:
 void makeAThing();
 };

 //m1.cpp
 #include "m1.h"
 void A::makeAThing(){ };

 //prog.cpp
 #include "m1.h"
 int main(){
 A a;
 a.makeAThing();
 }

 how can I compile and link the project?
sc -c prog.cpp sc -c m1.cpp sc prog.obj m1.obj
Dec 22 2002
prev sibling next sibling parent manuel <manuel_member pathlink.com> writes:
I try what you wrote to me, but message error:
fatal error: unable to open input file 'm1.h'
when I input command sc -c prog.cpp

In article <atogog$1got$1 digitaldaemon.com>, Walter says...
"manuel" <manuel_member pathlink.com> wrote in message
news:atnq9n$10cc$1 digitaldaemon.com...
 I have downloaded digital mars c++ compiler for Windows 32, in the readme
file
 it is explaned how to compile a simple program with one file (that
contains
 main). Now suppose that i have 2 or 3 files

 //m1.h
 class A{
 public:
 void makeAThing();
 };

 //m1.cpp
 #include "m1.h"
 void A::makeAThing(){ };

 //prog.cpp
 #include "m1.h"
 int main(){
 A a;
 a.makeAThing();
 }

 how can I compile and link the project?
sc -c prog.cpp sc -c m1.cpp sc prog.obj m1.obj
Dec 22 2002
prev sibling parent reply manuel <manuel_member pathlink.com> writes:
I was mistaken in my previous post, the command line sc works perfectly, it's
fantastic, now my simple test program runs, thank you very much and merry
cristmas.

P.S. But where did you find  this informations, i didn't found them in readme
file, neither any link on digital mars site.



 how can I compile and link the project?
sc -c prog.cpp sc -c m1.cpp sc prog.obj m1.obj
Dec 22 2002
parent reply "Daniel Fazekas" <fds mailbox.hu> writes:
"manuel" <manuel_member pathlink.com> wrote in message
news:au4l7b$1bqd$1 digitaldaemon.com...
 P.S. But where did you find  this informations, i didn't found them in
readme
 file, neither any link on digital mars site.
As it happens, he's the author of digital mars. :) But check this link: http://www.digitalmars.com/ctg/ctg.html -- Daniel
Dec 22 2002
parent manuel <manuel_member pathlink.com> writes:
In article <au4qt0$1flc$1 digitaldaemon.com>, Daniel Fazekas says...
But check this link:
http://www.digitalmars.com/ctg/ctg.html

--
Daniel
Thank you. Do you also know how to make a makefile for a project where prog.cpp include m1 (#include "m1.h") and m1 include m2: //prog.cpp #include "m1.h" int main {... .. } //m1.h #include "m2.h" class A { .. } //m1.cpp #include "m1.h" .. //m2.h class ... //m2.cpp ..
Dec 26 2002