Using Dynamic Libraries in a non-linux environment - iar

I'm using a non-linux OS (call it RTOS) on an iMX6 Quad processor (IAR IDE). I would like to use the onboard GC320 GPU to do some 2D bitblit, clearing and other functions. The library that NXP provides is libg2d.so which is a dynamic lib from Vivante and is proprietary. Is there any way to easily use this library in my environment? What I would like to get is the library in static form form that I can just link to; anyone know if that is available?

Related

C/C++ application dependency libraries

I am programming applictions written in C/C++, in my project I am using SMFL library for my GUI.The way I use SMFL is that I built it from the source,and link the compiled library.So the procedure can be summarized below:
install the libraries dependent by SMFL, that is "pthread opengl xlib udev xrandr xcursor freetype openal flac vorbis";
build the SMFL source and get the final library files;
build my project using the SMFL library file;
So the application I built could be distributed to others.
Then a question arises, do other users who get my built application have to install the libraries used by SFML(i.e. pthread opengl xlib udev xrandr xcursor freetype openal flac vorbis)?
Yes, all dependent libraries must be installed. Referencing udev and xlib indicates that you're most likely referring to Linux.
If you build and deploy your application using a Linux distribution's native package manager, like rpm for Fedora-based distributions, and apt for Debian-based distributions, then installing your rpm or deb package will result in all dependent packages getting automatically installed as well, making this process a moot point.
A quick check shows that SFML is a popular library that's already available in most mainstream Linux distributions. There is no apparent reason to build it yourself. Just use the one that already comes with your Linux distribution, and save yourself all those headaches.
There are some edge cases that call for building a custom or a different version of a library that's already included in the distribution. In that case that library can also get build with rpmbuild or debuild. The only additional twist here is that additional, advanced techniques must be used to make it possible to seamlessly have the custom-built library installed alongside the one that comes with the Linux distribution.
But, taking advantage of your Linux distribution's native package management tools is the easiest way to handle these kinds of common dependencies.

How to dynamically load dlls using macros

Sorry if the title is confusing. Anyways I'm working on a small game engine in C++ and I want to modularize it. I want there to be a core module and then you can install other modules based on what your using (2D Graphics, 3D Graphics, Audio, Physics, etc) and I was thinking the best (maybe only) way to do this is make each module another project in my VS solution that compile to dlls while the core is a lib. The core lib could check which modules are installed by checking for a macro like ENGINE_2D_GRAPHICS_MODULE that could be defined in the dll. How would I do this and is there a better way? I'm pretty sure there's probably a better way but idk what it is.
Macros are compile-time constants, you can't influence your core module this way upon installing new modules. You probably want to detect whether additional modules are present in the filesystem and then load them with LoadLibrary (on Windows) or dlopen (on POSIX-conforming systems).
A different option would be to let the game developer (i.e. the the engine user) to link your library statically and, respectively, compile only the needed parts.

c++ static, dynamic libraries - analyzing UE4 build system

TL:DR; Static/Dynamic library and data sharing in UE4.
So all libraries are static or dynamic but no "mixed" solution?
Long description:
I'm browsing the UE4 source code and found that they are using a modular system. So they're building libraries (static or dynamic, based on the IS_MONOLITHIC define) and they are linked based on the build configuration files (like Core.Build.cs).
Let's read the "OpenGLDrv" module's Build file. It depends on the Core and Engine (and so on) libraries, so I guess they are linked to the OpenGLDrv library.
And checking the Launch module, in the Build file they set up dynamic module dependencies for the D3DXX and the OpenGLDrv libraries.
And here comes my problems:
If they are dynamically loaded modules, they have to be dynamic libraries (dll in Windows). If it's not true, are they linked statically?
If linked statically, how are they handling the global/static data sharing? Both the Launch and OpenGLDrv depends on the Core module which is linked statically to both libraries.
If the OpenGLDrv is a dynamic library and the Launch and Core are not, the data sharing problem still exists.
More specifically
I've tried to implement a similar system. I'm using visual studio and my current target platform is Windows only (but I'm writing the code in a platform-independent way).
Currently I have 5 following modules:
Core: It has the really core things like math classes, logger, misc, and the module manager.
Modules: The base classes for the "implementable" modules: InputDevice, GraphicsDevice and so on. The Core is linked to this.
OGLDevice: This supposed to be a dynamic library. It implements the OpenGL-specific GraphicsDevice. Both the Core and Modules are linked to it.
Engine: This is the "main library" which. Both the Core and Modules are linked to this library. It should load the OGLDevice dynamically.
Application: The main executable. The Engine is linked to this.
Here is a pretty cool image drawn by myself in Paint:
The best design-image ever
If all the 4 libraries are static, there aren't any problem with the dependencies. However, this way the OGLDevice is not a dynamically loaded library, because it is linked to the Engine. Maybe the device itself is not instantiated but still linked to the project.
If the Core, Modules and Engine libraries are static but the OGLDevice is dynamic, data sharing problems comes up. First, the Core is "loaded" by the Engine (because it's statically linked to it) but when the Engine loads the OGLDevice library, it will also "load" its own Core. So every static and global are duplicated.
If all modules would be dynamic, I guess it should work. Is there any way to mix the static and dynamic library thing?
Or how is the UE4 doing this?

Statically linked OpenGL library on Windows

I want to get ( or build from source) OpenGL library that is statically linked to the crt on Windows.
I don't want my executable to require OPENGL32.dll.
My compiler is Visual C++ 9.
Where do I begin? The OpenGL website directs me to this wiki http://www.opengl.org/wiki/Getting_started
But that wiki tells me "In all three major desktop platforms (Linux, MacOS X, and Windows), OpenGL more or less comes with the system".
I am on Windows. Is this statement true. How do I verify this?
Statically linked OpenGL library on Windows
I don't want my executable to require OPENGL32.dll.
Impossible. End of story. opengl32.dll is provided by microsoft and may be changed after each system update. So you can't static-link it - it is a system component.
You can only static link with mesa3d which emulates OpenGL on CPU. However, it is not fully compliant to OpenGL, so you can get unexpected problems, and you'll still require several system dlls. (my bet is gdi32.dll) for your application. Also, performance will be very bad compared to normal OpenGL.
I believe what you are saying is that you don't want to be forced to make your application link with the C Runtime libraries dynamically (i.e. Multithreaded DLL or Multithreaded Debug DLL in the Properties/C++/Code Generation/Runtime Library setting).
Since OpenGL is a system provided .DLL, you are still free to choose Multithreaded or Multithreaded Debug (both choices statically link to the C Runtime) for your Runtime Library when using OpenGL.

How to port a PC game to Android written in C++

I want to create a simple game like Space Invaders. I know that I can use Android NDK, but I have to port the libraries that I use. I can not use third-party proprietary libraries.
I will use OpenGL, but OpenGL API seems different on Android. I have to use jpeg and png textures, and write texts. Can I compile libjpeg, libpng and freetype for Android?
I can not have specific implementation of the game engine (C++) and rendering routines (C++ and OpenGL), because that is the complex part.
There are components that I am disposed to implement for each platform. There is no problem with windowing system and user input, because I will use a specific implementation for each system, it is simple for me.
I use SDL and its extensions for audio on PC, but it is easy to use. I can use specific audio libraries for Android.
Thanks
Can I compile libjpeg, libpng and freetype for Android?
Yes you will have to recompile all the native libraries specifically for Android. Yes, you do need the source code for all 3rd party native libs you plan to use simply because Usually when we compile and link these libraries outside Android they are linked to glibc but unfortunately Android doesn't use glibc due to liscence and performance issues. Android uses a watered down version of glibc called libc. It has matching symbol names to glibc for most of the usual functionalities. But as far as i know the libc doesn't have some functionality related to Strings and it definitely doesnt have some posix support. If your native libraries are using any of the deprecated functionality you will have to find workaround for those by using alternative functionality supported by libc and coding your libs accordingly.
Also, as you righty pointed out you will have to use the NDK to interface Java(Android app/fwk) to native world(C++).
Though this sounds pretty simple in my experience compiling native libraries on Android(Android porting) has traditionally been very time consuming with no guarantee of sucesses.