Tutorial:Getting started: Compiling your own programs in MSL
From MSL-Libraries
Jump to navigationJump to search
- In order to be compiled by make, programs need to be in a specific location and be added to the Makefile.
- For your own programs, the special location is the myProgs subdirectory.
- Instead of editing the main Makefile, you edit the special myProgs.mk make file in the myProgs subdirectory.
- First you need to copy (or move) the myProgs/myProgs.mk.RENAME_ME to myProgs/myProgs.mk (this is done so that the distribute file does not conflict with your own customized version.
% cd myProgs
% cp myProgs.mk.RENAME_ME myProgs.mk
- Then edit the myProgs.mk, adding the name of the program (without the cpp extension) that you have created in the myProg subdirectory (let's say you named it halloMSL)
# THIS MAKE FILE IS USED TO MAKE PROGRAMS OR OBJECT THAT DO NOT BELONG
# TO THE CENTRAL REPOSITIORY WITHOUT ALTERING THE MASTER MAKEFILE
#
# 1) Rename this file to myProgs.mk
#
# 2) Place you own programs (i.e. prog1.cpp prog2.cpp) and objects (Obj1.h, Obj1.cpp)
# in the myProgs sub-directory
#
# 3) Add the program next to the MYPROG definition and the objects next to MYSOURCE
#
# Example:
# for objects Obj1.h/Obj1.cpp and Obj2.h/Obj2.cpp
#
# MYSOURCE = Obj1 Obj2
#
# for programs prog1.cpp prog2.cpp
#
# MYPROGS = prog1 prog2
#
# To compile (from the above directory):
# Objects:
# make objs/Obj1.o
# make objs/Obj2.o
#
# Programs:
# make bin/prog1
# make bin/prog2
MYSOURCE =
MYPROGS = halloMSL
MYHEADERS =
- Finally return to the main subdirectory and compile your program
% cd ..
% make helloMSL
- The program will be compiled in the subdirectory bin/. To run it
% bin/helloMSL