Big problem: include files with same name

support for the powerpc toolchain
Post Reply
nebiun
Posts: 91
Joined: Sat Dec 28, 2013 2:42 pm

Big problem: include files with same name

Post by nebiun » Sun Feb 18, 2024 10:29 am

Hi,
I have problems when recompile stable source code that uses assert() and include <assert.h>.
The problems appear to be due to the include assert.h in the FLAC directory which is used instead of the one in powerpc-eabi/include/assert.h.

Code: Select all

find /opt/devkitpro/ -name "assert.h"

/opt/devkitpro/devkitPPC/powerpc-eabi/include/assert.h
/opt/devkitpro/portlibs/ppc/include/FLAC/assert.h
Renaming /opt/devkitpro/portlibs/ppc/include/FLAC/assert.h solves the problem.

I think that /opt/devkitpro/portlibs/ppc/include/FLAC/assert.h should be renamed in /opt/devkitpro/portlibs/ppc/include/FLAC/FLAC_assert.h to avoid conflicts.

What do you think about?

Thanks.

nebiun
Posts: 91
Joined: Sat Dec 28, 2013 2:42 pm

Re: Big problem: include files with same name

Post by nebiun » Sun Feb 18, 2024 10:53 am

Added my Makefile.
There is some mistake?

Code: Select all

#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>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		:=	src/Basescape src/Geoscape src/Mod src/Battlescape src/Interface src/Savegame src/Engine/Adlib src/Engine/Scalers src/Engine src/Menu src/Ufopaedia src
DATA		:=	
INCLUDES	:=	include


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

CFLAGS	= -g -O2 -Wall $(MACHDEP) -D__NO_OPENGL -D__NO_DBGHELP -D__NO_MUSIC $(INCLUDE) `sdl-config --cflags`

CXXFLAGS	=	$(CFLAGS)

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

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS	:=	-lSDL_mixer -lSDL_gfx `sdl-config --libs` -lmodplug -lmad -lvorbisidec -logg -lgl2gx -lyaml-cpp -lpng -ljpeg -lfat -lz -lbz2 -lwiiuse -lbte -laesnd -logc -lm
#`freetype-config --libs` 
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS	:= $(PORTLIBS)

#---------------------------------------------------------------------------------
# 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_BIN	:=	$(addsuffix .o,$(BINFILES))
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)

export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))

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

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS	:=	$(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
                    $(foreach dir,$(PORTLIBS),-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
	@size $(OUTPUT).elf
	@nm -S --size-sort $(OUTPUT).elf  > symbols.txt
	
#---------------------------------------------------------------------------------
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)

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

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

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

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

nebiun
Posts: 91
Joined: Sat Dec 28, 2013 2:42 pm

Re: Big problem: include files with same name

Post by nebiun » Mon Feb 19, 2024 2:06 pm

Hi,
problems are in the Wii environment.

These is the include list of my application:

echo -iquote /e/WIIdev/OpenXcom-wii/include -I/opt/devkitpro/portlibs/wii/include -I/opt/devkitpro/portlibs/ppc/include -I/opt/devkitpro/portlibs/wii/include/MLlib/ -I/opt/devkitpro/portlibs/wii/include/SDL/ -I/opt/devkitpro/portlibs/wii/include/SDL2/ -I/opt/devkitpro/portlibs/wii/include/grrlib/ -I/opt/devkitpro/portlibs/wii/include/yaml-cpp/ -I/opt/devkitpro/portlibs/ppc/include/FLAC++/ -I/opt/devkitpro/portlibs/ppc/include/FLAC/ -I/opt/devkitpro/portlibs/ppc/include/freetype2/ -I/opt/devkitpro/portlibs/ppc/include/glm/ -I/opt/devkitpro/portlibs/ppc/include/harfbuzz/ -I/opt/devkitpro/portlibs/ppc/include/libmodplug/ -I/opt/devkitpro/portlibs/ppc/include/libpng16/ -I/opt/devkitpro/portlibs/ppc/include/ode/ -I/opt/devkitpro/portlibs/ppc/include/ogg/ -I/opt/devkitpro/portlibs/ppc/include/opus/ -I/opt/devkitpro/portlibs/ppc/include/tremor/ -I/opt/devkitpro/portlibs/ppc/include/vorbis/ -I/e/WIIdev/OpenXcom-wii/include -I/e/WIIdev/OpenXcom-wii/build -I/opt/devkitpro/libogc/include
-iquote /e/WIIdev/OpenXcom-wii/include -I/opt/devkitpro/portlibs/wii/include -I/opt/devkitpro/portlibs/ppc/include -I/opt/devkitpro/portlibs/wii/include/MLlib/ -I/opt/devkitpro/portlibs/wii/include/SDL/ -I/opt/devkitpro/portlibs/wii/include/SDL2/ -I/opt/devkitpro/portlibs/wii/include/grrlib/ -I/opt/devkitpro/portlibs/wii/include/yaml-cpp/ -I/opt/devkitpro/portlibs/ppc/include/FLAC++/ -I/opt/devkitpro/portlibs/ppc/include/FLAC/ -I/opt/devkitpro/portlibs/ppc/include/freetype2/ -I/opt/devkitpro/portlibs/ppc/include/glm/ -I/opt/devkitpro/portlibs/ppc/include/harfbuzz/ -I/opt/devkitpro/portlibs/ppc/include/libmodplug/ -I/opt/devkitpro/portlibs/ppc/include/libpng16/ -I/opt/devkitpro/portlibs/ppc/include/ode/ -I/opt/devkitpro/portlibs/ppc/include/ogg/ -I/opt/devkitpro/portlibs/ppc/include/opus/ -I/opt/devkitpro/portlibs/ppc/include/tremor/ -I/opt/devkitpro/portlibs/ppc/include/vorbis/ -I/e/WIIdev/OpenXcom-wii/include -I/e/WIIdev/OpenXcom-wii/build -I/opt/devkitpro/libogc/include

These directories in bold must not be added in the list: files in FLAC and FLAC++ must be referred as FLAC/file as reported in FLAC library's examples (https://github.com/xiph/flac/tree/maste ... s/c/encode)

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

Re: Big problem: include files with same name

Post by WinterMute » Wed Feb 21, 2024 3:24 pm

yaml-cpp, grrlib and MLib are not distributed nor supported by devkitPro. Please remove those includes and libs from your devkitpro folder.

I see nothing in this Makefile nor in any file we provide that would add include/FLAC/ to your include path. It must be something you've done to your environment.
Help keep devkitPro toolchains free, Donate today

Personal Blog

nebiun
Posts: 91
Joined: Sat Dec 28, 2013 2:42 pm

Re: Big problem: include files with same name

Post by nebiun » Wed Feb 21, 2024 10:02 pm

Hi, finally I find the problem.
Was in my Makefile.
I don't remember when and why I addedd this crazy instruction... :oops:

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

Sorry and thanks for your patience

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

Re: Big problem: include files with same name

Post by WinterMute » Wed Feb 21, 2024 10:45 pm

No worries.

Being honest though I think you're making life hard for yourself by attempting to shoehorn your port into a Makefile. We've spent quite a bit of time on support infrastructure that generally allows people to use existing buildsystems and thus require much less intrusive changes when compiling a port.

I've done enough here to get the project to compile and link https://github.com/WinterMute/OpenXcom/tree/dkp-port but I haven't done anything about testing the output binaries. You'll need to install ppc-yaml_cpp which I've just added to portlibs (although you'll need to delete the one I presume you compiled yourself or you'll get an error when it tries to install)

From a terminal you can configure the build for cube with this command

Code: Select all

/opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-cmake -B _cube -S . -GNinja
then this command will build

Code: Select all

cmake --build _cube
Similarly you can configure the build for wii with this command

Code: Select all

/opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -B _wii -S . -GNinja
then this command will build

Code: Select all

cmake --build _wii
You'll then find a dol in the appropriate build folder under src. It should probably be in bin along with the elf but never mind. An exercise for the reader as the saying goes.

This way makes it much, much easier to upstream changes as well.
Help keep devkitPro toolchains free, Donate today

Personal Blog

nebiun
Posts: 91
Joined: Sat Dec 28, 2013 2:42 pm

Re: Big problem: include files with same name

Post by nebiun » Thu Feb 22, 2024 7:13 am

Porting OpenXcom is not so hard.
"Standard" Makefile seem to do his work :D
My problems with the port are related to SDL for Wii:
- No default mouse emulation using wiimote (Do you remember? :) )
- And (more hard to solve) no keyboard for input base name :cry: (This is the reason of my SDLkeyboard project)

My openxcom version starts on a Wii.
With a SDL library patched from me I'm arrive to the point where I must input the base name and this stop me (at the moment...)

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

Re: Big problem: include files with same name

Post by WinterMute » Thu Feb 22, 2024 10:48 am

nebiun wrote: Thu Feb 22, 2024 7:13 am Porting OpenXcom is not so hard.
"Standard" Makefile seem to do his work :D
Well, sure. The Makefiles I wrote many years ago were intended to "just work" for most things people would want. They were written in a time when most homebrew programmers used .bat files or shell scripts instead of something more portable. What we also did along the way was to add our own compatibility layer to the toolchains and build infrastructure around them to make porting projects that use autotools and latterly cmake to produce a portable build system.

Using a "standard" Makefile seems easy, partly because of course it was meant to be, but it's much better for everyone to use the existing build system when you're porting something like this than to add a new one. Once I patched the CMakeLists.txt and the few things in the openxcom source that aren't available on wii I got something that compiles for gamecube and 3ds for free - no using different Makefiles for different platforms and the code still compiles as is for the existing platforms the project supports.

My problems with the port are related to SDL for Wii:
- No default mouse emulation using wiimote (Do you remember? :) )
I do, yes. I've just been a bit buried in a couple of other things that I thought would take much less time than they have. If you have a patch for our SDL port to add default mouse emulation then do please feel free to PR it at https://github.com/devkitPro/SDL/tree/ogc-sdl-1.2
- And (more hard to solve) no keyboard for input base name :cry: (This is the reason of my SDLkeyboard project)
Plug a usb keyboard in, I'm reasonably sure that works with SDL :P

Seriously though we also have someone doing something similar for SDL2. Eventually it would probably be good to have something more generic in libogc if that's possible. Another project for another day though.

My openxcom version starts on a Wii.
Have a go with the changes I made to get cmake working. You'll have a much better shot at getting changes merged to the upstream project if they don't affect existing builds and then everyone benefits.
With a SDL library patched from me I'm arrive to the point where I must input the base name and this stop me (at the moment...)
A PR would really be appreciated. It would make everyone's lives easier.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests