• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

compile multi source program

hello, all
      
  i am beginner of linux programming. I create a header file "A.h" save in "../inc", and the source file saved in in "../Cpp/B.cpp", which includes "A.h". How can i perform compilation by using g++?

thanx in advance.
kim
0
kim_wei
Asked:
kim_wei
  • 2
1 Solution
 
stefan73Commented:
Hi kim_wei,
Simply type

g++ -I ../inc ../Cpp/B.cpp -o B_binary

Cheers!

Stefan
0
 
stefan73Commented:
-I sets the include path. You can combine multiple -I, like

g++ -Idir1 -Idir2 -Idir3 ... file1.cpp file2.cpp ... -o output_path_and_name

But don't write spaces between -I and the path, so your command line should be
g++ -I../inc ../Cpp/B.cpp -o B_binary
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now