Thread: Linking Files

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    6

    Unhappy Linking Files

    Getting an error when linking files
    "one or more multiply defined symbols found"
    i am linking a cpp file and header file and inside my header file
    i have #ifndef
    #define
    ...code
    #endif

    Anyone have a solution???

  2. #2
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    Conflicting identifiers I guess. Check if you have any variables/function named the same as another.

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Is it simply:
    Code:
    #ifndef
    #define
    
    /* Code here */
    
    #endif
    or do you have an identifier for what you're defining?
    Code:
    #ifndef MY_LIB_H
    #define MY_LIB_H
    
    #endif
    Sent from my iPadŽ

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    i have #ifndef
    #define
    ...code
    #endif
    I'm assuming by that you mean you have something like this:

    Code:
    #ifndef SOMECLASS_HEADER_H
    #define SOMECLASS_HEADER_H
    /* code */
    #endif
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Registered User
    Join Date
    Nov 2004
    Posts
    6
    yes i have #ifndef SOME_HEADER_H
    #define SOME HEADER_H

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    then are there multiple headers enclosed in the same identifier SOME_HEADER_H?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    Registered User
    Join Date
    Nov 2004
    Posts
    6
    Nope. I was reading around aparantly MSVS has this problem alot.
    "one or more multiply defined symbols found"...

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    odd. try it with another compiler and see if the results are the same...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #9
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by MT_Pockets
    i have #ifndef
    #define
    ...code
    #endif
    Hopefully by "...code" you don't mean code, but instead merely delcarations and such. Definitions of functions and data must done exactly once.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  2. html link question about linking to files for download
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-01-2004, 01:27 PM
  3. Linking Error Whenever I Tried To Use Header Files
    By javacvb in forum C++ Programming
    Replies: 5
    Last Post: 12-16-2003, 11:46 AM
  4. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM