Menu

linking user-made libs

2002-11-28
2012-09-26
  • Nobody/Anonymous

    I have a .h file, a .cpp implementation file, and a .cpp main. My implementation includes the .h file, and my .cpp main includes the .h file. all files are in the same directory. when i compile my main, i get errors of "undefined function xxxxxx" for each function in my .h file. What am i doing wrong?

     
    • Nobody/Anonymous

      are you linking against the cpp implementation file?
      From what you say it looks like you are just including the header file.

      Try the following command:
      gcc -o main.exe main.cpp otherfile.cpp

      see which messages are printed.

       
      • Nobody/Anonymous

        //.h file

        #ifndef circle_h
        #define circle_h

        void printfunction(double myint);

        #endif

        //.cpp file

        #include "circle.h"
        #include <iostream.h>

        void printfunction(double myint)
        {
        cout<<"test"<<endl;
        }

        //driver

        #include <iostream.h>
        #include "circle.h"
        int main()
        {
        printfunction;
        return 0;
        }

        ----------------------------------------------------------
        where am I including/not including files? also, can I do this without making a project? if not, which project should i choose (windows exe, empty project, etc)? I've never used project before. thanks.

         
    • Nobody/Anonymous

      You have to have both of your .cpp files in the project (if you haven't created a project yet, do so). That way Dev knows to compile them both, instead of just the one you're working on.

       
    • Curtis Sutter

      Curtis Sutter - 2002-12-06

      The project you are building in a console.

      Curtis

       

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.