[SDL2]-3D Ray Casting Demo-Need Some Help!

[SDL2]-3D Ray Casting Demo-Need Some Help!

Hi,

We found some source code for an SDL2 ray casting demo.
We have incorporated it into our cross-platform SDL2 game engine.

Our issue now is it won’t build on Linux?
(builds fine on Windows)

You can download the entire project below:
http://16bitsoft.com/files/3dRayCasting/Demo/3dRayCasting-Demo.zip

Any help fixing errors on Linux would be appreciated!

[Image: http://16bitsoft.com/files/3dRayCasting/Demo/RayCastingScreenshot-01.png ]------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

What errors are you getting? Are they specific to SDL or is this just a
request for help in general?

Jonny DOn Thu, May 14, 2015 at 4:49 AM, JeZ-l-Lee < JessePalserMailingLists at gmail.com> wrote:

[SDL2]-3D Ray Casting Demo-Need Some Help!

Hi,

We found some source code for an SDL2 ray casting demo.
We have incorporated it into our cross-platform SDL2 game engine.

Our issue now is it won’t build on Linux?
(builds fine on Windows)

You can download the entire project below:
http://16bitsoft.com/files/3dRayCasting/Demo/3dRayCasting-Demo.zip

Any help fixing errors on Linux would be appreciated!


JeZxLee
JessePalser GMail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi,

Just asking for general help building on Linux.

Here are the errors in Linux terminal:

Code:
jezxlee at Thin-Client:~/Desktop/VM-SHARE/3dRayCasting-Demo$ make
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/main.cpp -o src/main.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/audio.cpp -o src/audio.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/data.cpp -o src/data.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/input.cpp -o src/input.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/interface.cpp -o src/interface.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/logic.cpp -o src/logic.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/screens.cpp -o src/screens.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/visuals.cpp -o src/visuals.o
g++ src/main.o src/audio.o src/data.o src/input.o src/interface.o src/logic.o src/screens.o src/visuals.o -L/usr/lib/x86_64-linux-gnu -lSDL2 -lSDL2_ttf -lSDL2_image -lSDL2_mixer -o lf
src/logic.o: In function __static_initialization_and_destruction_0': /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:106: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:107: undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:108: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:109: undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:110: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)‘
src/logic.o:/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:111: more undefined references to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' follow src/screens.o: In functionScreens::DisplayPlayingGameScreenRayCast()’:
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/screens.cpp:2097: undefined reference to InstantCG::ColorRGB::ColorRGB()' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/screens.cpp:2107: undefined reference toInstantCG::operator/(InstantCG::ColorRGB const&, int)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/screens.cpp:2109: undefined reference to InstantCG::verLine(int, int, int, InstantCG::ColorRGB const&)' src/screens.o: In function__static_initialization_and_destruction_0’:
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:106: undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:107: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:108: undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:109: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:110: undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' src/screens.o:/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:111: more undefined references toInstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)’ follow
collect2: error: ld returned 1 exit status
makefile:46: recipe for target ‘lf’ failed
make: *** [lf] Error 1
jezxlee at Thin-Client:~/Desktop/VM-SHARE/3dRayCasting-Demo$

It builds fine with Code::Blocks on Windows, just does not build on Linux.

Thanks!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

I tried to build it on Linux using your Code::Blocks project file and got a
linker error.
I set the linker settings correctly in Code::Blocks and was able to build
and run your application, although some code warnings were observed.
You probably want to fix those warnings, and maybe run it through Valgrind,
I have a feeling your application has a few more problems…
I don’t think you should be linking -lmingw32 on Linux.
I only linked against lSDL2 lSDL2_ttf lSDL2_image and lSDL2_mixer.
Why not setup separate build profiles for different systems?
The build output I got was: (with correct linker settings)

||=== Build: Release in 3dRayCasting (compiler: GNU GCC Compiler) ===|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp||In member function ?void
Data::ClearHighScores()?:expressionless:
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|119|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|118|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|127|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|126|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|135|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|134|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|143|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|142|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|151|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|150|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|159|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|158|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|167|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|166|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|175|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|174|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|183|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|182|note: containing loop|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|191|warning: iteration
19u invokes undefined behavior [-Waggressive-loop-optimizations]|
/home/paul/Desktop/3dRayCasting-Demo/src/data.cpp|190|note: containing loop|
||=== Build finished: 0 error(s), 10 warning(s) (0 minute(s), 1 second(s))
===|On Fri, May 15, 2015 at 12:11 AM, JeZ-l-Lee < JessePalserMailingLists at gmail.com> wrote:

Hi,

Just asking for general help building on Linux.

Here are the errors in Linux terminal:

Code:

jezxlee at Thin-Client:~/Desktop/VM-SHARE/3dRayCasting-Demo$ make
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/main.cpp -o
src/main.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/audio.cpp -o
src/audio.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/data.cpp -o
src/data.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/input.cpp -o
src/input.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/interface.cpp
-o src/interface.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/logic.cpp -o
src/logic.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/screens.cpp -o
src/screens.o
g++ -pipe -Wall -g -I/usr/include/SDL2 -D_REENTRANT -c src/visuals.cpp -o
src/visuals.o
g++ src/main.o src/audio.o src/data.o src/input.o src/interface.o
src/logic.o src/screens.o src/visuals.o -L/usr/lib/x86_64-linux-gnu -lSDL2
-lSDL2_ttf -lSDL2_image -lSDL2_mixer -o lf
src/logic.o: In function __static_initialization_and_destruction_0': /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:106: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char,
unsigned char, unsigned char)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:107:
undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:108: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char,
unsigned char, unsigned char)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:109:
undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:110: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char,
unsigned char, unsigned char)‘
src/logic.o:/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:111:
more undefined references to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' follow src/screens.o: In functionScreens::DisplayPlayingGameScreenRayCast()’:
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/screens.cpp:2097:
undefined reference to InstantCG::ColorRGB::ColorRGB()' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/screens.cpp:2107: undefined reference toInstantCG::operator/(InstantCG::ColorRGB const&,
int)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/screens.cpp:2109:
undefined reference to InstantCG::verLine(int, int, int, InstantCG::ColorRGB const&)' src/screens.o: In function__static_initialization_and_destruction_0’:
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:106:
undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:107: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char,
unsigned char, unsigned char)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:108:
undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' /home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:109: undefined reference toInstantCG::ColorRGB::ColorRGB(unsigned char,
unsigned char, unsigned char)’
/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:110:
undefined reference to InstantCG::ColorRGB::ColorRGB(unsigned char, unsigned char, unsigned char)' src/screens.o:/home/jezxlee/Desktop/VM-SHARE/3dRayCasting-Demo/src/instantcg.h:111: more undefined references toInstantCG::ColorRGB::ColorRGB(unsigned char,
unsigned char, unsigned char)’ follow
collect2: error: ld returned 1 exit status
makefile:46: recipe for target ‘lf’ failed
make: *** [lf] Error 1
jezxlee at Thin-Client:~/Desktop/VM-SHARE/3dRayCasting-Demo$

It builds fine with Code::Blocks on Windows, just does not build on Linux.

Thanks!


JeZxLee
JessePalser GMail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Paul Wortmann
E-mail : @Paul_Wortmann
Website: www.physhexgames.co.nr

Hi,

Thanks…

We are building on Linux with included makefile and get those errors.
Here is the makefile we are using:

Code:

“LettersFall[TM]” - MAKEFILE by JeZxLee & mattmatteh…

©opyright 2015 By www.16BitSoft.com

TARGET = lf

VERSION = 5.0

DEL_FILE = rm -f

CC = g++
CFLAGS = -pipe -Wall -g #-"ggdb"
SDL_CFLAGS = $(shell sdl2-config --cflags)
SDL_LIBS = $(shell sdl2-config --libs)

SDL_TTF_LIBS = -lSDL2_ttf
SDL_IMAGE_LIBS = -lSDL2_image
SDL_MIXER_LIBS = -lSDL2_mixer

OBJECTS = src/main.o
src/audio.o
src/data.o
src/input.o
src/interface.o
src/logic.o
src/screens.o
src/visuals.o

SOURCES = src/main.cpp
src/audio.cpp
src/data.cpp
src/input.cpp
src/interface.cpp
src/logic.cpp
src/screens.cpp
src/visuals.cpp

HEADERS = src/audio.h
src/data.h
src/input.h
src/interface.h
src/logic.h
src/screens.h
src/visuals.h

$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) $(SDL_LIBS) $(SDL_TTF_LIBS) $(SDL_IMAGE_LIBS) $(SDL_MIXER_LIBS) -o $@

.cpp.o:
$(CC) $(CFLAGS) $(SDL_CFLAGS) -c $< -o $@

clean:
rm $(OBJECTS) $(TARGET)

Is there something wrong with above makefile?

Thanks!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

you forgot instantcg.h / cpp / o in your make file, if I add, it builds.On Fri, May 15, 2015 at 1:22 AM, JeZ-l-Lee < JessePalserMailingLists at gmail.com> wrote:

Hi,

Thanks…

We are building on Linux with included makefile and get those errors.
Here is the makefile we are using:

Code:

“LettersFall[TM]” - MAKEFILE by JeZxLee & mattmatteh…

©opyright 2015 By www.16BitSoft.com

TARGET = lf

VERSION = 5.0

DEL_FILE = rm -f

CC = g++
CFLAGS = -pipe -Wall -g #-"ggdb"
SDL_CFLAGS = $(shell sdl2-config --cflags)
SDL_LIBS = $(shell sdl2-config --libs)

SDL_TTF_LIBS = -lSDL2_ttf
SDL_IMAGE_LIBS = -lSDL2_image
SDL_MIXER_LIBS = -lSDL2_mixer

OBJECTS = src/main.o
src/audio.o
src/data.o
src/input.o
src/interface.o
src/logic.o
src/screens.o
src/visuals.o

SOURCES = src/main.cpp
src/audio.cpp
src/data.cpp
src/input.cpp
src/interface.cpp
src/logic.cpp
src/screens.cpp
src/visuals.cpp

HEADERS = src/audio.h
src/data.h
src/input.h
src/interface.h
src/logic.h
src/screens.h
src/visuals.h

$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) $(SDL_LIBS) $(SDL_TTF_LIBS) $(SDL_IMAGE_LIBS)
$(SDL_MIXER_LIBS) -o $@

.cpp.o:
$(CC) $(CFLAGS) $(SDL_CFLAGS) -c $< -o $@

clean:
rm $(OBJECTS) $(TARGET)

Is there something wrong with above makefile?

Thanks!


JeZxLee
JessePalser GMail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Paul Wortmann
E-mail : @Paul_Wortmann
Website: www.physhexgames.co.nr

I’ll second that by saying that’s exactly what the makefile’s command line
output and linker error messages say the problem is.

Jonny DOn Thu, May 14, 2015 at 12:32 PM, Paul Wortmann <paul.wortmann at gmail.com> wrote:

you forgot instantcg.h / cpp / o in your make file, if I add, it builds.

On Fri, May 15, 2015 at 1:22 AM, JeZ-l-Lee < JessePalserMailingLists at gmail.com> wrote:

Hi,

Thanks…

We are building on Linux with included makefile and get those errors.
Here is the makefile we are using:

Code:

“LettersFall[TM]” - MAKEFILE by JeZxLee & mattmatteh…

©opyright 2015 By www.16BitSoft.com

TARGET = lf

VERSION = 5.0

DEL_FILE = rm -f

CC = g++
CFLAGS = -pipe -Wall -g #-"ggdb"
SDL_CFLAGS = $(shell sdl2-config --cflags)
SDL_LIBS = $(shell sdl2-config --libs)

SDL_TTF_LIBS = -lSDL2_ttf
SDL_IMAGE_LIBS = -lSDL2_image
SDL_MIXER_LIBS = -lSDL2_mixer

OBJECTS = src/main.o
src/audio.o
src/data.o
src/input.o
src/interface.o
src/logic.o
src/screens.o
src/visuals.o

SOURCES = src/main.cpp
src/audio.cpp
src/data.cpp
src/input.cpp
src/interface.cpp
src/logic.cpp
src/screens.cpp
src/visuals.cpp

HEADERS = src/audio.h
src/data.h
src/input.h
src/interface.h
src/logic.h
src/screens.h
src/visuals.h

$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) $(SDL_LIBS) $(SDL_TTF_LIBS) $(SDL_IMAGE_LIBS)
$(SDL_MIXER_LIBS) -o $@

.cpp.o:
$(CC) $(CFLAGS) $(SDL_CFLAGS) -c $< -o $@

clean:
rm $(OBJECTS) $(TARGET)

Is there something wrong with above makefile?

Thanks!


JeZxLee
JessePalser GMail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Paul Wortmann
E-mail : paul.wortmann at gmail.com
Website: www.physhexgames.co.nr


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Paul Wortmann wrote:

you forgot instantcg.h / cpp / o in your make file, if I add, it builds.
Hi!

That was the problem!
Now it builds on Linux!

Thanks!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com