Compiling Multifile Program

This is a discussion on Compiling Multifile Program within the C++ Programming forums, part of the General Programming Boards category; I am trying to compile a program with two source files and a header file. A.cpp and B.cpp both include ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    2

    Compiling Multifile Program

    I am trying to compile a program with two source files and a header file. A.cpp and B.cpp both include A.h which has my variables and function prototypes. However when I compile, I get variables undefined messages. What is the proper way of doing this? Thanx

  2. #2
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    first, this is the c board, not c++, and how are you compiling, you have to link them together.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    Well you could start by saying which OS/Compiler you have

    Assuming (from your other post) that you have some windows oriented compiler with an IDE, you need to add A.cpp and B.cpp to the project source files, then choose "build"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Useless Apprentice ryan_germain's Avatar
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by chrismiceli
    first, this is the c board, not c++, and how are you compiling, you have to link them together.
    1. this is c++ board OBVIOUSLY
    2. Put the files in the same project...try that

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    > 1. this is c++ board OBVIOUSLY
    Yeah, now it is - originally it was on the C board before I moved it here
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Useless Apprentice ryan_germain's Avatar
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by Salem
    > 1. this is c++ board OBVIOUSLY
    Yeah, now it is - originally it was on the C board before I moved it here
    my bad then

  7. #7
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    use makefile

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  8. #8
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Makefiles do rule but are a pain in the arse to setup

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  2. adding an #include stops my program from compiling
    By angelscars in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2005, 05:24 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Replies: 3
    Last Post: 04-19-2004, 09:09 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21