GRRLIB Help
March 16, 2009 11:38PM
I can figure out how to enable GRRLIB. I have put the include files in a GRRLIB file in the include file in devkitpro.
D:\devkitPro\libogc\include\GRRLIB

I put the library files in the root of the lib folder
D:\devkitPro\libogc\lib

I copyed the additonal code from the GRRLIB Template file, but my problem is in the makefile.
it says
GRRLIB.c
linking ... pong.elf
d:/devkitpro/devkitppc/bin/../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/bin/ld.exe: cannot find -lpng
collect2: ld returned 1 exit status
make[1]: *** [/d/homebrew/mystuff/pong/pong.elf] Error 1
"make": *** [build] Error 2

I havent added any pictures to my project yet, i dont know what i'm doing wrong
thanks
Re: GRRLIB Help
March 16, 2009 11:43PM
What I had to do was put the GRRLIB include folder and the libpng include folder inside my project's SOURCE folder, then in my Makefile, my SOURCES line looks like this:
SOURCES:= source source/gfx source/GRRLIB source/GRRLIB/fonts source/libpng source/libpng/pngu
Re: GRRLIB Help
March 17, 2009 12:51AM
I'm probably making some stupid mistake, but it isn't working. i don't think the problem is in the makefile because it isn't even linking it yet.
the error i'm getting is
main.c
In file included from d:/Homebrew/mystuff/Pong/source/GRRLIB/../libjpeg/jpeglib.h:26,
                 from d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:16,
                 from d:/Homebrew/mystuff/Pong/source/main.c:10:
d:/Homebrew/mystuff/Pong/source/GRRLIB/../libjpeg/jmorecfg.h:227: error: conflicting types for 'u8'
d:/devkitPro/libogc/include/gctypes.h:15: error: previous declaration of 'u8' was here
In file included from d:/Homebrew/mystuff/Pong/source/main.c:10:
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:80: error: conflicting types for 'GRRLIB_Rectangle'
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.h:74: error: previous declaration of 'GRRLIB_Rectangle' was here
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:828: error: conflicting types for 'GRRLIB_GXEngine'
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.h:109: error: previous declaration of 'GRRLIB_GXEngine' was here
d:/Homebrew/mystuff/Pong/source/main.c:14: error: conflicting types for 'xfb'
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:23: error: previous definition of 'xfb' was here
d:/Homebrew/mystuff/Pong/source/main.c:15: error: static declaration of 'rmode' follows non-static declaration
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:24: error: previous declaration of 'rmode' was here
make[1]: *** [main.o] Error 1
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:02

Re: GRRLIB Help
March 17, 2009 02:17AM
In file included from d:/Homebrew/mystuff/Pong/source/GRRLIB/../libjpeg/jpeglib.h:26
I'm assuming from this you're trying to load a jpg file? I don't use jpegs in my project at all, all of my graphics are .PNG which are converted to .h files using WiiBuilder 1.0. I think last time I tried to use the jpeglib, it didn't work for me either.

d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:80: error: conflicting types for 'GRRLIB_Rectangle'
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.h:74: error: previous declaration of 'GRRLIB_Rectangle' was here
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:828: error: conflicting types for 'GRRLIB_GXEngine'
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.h:109: error: previous declaration of 'GRRLIB_GXEngine' was here
d:/Homebrew/mystuff/Pong/source/main.c:14: error: conflicting types for 'xfb'
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:23: error: previous definition of 'xfb' was here
d:/Homebrew/mystuff/Pong/source/main.c:15: error: static declaration of 'rmode' follows non-static declaration
d:/Homebrew/mystuff/Pong/source/GRRLIB/GRRLIB.c:24: error: previous declaration of 'rmode' was here
Hmm....maybe post your Makefile, cus it sounds like it's trying to pull from the GRRLIB files in your project source, as well as from another source, and they're conflicting.

EDIT: The more I think about this, the more I want to think you just copy/pasted the SOURCES line I posted. If that's what you did, try removing the following part sof the SOURCES line, then recompile:
source/GRRLIB source/GRRLIB/fonts



Edited 1 time(s). Last edit at 03/17/2009 03:21AM by RazorChrist.
Re: GRRLIB Help
March 17, 2009 11:24PM
Here is my makefile, and all i'm trying to do is to load a png or jpg image and print it on screen.
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC")
endif

include $(DEVKITPPC)/wii_rules

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET		:=	$(notdir $(CURDIR))
BUILD		:=	build
SOURCES:= source source/gfx source/libpng source/libpng/pngu source/libjpg source/libjpg/pngu
DATA		:=	data  
INCLUDES	:=

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS	= -g -O2 -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS	=	$(CFLAGS)

LDFLAGS	=	-g $(MACHDEP) -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS	:=	-lpng -ljpeg -lz -lfat -lwiiuse -lbte -logc -lm

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS	:= $(CURDIR)

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT	:=	$(CURDIR)/$(TARGET)

export VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
					$(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR	:=	$(CURDIR)/$(BUILD)

#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
	export LD	:=	$(CC)
else
	export LD	:=	$(CXX)
endif

export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
					$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
					$(sFILES:.s=.o) $(SFILES:.S=.o)

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE	:=	$(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
					$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
					-I$(CURDIR)/$(BUILD) \
					-I$(LIBOGC_INC)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS	:=	$(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
					-L$(LIBOGC_LIB)

export OUTPUT	:=	$(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
$(BUILD):
	@[ -d $@ ] || mkdir -p $@
	@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
	@echo clean ...
	@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol

#---------------------------------------------------------------------------------
run:
	wiiload $(TARGET).dol


#---------------------------------------------------------------------------------
else

DEPENDS	:=	$(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)

#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o	:	%.jpg
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	$(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

Re: GRRLIB Help
March 17, 2009 11:48PM
Add this to your makefile (just before or just after the .jpg rule) if you are trying to use .png buffers:

#---------------------------------------------------------------------------------
# This rule links in binary data with the .png extension
#---------------------------------------------------------------------------------
%.png.o	:	%.png
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	$(bin2o)

-include $(DEPENDS)

This will use bin2o to turn your .png images in your projects data folder into buffers.

I hope that helps,
Arikado



Edited 1 time(s). Last edit at 03/17/2009 11:49PM by Arikado.
Re: GRRLIB Help
March 18, 2009 12:17AM
Thanks, but i'm still getting an error, it seems like it can't find certain functions. thanks for the fast responce

main.c
In file included from d:/homebrew/mystuff/pong/source/GRRLIB/../libjpeg/jpeglib.h:26,
                 from d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:16,
                 from d:/homebrew/mystuff/pong/source/main.c:10:
d:/homebrew/mystuff/pong/source/GRRLIB/../libjpeg/jmorecfg.h:227: error: conflicting types for 'u8'
d:/devkitPro/libogc/include/gctypes.h:15: error: previous declaration of 'u8' was here
In file included from d:/homebrew/mystuff/pong/source/main.c:10:
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:80: error: conflicting types for 'GRRLIB_Rectangle'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.h:74: error: previous declaration of 'GRRLIB_Rectangle' was here
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:828: error: conflicting types for 'GRRLIB_GXEngine'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.h:109: error: previous declaration of 'GRRLIB_GXEngine' was here
d:/homebrew/mystuff/pong/source/main.c:14: error: conflicting types for 'xfb'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:23: error: previous definition of 'xfb' was here
d:/homebrew/mystuff/pong/source/main.c:15: error: static declaration of 'rmode' follows non-static declaration
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:24: error: previous declaration of 'rmode' was here
make[1]: *** [main.o] Error 1
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:01

Re: GRRLIB Help
March 18, 2009 12:25AM
Here is my quick run down of most of your errors. I hope this helps you.


d:/homebrew/mystuff/pong/source/GRRLIB/../libjpeg/jmorecfg.h:227: error: conflicting types for 'u8'
d:/devkitPro/libogc/include/gctypes.h:15: error: previous declaration of 'u8' was here
Linking error

d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:80: error: conflicting types for 'GRRLIB_Rectangle'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.h:74: error: previous declaration of 'GRRLIB_Rectangle' was here
Linking Error

d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:828: error: conflicting types for 'GRRLIB_GXEngine'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.h:109: error: previous declaration of 'GRRLIB_GXEngine' was here
Linking Error

d:/homebrew/mystuff/pong/source/main.c:14: error: conflicting types for 'xfb'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:23: error: previous definition of 'xfb' was here
Use a different variable name than xfb in your main.c

d:/homebrew/mystuff/pong/source/main.c:15: error: static declaration of 'rmode' follows non-static declaration
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:24: error: previous declaration of 'rmode' was here
Use a different name than rmode in your main.c



Edited 1 time(s). Last edit at 03/18/2009 12:25AM by Arikado.
Re: GRRLIB Help
March 18, 2009 12:45AM
thanks, but what should i change it to? i found the code that uses these and i just use the templete from the codemii tutorial

Here is where i found all of the rmode and xbf
	VIDEO_Init();
	WPAD_Init();
	GRRLIB_Init();

	rmode = VIDEO_GetPreferredMode(NULL);

	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);

	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(0, 640, 480);
}
Re: GRRLIB Help
March 18, 2009 01:53AM
Trying changing this:
	VIDEO_Init();
	WPAD_Init();
	GRRLIB_Init();

	rmode = VIDEO_GetPreferredMode(NULL);

	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);

	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(0, 640, 480);
}
To this:
	GRRLIB_InitVideo();
	WPAD_Init();

	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);

	WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(0, 640, 480);
}



Edited 1 time(s). Last edit at 03/18/2009 01:55AM by RazorChrist.
Re: GRRLIB Help
March 18, 2009 02:30AM
now i get this.
main.c
In file included from d:/homebrew/mystuff/pong/source/GRRLIB/../libjpeg/jpeglib.h:26,
                 from d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:16,
                 from d:/homebrew/mystuff/pong/source/main.c:10:
d:/homebrew/mystuff/pong/source/GRRLIB/../libjpeg/jmorecfg.h:227: error: conflicting types for 'u8'
d:/devkitPro/libogc/include/gctypes.h:15: error: previous declaration of 'u8' was here
In file included from d:/homebrew/mystuff/pong/source/main.c:10:
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:80: error: conflicting types for 'GRRLIB_Rectangle'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.h:74: error: previous declaration of 'GRRLIB_Rectangle' was here
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:828: error: conflicting types for 'GRRLIB_GXEngine'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.h:109: error: previous declaration of 'GRRLIB_GXEngine' was here
d:/homebrew/mystuff/pong/source/main.c:14: error: conflicting types for 'xfb'
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:23: error: previous definition of 'xfb' was here
d:/homebrew/mystuff/pong/source/main.c:15: error: static declaration of 'rmode' follows non-static declaration
d:/homebrew/mystuff/pong/source/GRRLIB/GRRLIB.c:24: error: previous declaration of 'rmode' was here
d:/homebrew/mystuff/pong/source/main.c: In function 'Initialise':
d:/homebrew/mystuff/pong/source/main.c:48: warning: implicit declaration of function 'GRRLIB_InitVideo'
make[1]: *** [main.o] Error 1
"make": *** [build] Error 2

I wonder if somebody made a template with the location of each file, and the makefile and basic main.c needed for grrlib, it might help all of us.
Re: GRRLIB Help
March 18, 2009 02:34AM
Make sure you're not including any headers more than once.
Re: GRRLIB Help
March 18, 2009 02:52AM
Ok i lost most of the errors, i put grrlib.h and grrlib.c in my header, so i got rid of grrlib.c and got this error
main.c
d:/homebrew/mystuff/pong/source/main.c: In function 'Initialise':
d:/homebrew/mystuff/pong/source/main.c:48: warning: implicit declaration of function 'GRRLIB_InitVideo'
linking ... pong.elf
d:/devkitpro/devkitppc/bin/../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/bin/ld.exe: cannot find -lpng
collect2: ld returned 1 exit status
make[1]: *** [/d/homebrew/mystuff/pong/pong.elf] Error 1
"make": *** [build] Error 2
Re: GRRLIB Help
March 18, 2009 03:12AM
It's because of this line in your Makefile:
LIBDIRS	:= $(CURDIR)
Make a folder in the directory with your Makefile, called lib, and copy the libpng.a file into it, then recompile, see if that helps.



Edited 1 time(s). Last edit at 03/18/2009 03:14AM by RazorChrist.
Re: GRRLIB Help
March 18, 2009 03:16AM
thanks, i also added a include file and put the grrlib.h and .c files in there but i still get an error, i'm so close
ain.c
d:/homebrew/mystuff/pong/source/main.c: In function 'Initialise':
d:/homebrew/mystuff/pong/source/main.c:48: warning: implicit declaration of function 'GRRLIB_InitVideo'
linking ... pong.elf
main.o: In function `Initialise':
d:/homebrew/mystuff/pong/source/main.c:48: undefined reference to `GRRLIB_InitVideo'
main.o: In function `main':
d:/homebrew/mystuff/pong/source/main.c:105: undefined reference to `GRRLIB_Render'
d:/homebrew/mystuff/pong/source/main.c:138: undefined reference to `GRRLIB_Render'
collect2: ld returned 1 exit status
make[1]: *** [/d/homebrew/mystuff/pong/pong.elf] Error 1
"make": *** [build] Error 2

Re: GRRLIB Help
March 18, 2009 05:20AM
Add the following under the rest of your #include files:
extern "C" {
	#include "GRRLIB/GRRLIB.h"
}
Re: GRRLIB Help
March 18, 2009 11:07PM
ok i'm down to 2 errors

main.c
d:/homebrew/mystuff/pong/source/main.c:14: error: expected identifier or '(' before string constant
d:/homebrew/mystuff/pong/source/main.c: In function 'Initialise':
d:/homebrew/mystuff/pong/source/main.c:52: warning: implicit declaration of function 'GRRLIB_InitVideo'
make[1]: *** [main.o] Error 1
"make": *** [build] Error 2

Re: GRRLIB Help
March 18, 2009 11:57PM
The first error is one you made and must fix in line 14 of your code. I assume you have an if statement there?
Re: GRRLIB Help
March 19, 2009 12:32AM
No, i don't
this is the code that is there
14 extern "C" {
15	 #include "GRRLIB/GRRLIB.h"
16 }
Also, as i look over my code the header file GRRLIB/GRRLIB.h is already there
Re: GRRLIB Help
March 19, 2009 10:10AM
Hey,

you don't need the extern "C" {} as you are including GRRLIB to a C-file. You'll only want to do that if you include it to a C++ file.

There is no library version of GRRLIB (if you don't create it yourself). Thus you need to put GRRLIB.h and GRRLIB.c in your project directory. For the libraries that come with GRRLIB (libjpeg, libpng), create a directory "lib" in the root of your project directory as suggested earlier. Put the libraries (.a) in that directory. The header files go in to your source folder.
You may need to change some #include statements, depending on where you put the files in your source folder.

Last step is to tell the linker where to find the libraries and which libraries to link.
Add
LIBDIRS	:= $(CURDIR)
to the Makefile to add the lib folder of your project to the directories the linker is searching for libraries. Finally tell the linker which libraries to link by adding -lpng -ljpeg to that line of your Makefile:
LIBS	:=	-lz -lwiiuse -lbte -logc -lm
Sorry, only registered users may post in this forum.

Click here to login