Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when compiling with olcPixelGameEngine after installing X11 library in ubuntu. #319

Open
solracnauj1990 opened this issue Jan 16, 2023 · 3 comments

Comments

@solracnauj1990
Copy link

Hi. I have a problem with compiling a cpp file using the olcPixelGameEngine library. Everything in ubuntu.

First, i wanted to include the librarie in the program but whhen I compiled it I got the next problem in the terminal.

The command I used:
g++ -o resultado helloworld.cpp

What I got:
helloworld.cpp:5:10: fatal error: olcConsoleGameEngine.h: No such file or directory 5 | #include "olcConsoleGameEngine.h" | ^~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.

Then I downloaded the olcPixelGameEngine.h file and coppied it to /usr/include.
When I tried to compile again I got the next problem:

In file included from helloworld.cpp:5: olcPixelGameEngine.h:530:12: fatal error: X11/X.h: No such file or directory 530 | #include <X11/X.h> | ^~~~~~~~~ compilation terminated.

After that I searched in internet and found the command:

sudo apt install libx11-dev
When I runned it everything went ok.
But now when I try to compile I get the next problem:

/usr/bin/ld: /tmp/ccigeM0H.o: in function __static_initialization_and_destruction_0(int, int)':
helloworld.cpp:(.text+0x1c5): undefined reference to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)' /usr/bin/ld: helloworld.cpp:(.text+0x1e6): undefined reference to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)'
/usr/bin/ld: helloworld.cpp:(.text+0x207): undefined reference to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)' /usr/bin/ld: helloworld.cpp:(.text+0x228): undefined reference to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)'
/usr/bin/ld: helloworld.cpp:(.text+0x249): undefined reference to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)' /usr/bin/ld: /tmp/ccigeM0H.o:helloworld.cpp:(.text+0x26a): more undefined references to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)' follow
collect2: error: ld returned 1 exit status`

Then I searched but found nothing.
I show you the entire story to know if I did something wrong or just to find a solution.
Hope you could help me.

@gorbit99
Copy link

this means that you don't have

#define OLC_PGE_APPLICATION

line at the top of your main file.
For more information, check out: https://github.com/OneLoneCoder/olcPixelGameEngine/wiki/Compiling-on-Linux and https://github.com/OneLoneCoder/olcPixelGameEngine/wiki/Multiple-File-Projects and probably https://github.com/OneLoneCoder/olcPixelGameEngine/wiki/Hello-World

@solracnauj1990
Copy link
Author

Thank you so much!!! It worked!! :)

@gurkanctn
Copy link

It's quite interesting that you're including olcConsoleGameEngine instead of the olcPixelGameEngine, and then the problem is fixed by a PGE application definition. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants