Thread: A really weird problem. I understand the error, but not a clue why I get the errors.

  1. #1
    Registered User Finchie_88's Avatar
    Join Date
    Aug 2004

    A really weird problem. I understand the error, but not a clue why I get the errors.

    I'm writing a program that is made of several cpp files, and when I link them together, and try compiling them, I get errors like the ones below, but when I change the name of the functions(eg. void joinsession(); becomes void join1(); ) it compiles fine a few times, but after a while the errors come back, even when the code has hardly changed, and the only way (that I know of) to solve it is to change the names again. It's really starting to annoy me, but I have no idea why it does it.
    Any ideas?
    main_winsock.o(.text+0x22):main_winsock.cpp: multiple definition of `joinsession()'
    Project1.o(.text+0x22):Project1.cpp: first defined here
    main_winsock.o(.text+0x288):main_winsock.cpp: multiple definition of `hostsession()'
    Project1.o(.text+0x288):Project1.cpp: first defined here

  2. #2
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Well, right off the bat I can tell you that people are going to slam you for not posting the relevant code, but I can take a guess at what is going on here. I really think you should read this tutorial on including multiple files in C++ project

    As a general, create a header file and have all your function prototypes in it. Then create the associated cpp file, named the same as your header file, and place the function definitions in that. Then just include your header file when you need to use those functions in your other files.

    Additionally, you may find this thread useful.
    Last edited by andyhunter; 02-20-2005 at 09:51 AM.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird problem!
    By spank in forum C Programming
    Replies: 2
    Last Post: 04-08-2006, 03:26 AM
  2. No clue what the problem is...
    By FingerPrint in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2006, 03:16 PM
  3. weird CString problem
    By axr0284 in forum Windows Programming
    Replies: 1
    Last Post: 03-18-2006, 04:05 PM
  4. weird errors
    By R3N3G4D3 in forum Windows Programming
    Replies: 0
    Last Post: 06-14-2005, 06:54 AM
  5. weird problem with passing a value..
    By Unregistered in forum C Programming
    Replies: 11
    Last Post: 06-21-2002, 09:05 AM