compiling help/question

support for the powerpc toolchain
Post Reply
DacoTaco
Posts: 16
Joined: Tue Sep 22, 2009 5:37 pm

compiling help/question

Post by DacoTaco » Tue Sep 22, 2009 5:48 pm

now im not the best coder around but i did want to import my C++ lib to my next wii test project...
however; it was completely written in C++

i was hoping to compile in C++ instead of C but thats not possible i was thinking

then i was looking around and i saw ppl using main.cpp stuff so maybe it was me doing all shit wrong.

so i renamed my name to a cpp but...

main.c -> c:/stuff/devkitPro/Projects/Test/source/TestClass/Client.h(15): error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TestClass'
well, C doesn't support a class so we know why it says that

main.cpp -> 1>make[1]: *** No rule to make target `c:/stuff/devkitPro/Projects/Test/source/main.c', needed by `main.o'. Stop.
where the hell did that main.c come from? shouldn't makefile look for both c & cpp?


so, am i doomed to use shit structs to get a class feel or am i missing something here?

thx in advance. >_>

EDIT: its fixed. reloaded project and it worked (must've had it saved somewhere that i was still main.c) but now im having compile issues deu to the importing stuff. *looks up how he should import PCSTR & addrinfo*

EDIT : fixed that too. but now i have this:

1>c:/stuff/devkitPro/Projects/includeTest/source/main.cpp(126): undefined reference to `ClassClient::Init()'
1>c:/stuff/devkitPro/Projects/includeTest/source/main.cpp(128): undefined reference to `ClassClient::SetInfo(std::string, char const*)'
1>c:/stuff/devkitPro/Projects/includeTest/source/main.cpp(132): undefined reference to `Killtest();

Code: Select all

//main.cpp

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <network.h>
#include <unistd.h>
#include <string.h>
#include "Networking\Networking.h"

static void *xfb = NULL;
GXRModeObj *vmode;
void WaitForAButton();
void InitNetwork();

#define HOSTNAME "www.google.com"
using namespace std;

//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

	// Initialise the video system
	VIDEO_Init();
	
	// This function initialises the attached controllers
	WPAD_Init();
	
	// Obtain the preferred video mode from the system
	// This will correspond to the settings of TV
	switch (VIDEO_GetCurrentTvMode ())
    {
    case VI_NTSC:
      vmode = &TVNtsc480IntDf;
      break;

    case VI_PAL:
      vmode = &TVPal528IntDf;
      break;

    case VI_MPAL:
      vmode = &TVMpal480IntDf;
      break;

    default:
      vmode = &TVNtsc480IntDf;
      break;
    }

	/*** Let libogc configure the mode ***/
	VIDEO_Configure(vmode);
	
	// Allocate memory for the display in the uncached region
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
	
	// Initialise the console, required for printf
	console_init(xfb,20,20,vmode->fbWidth,vmode->xfbHeight,vmode->fbWidth*VI_DISPLAY_PIX_SZ);
	
	
	// Tell the video hardware where our display memory is
	VIDEO_SetNextFramebuffer(xfb);
	
	// Make the display visible
	VIDEO_SetBlack(FALSE);

	// Flush the video register changes to the hardware
	VIDEO_Flush();

	// Wait for Video setup to complete
	VIDEO_WaitVSync();
	if(vmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();


	// The console understands VT terminal escape codes
	// This positions the cursor on row 2, column 0
	// we can use variables for this with format codes too
	// e.g. printf ("\x1b[%d;%dH", row, column );
	printf("\x1b[2;0H");
	

	//printf("waiting to start test and test's init (network & reset)...(press A)\n");
	int space = 0;
	for(space = 0;space < 79;space++)
	{
		printf("1");
	}
	printf("\n11");
	for(space=0;space <= 24;space++)
	{
		printf(" ");
	}
	printf("DacoTaco's Network Tester");
	for(space=0;space <= 24;space++)
	{
		printf(" ");
	}
	printf("11\n");
	for(space = 0;space < 79;space++)
	{
		printf("1");
	}
	printf("trying to init stuffz...\n");
	Initstuffz();
	WaitForAButton();
	Classtest test;
	while(1)
	{
		test.Init();
		test.SetInfo(HOSTNAME,"80");
		WaitForAButton();
		break;
	}
	Killtest();
	return 0;
}
in networking.h should be an include to client.h which should have the class. this worked fine when compiling for windows...
also, including the client.h on it self doesn't help cause it'll say redefinition ...
and since im importing a C++ "lib" of mine (for windows its lib, for wii currently its just a bunch of code you include) what is the point of including 3 things just to get 1 part of the lib? :/

hell, Killtest(); is found in networking.h/cpp ...

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: compiling help/question

Post by WinterMute » Tue Sep 22, 2009 9:48 pm

DacoTaco wrote:
main.cpp -> 1>make[1]: *** No rule to make target `c:/stuff/devkitPro/Projects/Test/source/main.c', needed by `main.o'. Stop.
where the hell did that main.c come from? shouldn't makefile look for both c & cpp?
This one is caused by the automatic dependency generation, either delete build/main.d or make clean when you've renamed a file like this.
hell, Killtest(); is found in networking.h/cpp ...
Assuming you mean Networking is a subdirectory of source then add it to the Makefile.

Code: Select all

SOURCES		:=	source source/Networking
I'd guess the Makefile hasn't picked up networking.cpp
Help keep devkitPro toolchains free, Donate today

Personal Blog

DacoTaco
Posts: 16
Joined: Tue Sep 22, 2009 5:37 pm

Re: compiling help/question

Post by DacoTaco » Wed Sep 23, 2009 6:13 am

thx. didn't think that was needed...
/noob

now to go on and fix all this importing mess XD

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests