Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [Tier 2] Adding own classes

Author
Message
CodeTrasher
11
Years of Service
User Offline
Joined: 18th Jul 2012
Location: Tampere, Finland
Posted: 13th Jul 2017 10:11 Edited at: 13th Jul 2017 12:50
Hi all,

I'm trying to make a simple project in C++. I am able to build and run the template_linux project without issues but I can't add any custom classes to the project. I can't create an object either by calling:

or by instancing it with 'new':


I saw that Mobiius had similar issues with his C++ code back in 2015. Here's his thread.

I haven't programmed C++ stuff in ages but I believe I'm doing it right, but for some reason template doesn't recognise my object since Netbeans is giving me undefined reference error message.

Can somebody point me in the right direction here, please? Thank you!

EDIT: I may have found the problem. All I needed to do was to add my class inside AppGameKit namespace.
Mah machine: Intel Xeon E3-1231v3 4x3.40GHz | CM Hyper 212 Evo | ASRock H97 Pro4 | 240GB SanDisk SSD | Sapphire Radeon R9 270X Dual-X 2048MB | Seagate HDD 1000GB |
8GB Crucial Ballistix Sport DDR3-1600
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 14th Jul 2017 13:14
Quote: "All I needed to do was to add my class inside AppGameKit namespace."

Hey. So you shouldn't have to add your classes inside the agk namespace to get them to work.

Quote: "Netbeans is giving me undefined reference error message."

It's hard to know for sure what's going wrong without seeing the actual error message. Do you mean you're getting linker errors? If so are you sure that the makefile is building your new source files? Or do you mean you're getting undefined symbols? If so, that suggests you might be forgetting to include a header somewhere.
CodeTrasher
11
Years of Service
User Offline
Joined: 18th Jul 2012
Location: Tampere, Finland
Posted: 15th Jul 2017 20:20
Thanks for replying, Lucas Tiridath, but I think what was the matter now.

When testing my custom class, I had the simple method to print hello world to stdout in the header file, but after expanding my class I moved the implementation from header to source file. That's where your hint was correct, I actually hadn't added the source file in the makefile. I tested it again, and it worked. My C++ is very rusty at the moment...
Mah machine: Intel Xeon E3-1231v3 4x3.40GHz | CM Hyper 212 Evo | ASRock H97 Pro4 | 240GB SanDisk SSD | Sapphire Radeon R9 270X Dual-X 2048MB | Seagate HDD 1000GB |
8GB Crucial Ballistix Sport DDR3-1600
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 19th Jul 2017 09:43
I felt my name mentioned... lol

I gave up with c++, again.
Signature removed by mod because it's larger than 600x120... please resize and try again.

Login to post a reply

Server time is: 2024-04-26 07:12:07
Your offset time is: 2024-04-26 07:12:07