Linking problems

This is a discussion on Linking problems within the C++ Programming forums, part of the General Programming Boards category; I'm having problems linking with my headers. in my game i have these files: rpg.ccp player.h player.ccp rpg and player.ccp ...

  1. #1
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65

    Question Linking problems

    I'm having problems linking with my headers.
    in my game i have these files:
    rpg.ccp
    player.h
    player.ccp

    rpg and player.ccp have #include "player.h" but both have linking errors. i pretty much don't really know what to do. if it matters im using Borland.

    Thanks for any and all help.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    And the link errors are?

  3. #3
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    well, i don't have the files on this computer...but it's something like this
    something like external blah blah player::player in RPG.OBJ
    same with player::~player

    hope u can understand that...
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Have you impemeted those functions (not just declared them in the class declaration)?

  5. #5
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    I implemented them in player.ccp
    if i could possibly get some source code of the correct way of linking or and explanation that would be great.
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Btter to see yours first and say where your going wrong

  7. #7
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    well, in rpg i have this (just the related stuff to this subject)
    Code:
    main
    {
        player usr;
        blah blah
        return 0;
    }
    
    //player.h
    
    class player
    {
       //variables and such
    }
    
    //player.ccp
    
    player::player(arguments)
    {
        //function stuff
    }
    that probably doesn't help at all but...im trying
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Try this

    Code:
    #include <iostream>
    
    class player
    {
    public:
    	player();
    };
    
    player::player()
    {
    	std::cout << "Player created";
    }
    
    int main(int argc, char** argv)
    {
    	player p;
    }

  9. #9
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    hmmm...well, i guess i could do one file. but it doesn't solve the question of why the linking doesn't work.
    but thanks for ur help.
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  10. #10
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    It should work just as well in seperate files. As long as Main.cpp and Player.cpp have Player.h then all should be well.

  11. #11
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    but that's what i have...
    i have #include "player.h" in both of them. eh...i'll ask mi padre when he gets home
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  12. #12
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    > rpg.ccp
    > player.h
    > player.ccp
    You have to make sure ALL your source files are in the project, otherwise it won't know to compile them, and the linker will then complain about not being able to find definitions for everything.

    From a simple command line, you would do
    bcc32 player.cpp rpg.cpp

    If you're using an IDE and a project, you need to achieve the same thing.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  13. #13
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    oh...i WOULD probably work if i did it as a project and not individual files. duh!
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ OpenGL linking problems
    By KoshiB in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2006, 04:25 PM
  2. Linking problems, class problems
    By Kheila in forum C++ Programming
    Replies: 12
    Last Post: 11-22-2005, 12:47 AM
  3. Linking problems trying to compile QT application
    By Maragato in forum C++ Programming
    Replies: 1
    Last Post: 08-19-2005, 09:08 PM
  4. Grrr.... SDL Linking Problem
    By 7EVEN in forum Game Programming
    Replies: 5
    Last Post: 08-12-2005, 08:44 PM
  5. More linker problems
    By Ganoosh in forum C++ Programming
    Replies: 4
    Last Post: 07-12-2005, 10:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21