Preparation for Assignment 2

Slides:



Advertisements
Similar presentations
Makefile Ansuman Banerjee Arijit Bishnu Debapriyo Majumdar Data and File Structures Lab M.Tech. Computer Science 1 st Year, Semester I Indian Statistical.
Advertisements

Compiling. Your C, C++ or Fortran program won’t work unless you compile it The compiler will build your program as an executable file (typically in the.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
SPL – Practical Session 2 Topics: – Makefile – C++ Memory Management – Pointers.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab.
Computer Architecture and Assembly Languages Course’s web site: Teaching Assistant: Or Peri Office Hours: Thursday 37/-108.
Guide To UNIX Using Linux Third Edition
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Lecture 8  make. Overview: Development process  Creation of source files (.c,.h,.cpp)  Compilation (e.g. *.c  *.o) and linking  Running and testing.
1 uClinux course Day 3 of 5 The uclinux toolchain, elf format and ripping a “hello world”
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Enabling the ARM Learning in INDIA ARM DEVELOPMENT TOOL SETUP.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
Setting up Eclipse Computer Organization I 1 August 2009 ©2009 McQuain Getting Eclipse for C/C++ Development Go to and click on Download.
Developing C/C++ applications with the Eclipse CDT David Gallardo.
Old Chapter 10: Programming Tools A Developer’s Candy Store.
Active-HDL Interfaces Debugging C Code Course 10.
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
System Programming - LAB 1 Programming Environments.
ENEE150 – 0202 ANDREW GOFFIN Introduction to ENEE150.
UNIT 13 Separate Compilation.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
Makefile M.A Doman. Compiling multiple objects Card.cpp -> Card.o Deck.cpp -> Deck.o main.cpp -> main.o main.o Deck.o Card.o -> Dealer.exe.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
1 How to Install OpenGL u Software running under Microsoft Windows makes extensive use of "dynamic link libraries." A dynamic link library (DLL) is a set.
More Unix Naomi Altman. Directories Directory = folder mkdir - makes a new directory rmdir - removes an empty directory cd mydirectory - moves you into.
Open project in Microsoft Visual Studio → build program in “Release” mode.
Chapter Linux Basics. Acknowledgements This presentation was prepared by – Banyat Settapanich – Bahran Madaen This presentation will be updated later.
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
 CSC 215 : Procedural Programming with C C Compilers.
RTLAB Kang. Moo jin Using Open Source Tools for AT91SAM7X Cross Development.
Day 1 Session 2. Setup & Installation
Review Why do we use protection levels? Why do we use constructors?
Multiple file project management & Makefile
Makefiles CSSE 332 Operating Systems
Cygwin: getting the setup tool
Development Environment
Getting Eclipse for C/C++ Development
Computer Terms Review from what language did C++ originate?
Introduction to Computer CC111
Compilation and Debugging
Compilation and Debugging
The Linux Operating System
Editor, Compiler, Linker, Debugger, Makefiles
CS1010 Programming Methodology
Getting started in Eclipse
CS1010 Programming Methodology
SPL – Practical Session 2
Computer Systems and Networks
Choice of Programming Language
CMPE 152: Compiler Design ANTLR 4 and C++
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
C Programming Lecture Series
Makefiles and Notes on Programming Assignment PA2
Getting Started: Developing Code with Cloud9
Header files.
Created by Hwansoo Han Edited by Ikjun Yeom
Setting up CDT Makefile project
Software Setup & Validation
Yung-Hsiang Lu Purdue University
Appendix F C Programming Environment on UNIX Systems
Getting Eclipse for C/C++ Development
Computer Terms Review from what language did C++ originate?
CSCE 206 Lab Structured Programming in C
HW4: Due Nov 22nd 23:59 Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also,
Makefiles, GDB, Valgrind
SPL – PS1 Introduction to C++.
g++ features, better makefiles
Presentation transcript:

Preparation for Assignment 2 Practical Session 4 Preparation for Assignment 2 Topics: C++ Eclipse – On Windows. MinGW, msys, OpenCV C++ Compilation Process dos2unix, unix2dos utility makefile

Setting up our programing environment At Home, Windows: IDE: Eclipse for C++ Compiler: MinGW, contains g++ Optional: Unix Like Shell: msys For Assignment 2: OpenCV (external library) At Labs, Linux: http://www.cs.bgu.ac.il/~spl121/PracticalSession04

C++ Eclipse Eclipse is just an IDE: Download: Integrated Development Environment Does not provide a compiler! Download: Eclipse IDE for C/C++ Developers http://www.eclipse.org/downloads/ Install to C:\eclipse for ease of use.

g++ We need a compiler to compile our programs! Download MinGW: http://sourceforge.net/projects/mingw/files/latest/download Install: Preferred place: c:\eclipse\MinGW\ While installing select these components: C++ Compiler MinGW Development Toolkit (contains msys)

Unix like shell for Windows Name: msys Why use it? Useful when testing your makefiles! Installation: Already done with MinGW installation. Program path: C:\eclipse\MinGW\msys\1.0\ Exactly like a Linux shell. Can cp, rm, mkdir, and make.

Eclipse, MinGW, msys, and $PATH What is $PATH: Environment variable. Contains paths of certain programs. Why should I care? To let Eclipse know where is the compiler at. Eclipse checks the $PATH variable. Not there? No compiler for eclipse! Where is it? Control Panel\System and Security\System\Advanced System Settings\Environment Variables\PATH How do I change it? Just add “C:\eclipse\MinGW\bin\;c:\eclipse\msys” to its end. Note: Each program path must be separated by “;”.

New C++ Project Run Eclipse File -> New -> C++ Project Project Name: Name of project. Project Type: Executable -> Empty Project Toolchains: MinGW GCC Click on Finish. Create three directories: (good programming style!) “src” for .cpp files. “include” for .h files. “bin” folder for binary (.o and .a) files.

OpenCV What is it? Homepage: Note: Open (Source) Computer Vision Library. An external library. A graphical library. Contains around 500 functions especially made for image processing. Made originally by Intel, maintained today by willowgarage. Homepage: http://opencv.willowgarage.com/wiki/ Note: You need to use it as a Black box. You don’t need to understand its code. You don’t need to understand why it works. All you need to know is how to use it! Work with the API only! Learn what the function needs as input. Learn what it returns. Learn what it does! Not how it does it!

OpenCV Download: Install path: API: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/OpenCV-2.3.1-win-superpack.exe/download Install path: C:\eclipse\ It will make a directory named “opencv” under eclipse path. API: http://opencv.itseez.com/ http://opencv.itseez.com/modules/refman.html

Adding OpenCV to project After creating your project. Goto Project -> Properties C/C++ Build -> Settings GCC C++ Compiler -> Includes Under Include Path we add: c:\eclipse\opencv\build\include MinGW C++ Linker -> Libraries Under Libraries we add: Core OpenCV libraries: opencv_core231 opencv_highgui231 Other OpenCV libraries : opencv_imgproc231 opencv_calib3d231 opencv_feature2d231 opencv_video231 opencv_objdetect231 opencv_ml231 opencv_gpu231 Note: 231 is the library version. In this case: 2.3.1 Under Libraries search path we add: C:\eclipse\opencv\build\x86\mingw\lib

Windows and OpenCV If you wish to run the executable file as a standalone, and not from eclipse. You need OpenCV’s dll files. Copy the dll files from: C:\eclipse\opencv\build\x86\mingw\bin To your Windows system directory: C:\Windows\system\ Then you can run any executable program that includes OpenCV code.

C++ Compilation Process Input: C++ Code, .h and .cpp files. Preprocessor: Removes comments interpreting special preprocessor directives denoted by #: #include <math.h> – paste in the standard library math file. #include "My.h" – paste in the file My.h from the same directory (relative path) C++ Compiler: Converts C++ code to Assembly code What is Assembler? Programming language. Lower level than C++ Example code: http://www.assembly.happycodings.com/code1.html Assembler: Converts the Assembly code to object code – “.o” files. – this is machine code. Not executable until linking is done! Linker: Takes several object code files, and links them together into an executable “.a” files. Output: Executable file.

dos2unix Why? Why should I care? Solution? Linux and Windows text files are not the same! Windows new line is \r\n Linux new line is \n Why should I care? Work at home? Windows? Work at labs? Unix? Allows you to test your files at the Linux labs if you solved your assignment at home. Solution? Utility that changes the format of text files from DOS format (Windows) to Unix format (Linux). What about the other way around? unix2dos: converts from Linux to DOS format. Usage: dos2unix input.txt output.txt Run this under using msys shell. Note: Your file format must be suitable for Linux testing environment.

makefile What is makefile? Why makefile? How do we run it? It is a text file called “makefile”. Contains functions that allows us to compile c++ programs. Why makefile? Allows us to compile c++ programs with a single command. How do we run it? You use “make” program. make can read the makefile and run the appropriate function depending on user request. Example: make clean This line runs a function named “clean”.

makefile example Comment: # All Targets Define Variables: CC, FLAGS, … # define some Makefile variables for the compiler and compiler flags # to use Makefile variables later in the Makefile: $() CC = g++ CFLAGS = -g -Wall OBJECT_FILES = run.o imageloader.o INCLUDE_LIBRARIES = -I/usr/local/include/opencv -I/usr/local/include SHARED_LIBRARIES = -L/usr/local/lib OPENCV_LIBS = -lopencv_core -lopencv_highgui # All Targets all: run # Tool invocations # Executable "run" depends on the files imageloader.o and run.o. run: $(OBJECT_FILES) @echo 'Building target: run' @echo 'Invoking: C++ Linker' $(CC) $(CFLAGS) $(OBJECT_FILES) -o $@ $(INCLUDE_LIBRARIES) $(SHARED_LIBRARIES) $(OPENCV_LIBS) @echo 'Finished building target: run' @echo ' ' # Depends on the source and header files imageloader.o: src/imageloader.cpp include/imageloader.h $(CC) $(CFLAGS) $< -c -o $@ $(INCLUDE_LIBRARIES) $(SHARED_LIBRARIES) $(OPENCV_LIBS) run.o: src/run.cpp #Clean the build directory clean: rm -rf *.o run Comment: # All Targets Define Variables: CC, FLAGS, … Use Variables: $(CC), $(FLAGS) Function definition: clean: Function with dependencies: all: run Dependencies mean that you run the functions that your function depends on, then your function after. Printing to shell: @echo ‘Building target: run’ $<: the first item in the dependencies list for this function: 1st $< is src/imageloader.cpp 2nd $< is src/run.cpp -o $@: the output file name is the function name. 1st –o $@ is run 2nd –o $@ is imageloader.o 3rd -o $@ is run.o