Menu

Graphics Program Help

2009-03-10
2012-09-26
  • StillLearning

    StillLearning - 2009-03-10

    I am trying to write a program using graphics, using header files that have been supplied by an external source. The following is the program:

    include "ccc_win.h"

    int ccc_win_main()
    {
    Point p(1, 3);
    cwin << p << Circle(p, 2.5);

    return 0;
    }

    I have added the ccc_win.h file to the project, along with the other header files it seems to use. I receive the following during compile:

    [Linker error] undefined reference to 'Point::Point(double, double)
    [Linker error] undefined reference to 'Circle::Circle(Point, double)
    [Linker error] undefined reference to 'cwin'
    [Linker error] undefined reference to 'GraphicWindow::operator<<(Point)'
    [Linker error] undefined reference to 'GraphicWindow::operator<<(Circle}'
    [Linker error] undefined reference to 'WinMain@16'

    id returned 1 exit status
    [Build Error] [Project1.exe]Error 1

    Any help would be greatly appreciated.

     
    • StillLearning

      StillLearning - 2009-03-10

      By source file(s), the ccc_win.h file does include #if defined, #define, and #elif defined for other .h files. The win.h file does not have an associated .cpp source file, the other .h files do. All (both .h and .cpp) have been added to the project and all are in the same location/folder, along with my application source file.

      Thank you for your prompt and helpful replies to share your expertise and knowledge.

       
      • Wayne Keen

        Wayne Keen - 2009-03-11

        Is there still a question pending here?

        If so, it would be best if you followed the directions for the Basic 3 and posted your compile log from the start, rather than excerpting the errors.

        Wayne

         
    • Wayne Keen

      Wayne Keen - 2009-03-10

      Please note that a header file, in most cases, is just a recipe.
      It has NO code that does anything. Associated with the header file
      will usually be either a library, or a source file that actually does
      the heavy lifting.

      This appears to be your problem. The header promises the functions
      in your error message, which allows the code to compile, but because
      there is not associated library, when it comes to linking the works,
      there is nothing there.

      Bottom line - in most cases a header file by itself is useless.

      Wayne

      p.s. I recommend you check out the section in the thread titled
      "Please Read Before Posting a Question" on the compile log,
      including headers, and linking libraries.

       
    • cpns

      cpns - 2009-03-10

      Header files are not libraries. They merely provide declarations for the content of libraries. You have to link the library too.

      If teh library were provided as a static archive, it will have a .a extension. It may also have been provided as a DLL, in which case you should also have an export library, also with a .a extension which you need to link, and you'll need teh DLL for runtime. If it were provided as source code, you need to compile an link it, and teh final possibility is that it is provided as object code, which must be linked.

      Note that if the library is provided in any form other than source, the library (or at least the export file for a DLL) must have been built with MinGW/GCC to be usable with Dev-C++.

      If your libraries have a .lib extension, they will probably not work. If all you have are the .h files, you do not have all the requisites, unless teh entire library is written as template or inline code in the header. If that is teh case, then the problem may simply be that the CCC classes exist in a namespace and need to be qualified.

      I can only find reference to using CCC with VC++, so I am guessing that you may be out of luck with Dev-C++. Lukilly VC++ 2008 Express is free and frankly, superior to Dev-C++.

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.