Find the answer to your Linux question:
Results 1 to 4 of 4
Hi. I have a C++ project that I can't compile. These are the files: iplookup.cc pastebin.com/rFBgAN0r iplookup.hh pastebin.com/RDs85kYT iproute.cc pastebin.com/03wNgcUb iproute.hh pastebin.com/JXjNiJ7Q main.cc pastebin.com/tRE29zCJ Makefile: pastebin.com/72AXnZPx When I do: $ ...
  1. #1
    Just Joined!
    Join Date
    Mar 2011
    Posts
    3

    undefined reference to.... (g++ error message)

    Hi.
    I have a C++ project that I can't compile.
    These are the files:

    iplookup.cc
    pastebin.com/rFBgAN0r

    iplookup.hh
    pastebin.com/RDs85kYT

    iproute.cc
    pastebin.com/03wNgcUb

    iproute.hh
    pastebin.com/JXjNiJ7Q

    main.cc
    pastebin.com/tRE29zCJ

    Makefile:
    pastebin.com/72AXnZPx

    When I do:
    $ make:all

    I get:
    pastebin.com/m7nRhmxM

    I've found dozens of cases like this in google, but none worked for me.

    Any suggestions??

    Thanks a lot!!!

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    You are not linking a required library that contains the iproute class implementation.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Mar 2011
    Posts
    3
    Thanks. Theoretically, that's the problem. However, the project compiles now. I just removed the "inline" modifiers and it works. Obviously, I didn't want to do that (for performance reasons).

    The thing is that I don't know why it worked.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Yes, well I didn't look at your source code before. Inlines cannot be seen outside of the translation unit they are compiled into. IE, you would need to define them in the header file, otherwise they are only visible in the .cc file where they are defined. For get/set methods like many of these, it is best to simply implement them in the class definition (in the header file) as that will inline them automatically.

    In any case, this is the reason why you were getting the undefined references.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...