Comments (8)
There is an example command in olcPixelGameEngine source
Please note that you need to install the development packages for
- libpng, package probably named
libpng-dev
like in Ubuntu - OpenGL, package probably named
libglu1-mesa-dev
like in Ubuntu - X11, package probably named
libx11-dev
like in Ubuntu - pthread, package probably named
libpthread-stubs0-dev
like in Ubuntu. This will probably be installed when you install X11 development packages.
I tried with the following command myself and it compiled without any problems.
g++ -o olcExampleProgram olcExampleProgram.cpp -lX11 -lGL -lpthread -lpng -lstdc++fs
EDIT: Tested this on my Ubuntu 18.04 desktop
from olcpixelgameengine.
You are getting undefined reference
errors for PGE functions because you are failing to include the implementation.
before your #include
directive for the PGE header you need to #define OLC_PGE_APPLICATION
like so.
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
from olcpixelgameengine.
For more info i used linux mint 64 bit with g++ installed and them dev tools!
from olcpixelgameengine.
Full list of errors!
g++ olcExampleProgram.cpp
/tmp/ccKGgmLV.o: In function `olc::pngReadStream(png_struct_def*, unsigned char*, unsigned long)':
olcExampleProgram.cpp:(.text+0x7fa): undefined reference to `png_get_io_ptr'
/tmp/ccKGgmLV.o: In function `olc::Sprite::LoadFromFile(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, olc::ResourcePack*)::{lambda()#1}::operator()() const':
olcExampleProgram.cpp:(.text+0x858): undefined reference to `png_read_info'
olcExampleProgram.cpp:(.text+0x878): undefined reference to `png_get_image_width'
olcExampleProgram.cpp:(.text+0x8a4): undefined reference to `png_get_image_height'
olcExampleProgram.cpp:(.text+0x8d1): undefined reference to `png_get_color_type'
olcExampleProgram.cpp:(.text+0x8f4): undefined reference to `png_get_bit_depth'
olcExampleProgram.cpp:(.text+0x90f): undefined reference to `png_set_strip_16'
olcExampleProgram.cpp:(.text+0x927): undefined reference to `png_set_palette_to_rgb'
olcExampleProgram.cpp:(.text+0x945): undefined reference to `png_set_expand_gray_1_2_4_to_8'
olcExampleProgram.cpp:(.text+0x96a): undefined reference to `png_get_valid'
olcExampleProgram.cpp:(.text+0x985): undefined reference to `png_set_tRNS_to_alpha'
olcExampleProgram.cpp:(.text+0x9b3): undefined reference to `png_set_filler'
olcExampleProgram.cpp:(.text+0x9d1): undefined reference to `png_set_gray_to_rgb'
olcExampleProgram.cpp:(.text+0x9f1): undefined reference to `png_read_update_info'
olcExampleProgram.cpp:(.text+0xa45): undefined reference to `png_get_rowbytes'
olcExampleProgram.cpp:(.text+0xa87): undefined reference to `png_read_image'
/tmp/ccKGgmLV.o: In function `olc::Sprite::LoadFromFile(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, olc::ResourcePack*)':
olcExampleProgram.cpp:(.text+0xc61): undefined reference to `png_create_read_struct'
olcExampleProgram.cpp:(.text+0xc87): undefined reference to `png_create_info_struct'
olcExampleProgram.cpp:(.text+0xcbc): undefined reference to `png_set_longjmp_fn'
olcExampleProgram.cpp:(.text+0xd2f): undefined reference to `png_init_io'
olcExampleProgram.cpp:(.text+0xdab): undefined reference to `png_set_read_fn'
/tmp/ccKGgmLV.o: In function `olc::ResourcePack::AddFile(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)':
olcExampleProgram.cpp:(.text+0x175c): undefined reference to `std::experimental::filesystem::v1::file_size(std::experimental::filesystem::v1::__cxx11::path const&)'
/tmp/ccKGgmLV.o: In function `olc::PixelGameEngine::SetScreenSize(int, int)':
olcExampleProgram.cpp:(.text+0x2bdd): undefined reference to `glClear'
olcExampleProgram.cpp:(.text+0x2bfe): undefined reference to `glXSwapBuffers'
olcExampleProgram.cpp:(.text+0x2c08): undefined reference to `glClear'
/tmp/ccKGgmLV.o: In function `olc::PixelGameEngine::EngineThread()':
olcExampleProgram.cpp:(.text+0x4f51): undefined reference to `glEnable'
olcExampleProgram.cpp:(.text+0x4f6b): undefined reference to `glGenTextures'
olcExampleProgram.cpp:(.text+0x4f84): undefined reference to `glBindTexture'
olcExampleProgram.cpp:(.text+0x4f98): undefined reference to `glTexParameteri'
olcExampleProgram.cpp:(.text+0x4fac): undefined reference to `glTexParameteri'
olcExampleProgram.cpp:(.text+0x4fc3): undefined reference to `glTexEnvf'
olcExampleProgram.cpp:(.text+0x501d): undefined reference to `glTexImage2D'
olcExampleProgram.cpp:(.text+0x5114): undefined reference to `XPending'
olcExampleProgram.cpp:(.text+0x5141): undefined reference to `XNextEvent'
olcExampleProgram.cpp:(.text+0x517a): undefined reference to `XGetWindowAttributes'
olcExampleProgram.cpp:(.text+0x51b3): undefined reference to `glClear'
olcExampleProgram.cpp:(.text+0x52a9): undefined reference to `XLookupKeysym'
olcExampleProgram.cpp:(.text+0x5314): undefined reference to `XLookupString'
olcExampleProgram.cpp:(.text+0x5369): undefined reference to `XLookupKeysym'
olcExampleProgram.cpp:(.text+0x53d4): undefined reference to `XLookupString'
olcExampleProgram.cpp:(.text+0x59bf): undefined reference to `glViewport'
olcExampleProgram.cpp:(.text+0x5a19): undefined reference to `glTexSubImage2D'
olcExampleProgram.cpp:(.text+0x5a27): undefined reference to `glBegin'
olcExampleProgram.cpp:(.text+0x5a38): undefined reference to `glTexCoord2f'
olcExampleProgram.cpp:(.text+0x5a7d): undefined reference to `glVertex3f'
olcExampleProgram.cpp:(.text+0x5a8a): undefined reference to `glTexCoord2f'
olcExampleProgram.cpp:(.text+0x5acf): undefined reference to `glVertex3f'
olcExampleProgram.cpp:(.text+0x5ae0): undefined reference to `glTexCoord2f'
olcExampleProgram.cpp:(.text+0x5b25): undefined reference to `glVertex3f'
olcExampleProgram.cpp:(.text+0x5b3a): undefined reference to `glTexCoord2f'
olcExampleProgram.cpp:(.text+0x5b7f): undefined reference to `glVertex3f'
olcExampleProgram.cpp:(.text+0x5b84): undefined reference to `glEnd'
olcExampleProgram.cpp:(.text+0x5bab): undefined reference to `glXSwapBuffers'
olcExampleProgram.cpp:(.text+0x5d1d): undefined reference to `XStoreName'
olcExampleProgram.cpp:(.text+0x5d9d): undefined reference to `glXMakeCurrent'
olcExampleProgram.cpp:(.text+0x5dc4): undefined reference to `glXDestroyContext'
olcExampleProgram.cpp:(.text+0x5deb): undefined reference to `XDestroyWindow'
olcExampleProgram.cpp:(.text+0x5e01): undefined reference to `XCloseDisplay'
/tmp/ccKGgmLV.o: In function `olc::PixelGameEngine::olc_WindowCreate()':
olcExampleProgram.cpp:(.text+0x61f8): undefined reference to `XInitThreads'
olcExampleProgram.cpp:(.text+0x6202): undefined reference to `XOpenDisplay'
olcExampleProgram.cpp:(.text+0x62ab): undefined reference to `glXChooseVisual'
olcExampleProgram.cpp:(.text+0x62f6): undefined reference to `XCreateColormap'
olcExampleProgram.cpp:(.text+0x63d9): undefined reference to `XCreateWindow'
olcExampleProgram.cpp:(.text+0x6410): undefined reference to `XInternAtom'
olcExampleProgram.cpp:(.text+0x6447): undefined reference to `XSetWMProtocols'
olcExampleProgram.cpp:(.text+0x646e): undefined reference to `XMapWindow'
olcExampleProgram.cpp:(.text+0x649c): undefined reference to `XStoreName'
olcExampleProgram.cpp:(.text+0x64d4): undefined reference to `XInternAtom'
olcExampleProgram.cpp:(.text+0x64fd): undefined reference to `XInternAtom'
olcExampleProgram.cpp:(.text+0x65bf): undefined reference to `XMapWindow'
olcExampleProgram.cpp:(.text+0x661f): undefined reference to `XSendEvent'
olcExampleProgram.cpp:(.text+0x6635): undefined reference to `XFlush'
olcExampleProgram.cpp:(.text+0x6663): undefined reference to `XGetWindowAttributes'
/tmp/ccKGgmLV.o: In function `olc::PixelGameEngine::olc_OpenGLCreate()':
olcExampleProgram.cpp:(.text+0x7341): undefined reference to `glXCreateContext'
olcExampleProgram.cpp:(.text+0x7387): undefined reference to `glXMakeCurrent'
olcExampleProgram.cpp:(.text+0x73b5): undefined reference to `XGetWindowAttributes'
olcExampleProgram.cpp:(.text+0x73d4): undefined reference to `glViewport'
olcExampleProgram.cpp:(.text+0x73eb): undefined reference to `glXGetProcAddress'
/tmp/ccKGgmLV.o: In function `std::experimental::filesystem::v1::exists(std::experimental::filesystem::v1::__cxx11::path const&)':
olcExampleProgram.cpp:(.text._ZNSt12experimental10filesystem2v16existsERKNS1_7__cxx114pathE[_ZNSt12experimental10filesystem2v16existsERKNS1_7__cxx114pathE]+0x14): undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/tmp/ccKGgmLV.o: In function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)':
olcExampleProgram.cpp:(.text.ZNSt12experimental10filesystem2v17__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES3_EERKT[ZNSt12experimental10filesystem2v17__cxx114pathC5INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES3_EERKT]+0x70): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/tmp/ccKGgmLV.o: In function `std::thread::thread<void (olc::PixelGameEngine::)(), olc::PixelGameEngine>(void (olc::PixelGameEngine::&&)(), olc::PixelGameEngine&&)':
olcExampleProgram.cpp:(.text.ZNSt6threadC2IMN3olc15PixelGameEngineEFvvEJPS2_EEEOT_DpOT0[ZNSt6threadC5IMN3olc15PixelGameEngineEFvvEJPS2_EEEOT_DpOT0]+0x33): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
from olcpixelgameengine.
I try to ensure that all the packages you need are covered by build-essentials
from olcpixelgameengine.
I try to ensure that all the packages you need are covered by build-essentials
I completely forgot about build essentials, which is definitely something you should install if you want to compile C or C++ code. Sadly, installing build-essential
package in Ubuntu (and most likely in its derivatives) will not install the 4 development packages I mentioned in my previous comment.
I already had build essentials installed and had to install libpng-dev
, libglu1-mesa-dev
and libx11-dev
to get olcPixelGameEngine to build.
from olcpixelgameengine.
Hi... I tried to run the example code (changing just the name of the cop and code). I run on a Ubuntu 18 with g++-9 with the following command:
g++-9 main.cpp -o path -lX11 -lGL -lpthread -lpng -lstdc++fs -std=c++17
And got the following error:
/tmp/cchWv4Kp.o: In function main': main.cpp:(.text+0x56): undefined reference to
olc::PixelGameEngine::Construct(int, int, int, int, bool, bool)'
main.cpp:(.text+0x72): undefined reference to olc::PixelGameEngine::Start()' /tmp/cchWv4Kp.o: In function
__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x130): undefined reference to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)' main.cpp:(.text+0x151): undefined reference to
olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)'
main.cpp:(.text+0x172): undefined reference to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)' main.cpp:(.text+0x193): undefined reference to
olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)'
main.cpp:(.text+0x1b4): undefined reference to olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)' /tmp/cchWv4Kp.o:main.cpp:(.text+0x1d5): more undefined references to
olc::Pixel::Pixel(unsigned char, unsigned char, unsigned char, unsigned char)' follow
/tmp/cchWv4Kp.o: In function Path::Path()': main.cpp:(.text._ZN4PathC2Ev[_ZN4PathC5Ev]+0x15): undefined reference to
olc::PixelGameEngine::PixelGameEngine()'
main.cpp:(.text._ZN4PathC2Ev[_ZN4PathC5Ev]+0x4b): undefined reference to olc::PixelGameEngine::~PixelGameEngine()' /tmp/cchWv4Kp.o:(.data.rel.ro._ZTV4Path[_ZTV4Path]+0x30): undefined reference to
olc::PixelGameEngine::OnUserDestroy()'
/tmp/cchWv4Kp.o:(.data.rel.ro._ZTV4Path[_ZTV4Path]+0x38): undefined reference to olc::PixelGameEngine::Draw(int, int, olc::Pixel)' /tmp/cchWv4Kp.o: In function
Path::~Path()':
main.cpp:(.text._ZN4PathD2Ev[_ZN4PathD5Ev]+0x22): undefined reference to olc::PixelGameEngine::~PixelGameEngine()' /tmp/cchWv4Kp.o:(.data.rel.ro._ZTI4Path[_ZTI4Path]+0x10): undefined reference to
typeinfo for olc::PixelGameEngine'
collect2: error: ld returned 1 exit status
Do you know what is going on?
from olcpixelgameengine.
I'm getting same errors as above on OpenSuse Tumbleweed, all required packages (I think) I have installed just fine.
from olcpixelgameengine.
Related Issues (20)
- Can't paste text when Console is open
- v2d_generic::lerp
- Doesn't build with /Wx and /Wall
- Directly draw on a sprite --> scaled string HOT 2
- Implement PingPong style in Animate2D HOT 1
- olcUTIL_Camera2D: m_vScreenSize is hard coded with no construction update, or means to change
- WASM (Emscripten): font looks ugly (strange underscores) HOT 2
- drawing Decal on Decal --> no transparency possible? HOT 2
- cursor disable and mouse delta values HOT 1
- Not an issue - Font suggestions. HOT 3
- PGEX extensions not usable in dll context
- TEST_Animate2D.cpp does not compile on ubuntu HOT 9
- Integrating render window into MFC or Qt
- have no function loading like mutillang font file or vector diagram as pixel Sprite HOT 1
- ModalDialog doesn't function intended
- olc::QuickGui::TextBox focusing issue
- broken link to RetroMenu.png asset in olcPGEX_PopUpMenu.h
- Support request: how can i port this library to embedded systems? HOT 8
- Multithreading in Visual Studio compiled program HOT 1
- Something causing dataraces? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from olcpixelgameengine.