Results 1 to 8 of 8

Thread: Need help with a code please help :D

  1. #1
    Join Date
    Sep 2017
    Posts
    15
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Need help with a code please help :D

    Hey guys im new to QT programming im writing my first QT c++ game now ive tried to solve this by my self i just cant understand the problem i hope you can help me
    i get an error "player.obj : error LNK2019: unresolved external symbol "public: __cdecl Spaceship::Spaceship(void)" (??0Spaceship@@QEAA@XZ) referenced in function "public: void __cdecl Player::spawn(void)" (?spawn@Player@@QEAAXXZ)"

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Need help with a code please help :D

    You haven't linked in the object file that implements your "Spaceship" class code, probably because it isn't being compiled because you haven't included the .cpp file in your project's list of source files. The project compiles because you have included the .h file that defines the Spaceship class and its methods, but your problem is a linker error, which takes place after compilation is done.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2017
    Posts
    58
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Need help with a code please help :D

    I'm not sure, but I think I got same or similar error due to circular dependencies of header files.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Need help with a code please help :D

    I'm not sure, but I think I got same or similar error due to circular dependencies of header files.
    That's more likely to result in a compile-time error. Not being able to find a symbol at link time means a library or object file isn't being linked in (or the wrong one -is- being linked in but it doesn't include the symbols being sought after).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Sep 2017
    Posts
    15
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Need help with a code please help :D

    Ill upload my code and you can see what ive done and whats not.
    tnx for your fast comment
    this is my code:
    https://github.com/SeanR11/Spaceship---first-game

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Need help with a code please help :D

    Having your .cpp and .h source code files is useless. What is needed is the project file or Makefile that is used to build your code into an executable. It is there where you are missing the information needed to tell the build tool chain how to build your project.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  7. #7
    Join Date
    Jul 2017
    Posts
    37
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Need help with a code please help :D

    Are you using cmake or qmake? If cmake, you have a file CMakeLists.txt with a line like this:
    Qt Code:
    1. add_executable(game main.cpp player.cpp game.cpp)
    To copy to clipboard, switch view to plain text mode 
    Add "spaceship.cpp" to the list of cpp files and your problem should go away.

  8. #8
    Join Date
    Sep 2017
    Posts
    15
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Need help with a code please help :D

    Guys first of all thanks you both for your help
    PierreA ur answer actually helped i went to "build" and clicked "build qMake" and it actually fixed my problem.. without adding anything

Similar Threads

  1. Replies: 7
    Last Post: 6th September 2012, 07:07
  2. GUI Code
    By waynew in forum Newbie
    Replies: 2
    Last Post: 12th October 2009, 12:12
  3. SSH through Qt code
    By lrrcaldas in forum Qt Programming
    Replies: 2
    Last Post: 28th August 2007, 15:45
  4. Pasting code from code tag in emacs
    By Gopala Krishna in forum General Discussion
    Replies: 0
    Last Post: 16th February 2007, 05:47
  5. use of VC++ code in Qt
    By shailesh in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 11:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.