Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LibGDX Native Libraries  (Read 754 times)
0 Members and 1 Guest are viewing this topic.
Offline KevinWorkman

JGO Kernel


Medals: 116
Projects: 11
Exp: 12 years


klaatu barada nikto


« Posted 2014-04-30 17:23:35 »

This is probably a dumb question, but it's been bugging me for a while.

I can successfully deploy a LWJGL game by adding its natives to my native library path when I run the jar using the -Djava.library.path argument. That works great.

I can also successfully deploy a libGDX game just be exporting a runnable jar. That also works great. My question is... why does that work? Why *don't* I have to set the native library path when I run the libGDX jar? LibGDX is built on top of LWJGL, so shouldn't it require the same native libraries? Does libGDX extract them automagically?

Again, I know how to get both LWJGL and libGDX working, my only question is why I don't seem to have to set the native library path with libGDX, even though LWJGL requires it. I suspect some witchcraft going on, and I'm just curious what that witchcraft is.

(Or maybe my assumptions are invalid and my runnable jar approach has only worked coincidentally and isn't what I should actually be doing?)

Static Void Games - Play indie games, learn game programming, upload your own games!
Offline Drenius
« Reply #1 - Posted 2014-04-30 17:57:38 »

1  
System.setProperty("org.lwjgl.librarypath", libraryPath);

at runtime while having the natives extracted to "libraryPath" is useful.

This is not exactly what you asked but where it will end up.
Offline KevinWorkman

JGO Kernel


Medals: 116
Projects: 11
Exp: 12 years


klaatu barada nikto


« Reply #2 - Posted 2014-04-30 18:00:38 »

1  
System.setProperty("org.lwjgl.librarypath", libraryPath);

at runtime while extracting the natives to "libraryPath" is useful.

Are you saying that's what libGDX does?

I use SvgExe to deploy LWJGL with self-extracting natives, so I don't have to worry about setting it myself. Does libGDX use the code you posted and some internal automagic self-extracting logic?

Static Void Games - Play indie games, learn game programming, upload your own games!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SHC
« Reply #3 - Posted 2014-05-01 13:34:34 »

This article from FromMyPlayGround says how to do it.

Offline KevinWorkman

JGO Kernel


Medals: 116
Projects: 11
Exp: 12 years


klaatu barada nikto


« Reply #4 - Posted 2014-05-01 15:01:24 »

This article from FromMyPlayGround says how to do it.

Sorry, but that isn't my question. I understand how to load native libraries. I do that with LWJGL, and in fact wrote a tool that handles it for Processing.

My question is, why *don't* I have to do that with libGDX? Every libGDX game I've made works fine as a runnable jar without setting the native library location. Again, I'm not asking how to set the native library location. I'm asking why I *don't seem to have to* with libGDX.

Am I just getting lucky and not hitting any native code (seems unlikely since I'm using OpenGL), or does libGDX have some kind of internal mechanism for extracting its own native libraries?

Static Void Games - Play indie games, learn game programming, upload your own games!
Offline Drenius
« Reply #5 - Posted 2014-05-01 15:06:44 »

Quote
or does libGDX have some kind of internal mechanism for extracting its own native libraries?
Probably, our posts were about how.
Anything else?
Offline cylab

JGO Ninja


Medals: 55



« Reply #6 - Posted 2014-05-01 15:13:06 »

As you guessed yourself,  the libGDX backend jars contain the natives.  On startup the framework checks if there is already a folder containing the natives where it expect it to be,  if not the folder is created and the natives are extracted from the right backend jar.  After that the system properties of lwjgl and other native libs are set and your game starts.

Mathias - I Know What [you] Did Last Summer!
Offline KevinWorkman

JGO Kernel


Medals: 116
Projects: 11
Exp: 12 years


klaatu barada nikto


« Reply #7 - Posted 2014-05-01 15:17:40 »

Quote
or does libGDX have some kind of internal mechanism for extracting its own native libraries?
Probably, our posts were about how.
Anything else?

I meant no disrespect, but I understand how it would work. The tool I wrote for Processing does exactly that (well, similar to that anyway), so I wasn't asking about how it might be done. I couldn't find any easily digestible (I suppose I could traipse through the source) information on it though, so I figured I'd ask here.

Again, I meant no disrespect and I didn't mean to sound dismissive of your answers. I was just looking for specifics on *whether* libGDX in fact did some automagic preprocessing, not *how* it might be done. Mostly I was making sure I was deploying libGDX correctly and not missing a step.

Thanks for the replies!

Static Void Games - Play indie games, learn game programming, upload your own games!
Offline KevinWorkman

JGO Kernel


Medals: 116
Projects: 11
Exp: 12 years


klaatu barada nikto


« Reply #8 - Posted 2014-05-01 15:18:14 »

As you guessed yourself,  the libGDX backend jars contain the natives.  On startup the framework checks if there is already a folder containing the natives where it expect it to be,  if not the folder is created and the natives are extracted from the right backend jar.  After that the system properties of lwjgl and other native libs are set and your game starts.

Thanks! This is exactly what I was looking for!

The more I learn about libGDX, the more clever I think it is...

Static Void Games - Play indie games, learn game programming, upload your own games!
Offline SHC
« Reply #9 - Posted 2014-05-01 15:18:53 »

You may want to check this class from the LibGdx source. LwjglNativesLoader

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline KevinWorkman

JGO Kernel


Medals: 116
Projects: 11
Exp: 12 years


klaatu barada nikto


« Reply #10 - Posted 2014-05-01 15:21:03 »

You may want to check this class from the LibGdx source. LwjglNativesLoader

Awesome, thanks again. This is exactly what I was curious about. I appreciate it.

Static Void Games - Play indie games, learn game programming, upload your own games!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (14 views)
2014-12-27 22:38:51

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (17 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (86 views)
2014-12-05 12:39:02

SHC (97 views)
2014-12-03 16:27:13
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!