Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using clang++ : how do you compile a program with multiple files

18 views
Skip to first unread message

gdo...@gmail.com

unread,
Jan 5, 2017, 3:37:31 PM1/5/17
to
given three files

GradeBook.h
GradeBook.cpp
fig03_15.cpp -- which contains main --

how do i compile this to produce and object file,
an executable, with the name fig03_15?

-----------------------------

i tried:

clang++ -o fig03_13 GradeBook.h GradeBook.cpp fig03_13.cpp

clang++ GradeBook.h GradeBook.cpp fig03_13.cpp -o fig03_13

i get:

clang: error: cannot specify -o when generating multiple output files


------------------------------
also:

clang++ GradeBook.h GradeBook.cpp fig03_13.cpp

produces an a.out that works and it produces a file named
GradeBook.h.gch


Thanks everyone,

g.

Vir Campestris

unread,
Jan 5, 2017, 4:05:25 PM1/5/17
to
Your teacher should have explained.

clang++ -o fig03_13 GradeBook.cpp fig03_13.cpp
clang++ GradeBook.cpp fig03_13.cpp -o fig03_13

ought to do it. That's your lines, but without the .h file.

Inside the cpp files you'll find a line
#include "GradeBook.h"
which is how it gets used.

Andy

gdo...@gmail.com

unread,
Jan 5, 2017, 4:11:08 PM1/5/17
to
Thanks Andy.
0 new messages