Is it safe to modify the android_native_app_glue.c file in the Android NDK? - android-ndk

I was thinking about modifying the onCreate() method in this file. Is this, and other modifications of the android_native_app_glue.c file safe?

Yes, you can change this file, as you can modify any file under sources - they are all compiled into your app, except that for STL you may need to additionally require rebuild of the STL library.

Related

How to use ReaderWriterOBJ in OpenSeneGraph

Can anyone explain to me how to use ReaderWriterOBJ in OpenSceneGraph? I want to load an obj file along with the mtl file. I have already built the solution for readerWriterObj code and created a dll file.
The ReaderWriter's are just file loaders. You have to use them in context of an application, like osgviewer, one of the examples included in OSG. If you've gone through the process of building OSG, you might have already built osgviewer, which will use the appropriate DLL's to load files.
eg
osgviewer FILE.obj
will open FILE.obj, with its associated material file[s].

Can I build static library that main component is header file(.h) with NDK?

I want to convert my cpp code for static library into Android library.
For this, I'm attempting to use NDK.
But I read NDK documentation and it said that only source code is able to be input for building, "Android.mk".
My Questtion is "Is there any way to build static library for Android system with my cpp library?"
Top module of my cpp library is header file and it can be built on Windows system as ".lib".
Thank you!
Your cpp library should be built with NDK toolchain as "libyourname.a" to begin with. You don't need Android.mk for that, even though in many cases deriving a standards-compliant Android.mk is trivial, and makes the developer's life happier in the long run (See, e.g., github).
The next step should be to prepare a JNI wrapper dynamic library (shared object, .so), which can be loaded from your Java app. That "libyourname_jni.so" will probably have its own, separate Android.mk file. Well, Java is not a must: you can use NativeActivity, or maybe some alternative frameworks.
I suggest the following reading to understand the whole process: http://thesoftwarerogue.blogspot.co.il/2010/05/porting-of-libcurl-to-android-os-using.html

C++ Creating a standalone library in linux and using it in another program

I'm trying to create a shared library for Linux such that:
other programs can use its functions and its objects
the code is not visible to final user
What i did is create a shared library with Eclipse. This library uses pthreads.
I generated .so and .lib. The .lib is in LIBRARY/Lib while the .so is in LIBRARY/Release.
Then i created another project which should use this library and i gave the path of the .lib file and the path of the .h file which only contains the inclusions of all the necessary .h of the library.
All seems working but when i run the program it crashes. When debugging it I receive the following message:
Can't find a source file at "pthread_mutex_lock.c"
Locate the file or edit the source lookup path to include its location.
What's wrong? Can someone help me please?
EDIT: I changed nothing and now I have a different error, some lines before the previous:
Can't find a source file at "random.c"
Locate the file or edit the source lookup path to include its location.
other programs can use its functions and its objects
the code is not visible to final user
These two goals directly contradict each other, and achieving both at the same time is impossible on Linux.
If some program can use your library, then I can write a new program that can do so as well.

Avoiding implicit precompiled header dependencies?

We are using a precompiled header to include library files such as Boost and Windows.
Our precompiled.h is included explicitly at the top of each .cpp file in order to work with the precompiled header commands (/Yc, /Yu, and /Fp). I accepted that as necessary.
Recently, however, I found /FI, which forces an include file at the top of the source file. I tried using it to force-include precompiled.h instead of including it explicitly, and sure enough, it worked.
This would allow us to omit the precompiled header (which is an implementation detail, as far as I am concerned), and only specify the actual dependencies of the file.
Unfortunately, it looks like the only way to validate that we aren't relying on implicit dependencies provided by precompiled.h is to periodically run through a build without /FI"precompiled.h" to see which files have a problem.
This is fairly onerous. Is there a better way?

How to structure a project in Visual C++ 2008 Express

I am using Visual C++ 2008 Express for the first time for a project. And I can't seem to be able to split the .h & .cpp files for classes I'm writing. I was under the impression that you add a header file and prototype the class in there, and then you add a .cpp file with the implementation into your source files directory. Then when you include the .h it would automatically include the .cpp implementation files. Is this correct or am I missing something?
Not sure if this is the same as in Express version. But you can also add a new C++ class with header (.h) and source (.cpp) at the same time by right clicking on the project -> Add -> Class...
By including the .h file using #include, doesn't mean the actual implementation (in another .cpp file) is also include in your source file. The content of .h file which are class and method prototypes is only included. These prototypes allow you to make use of the classes declared in header file (without including real C++ code.)
Each source files (.cpp) are first compiled into object files. All these object file are then linked together to create single executable file. The referenced symbols in, each object file, are actually linked to their implementation during this linking process (http://www.cprogramming.com/compilingandlinking.html)
I don't remember the rules, but sometimes the IDE assumes you're putting all your code in the header file. This is legal, but not a common preference.

Resources