Professional Documents
Culture Documents
Nguyn Vn Khit
Ni dung
Bin dch chng trnh C++ Cch thc to Makefile V d Lm vic vi C#
Example
//mypoint.h #ifndef __MYPOINT_H__ #define __MYPOINT_H__ class MyPoint { private: int x,y; public: MyPoint(int x,int y); void Move(int xoffset,int yoffset); void CurPos(); }; #endif
Example
//mypoint.cpp #include <iostream.h> #include "mypoint.h" MyPoint::MyPoint(int x,int y) { this->x = x; this->y = y; } void MyPoint::Move(int xoffset,int yoffset) { x+= xoffset; y+= yoffset; } void MyPoint::CurPos() { cout<<"I'm at ("<<x<<","<<y<<")"<<endl; }
Example
//main.cpp #include <iostream.h> #include "mypoint.h" void main() { cout<<"Hello, there!"<<endl; MyPoint p(3,4); p.CurPos(); p.Move(2,3); p.CurPos(); cout<<"Bye!"<<endl; }
Example
Linux: g++ -c main.cpp mypoint.cpp g++ main.o mypoint.o o point Windows (VC++ 6.0): cl /c main.cpp mypoint.cpp link main.obj mypoint.obj /out:point.exe
Khi all : cha thnh phn to ra thnh phn chnh. Khi clean : thnh phn cui cng
Makefile
Linux: //Makefile all: point point: main.o mypoint.o g++ main.o mypoint.o o point main.o: main.cpp mypoint.h g++ -c main.cpp mypoint.o: mypoint.cpp mypoint.h g++ -c mypoint.cpp
Makefile
Windows: //Makefile all: point point: main.obj mypoint.obj link main.obj mypoint.obj /out:point.exe main.obj: main.cpp mypoint.h cl /c main.cpp mypoint.obj: mypoint.cpp mypoint.h cl /c mypoint.cpp
Makefile
//Makefile all: point point: main.o mypoint.o g++ $(CFLAGS) main.o mypoint.o o point main.o: main.cpp mypoint.h g++ $(CFLAGS) -c main.cpp mypoint.o: mypoint.cpp mypoint.h g++ $(CFLAGS) -c mypoint.cpp
Makefile
make make CFLAGS=-O2 make CFLAGS=-g
Lm vic vi C#
Tng t nh vi C++. Lnh command line ca C# : csc V d csc /out:MyProg.exe Form1.cs Form1.Designer.cs Program.cs
Lm vic vi C#
Cc tham s khc ca csc:
/target : loi assembly s c sinh ra /reference (/r): cc tham chiu trong qu trnh dch /lib : xc nh cc th mc tm th vin