Thread: undefined reference to...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    1

    undefined reference to...

    Ok, before I describe the problem I think I must give you some background info.

    1)I'm a Linux newbie. I've just installed the Fedora Core 6 Linux distribution.
    2)I've installed the MPICH2 program (contains libraries for parallel algorithm programming) <-- double and triple checked: No problem in the installation.
    3)I'm working with KDevelop. I can compile and build simple C++ programmes without problem.

    But when I use libraries from MPICH2, I get the following error message during the build:

    undefined reference to `MPI_Init'
    undefined reference to `MPI_Comm_rank'
    undefined reference to `MPI_Comm_size'
    ... and the list goes on ...

    How is it possible that the KDevelop compiler recognizes these (functions/procedures(?) whatever) during compilation but not during build?

    Anyway, I'm not expecting that any of you has used this specific program, but I guess that you'll have encountered similar errors in other cases too and dealt with them.
    PLEASE HELP!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Compiling and linking are separate steps in creating a program. So when compiling your code, the KDevelop compiler can find the declarations of the functions, classes, etc. you are using because you are correctly including the library headers and the headers can be found by the compiler by looking in the include paths. The linking is probably failing either because you are failing to tell the KDevelop linker which library files you want to link to, or because it caanot find the library files in its linker path.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM