Having trouble with llinker and Undefined reference errors

This is a discussion on Having trouble with llinker and Undefined reference errors within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by manasij7479 What is a translation unit ? The definition is: Originally Posted by C++03 Clause 2 Paragraph ...

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,258
    Quote Originally Posted by manasij7479
    What is a translation unit ?
    The definition is:
    Quote Originally Posted by C++03 Clause 2 Paragraph 1 (part)
    A source file together with all the headers and source files included via the preprocessing directive #include, less any source lines skipped by any of the conditional inclusion preprocessing directives, is called a translation unit.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,523
    OK.. Suggest me something...
    I have multiple independent (*.h + *.cpp) pairs ...They are translation units if I understand the definition.
    All of them need to be combined into a single project..
    Till now ..I've been # including the headers in the main program...and then giving the compiler the *.cpp files together..
    Is there a better way to work with such distinct units ?
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,258
    Quote Originally Posted by manasij7479
    I have multiple independent (*.h + *.cpp) pairs ...They are translation units if I understand the definition.
    All of them need to be combined into a single project..
    Till now ..I've been # including the headers in the main program...and then giving the compiler the *.cpp files together..
    Is there a better way to work with such distinct units ?
    That's a normal way of working: you have separate source files and include headers where you need them, then finally link the object files generated to form the final product.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    Normally, all you do is add all the .cpp files to the project list of source files.

    The IDE generates a 'makefile' from this, and then make works out the minimum dependencies necessary to keep the executable up to date.
    Done well, if you edit only one source file, you only compile that source file and then run the linker to combine all the objects and libraries together.
    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.

  5. #20
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,523
    What is the difference between an IDE generated makefile and a manually made one ?...Is there some tech *magic* (!) involved so that the former one works better ?
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  6. #21
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,258
    Quote Originally Posted by manasij7479
    What is the difference between an IDE generated makefile and a manually made one ?...Is there some tech *magic* (!) involved so that the former one works better ?
    That depends on your makefile writing skills, methinks
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

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