# Native C program for Android, using PVRScope

**URL:** <https://forums.imgtec.com/t/native-c-program-for-android-using-pvrscope/2378>\
**Category:** PowerVR Insider\
**Tags:** pvrscope\
**Created:** [October 15, 2015, 7:28am UTC](https://forums.imgtec.com/t/native-c-program-for-android-using-pvrscope/2378 "2015-10-15T07:28:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![goliki1](https://avatars.discourse-cdn.com/v4/letter/g/c4cdca/32.png) [@goliki1](https://forums.imgtec.com/u/goliki1)\
**Post date:** [October 15, 2015, 7:28am UTC](https://forums.imgtec.com/t/native-c-program-for-android-using-pvrscope/2378/1 "2015-10-15T07:28:56Z")

</div>

Hello. I’m trying to use PVRScope for the native C program (command line program) on Android.  
(My device is Odroid-XU with Android 4.2.2)

I have tried to compile the example code of PVRScopeStats, included in PVRScope’s user manual.

And, I found some example for Android NDK in  
[http://imgtec.eetrend.com/sites/imgtec.eetrend.com/files/download/201403/1765-3054-tuxingfenxiandroid.pdf](http://imgtec.eetrend.com/sites/imgtec.eetrend.com/files/download/201403/1765-3054-tuxingfenxiandroid.pdf)

Thus now trying to use Android NDK for compling of the example.  
(In Windows(cygwin), using the Android NDK ver. r10e)  
(Application.mk contains only APP\_ABI := armeabi-v7a)

Below is my Android.mk for ndk-build command.  
[hr]  
LOCAL\_PATH := /home/admin/project/jni

include $(CLEAR\_VARS)  
LOCAL\_MODULE:= PVRScope  
LOCAL\_SRC\_FILES := /home/admin/PVRScopeDeveloper/Linux\_armv7/libPVRScopeDeveloper.a  
include $(PREBUILT\_STATIC\_LIBRARY)

include $(CLEAR\_VARS)  
LOCAL\_MODULE := example  
LOCAL\_SRC\_FILES := example.c  
LOCAL\_C\_INCLUDES := /home/admin/PVRScopeDeveloper/Linux\_armv7/  
LOCAL\_STATIC\_LIBRARIES := PVRScope  
LOCAL\_LDFLAGS += -Wl,–no-undefined  
LOCAL\_CPPFLAGS := -std=c99 -Wall  
include $(BUILD\_EXECUTABLE)  
[hr]

With these settings, ndk-build shows error messages below.  
[hr]  
$ ndk-build  
[armeabi-v7a] Compile thumb : example \<= example.c  
C:/cygwin/home/admin/project/jni/example.c:21:13: error: unknown type name 'SPVRScopeImplData’  
bool PSInit(SPVRScopeImplData \*\*ppsPVRScopeData, SPVRScopeCounterDef _ppsCounters, SPVRScopeCounterReading const psReading, unsigned int_ const pnCount)  
^  
C:/cygwin/home/admin/project/jni/example.c:21:50: error: unknown type name 'SPVRScopeCounterDef’  
bool PSInit(SPVRScopeImplData \*\*ppsPVRScopeData, SPVRScopeCounterDef _ppsCounters, SPVRScopeCounterReading const psReading, unsigned int_ const pnCount)  
^  
C:/cygwin/home/admin/project/jni/example.c:21:85: error: unknown type name 'SPVRScopeCounterReading’  
bool PSInit(SPVRScopeImplData \*\*ppsPVRScopeData, SPVRScopeCounterDef _ppsCounters, SPVRScopeCounterReading const psReading, unsigned int_ const pnCount)  
^  
C:/cygwin/home/admin/project/jni/example.c: In function ‘main’:  
C:/cygwin/home/admin/project/jni/example.c:45:1: error: unknown type name 'SPVRScopeImplData’  
SPVRScopeImplData \*psData;  
^  
C:/cygwin/home/admin/project/jni/example.c:47:1: error: unknown type name 'SPVRScopeCounterDef’  
SPVRScopeCounterDef \*psCounters;  
^  
C:/cygwin/home/admin/project/jni/example.c:52:1: error: unknown type name 'SPVRScopeCounterReading’  
SPVRScopeCounterReading sReading;  
^  
C:/cygwin/home/admin/project/jni/example.c:64:37: error: request for member ‘nGroup’ in something not a structure or union  
printf(" Group %d %s", psCounters[i].nGroup, psCounters[i].pszName);  
^  
C:/cygwin/home/admin/project/jni/example.c:64:59: error: request for member ‘pszName’ in something not a structure or union  
printf(" Group %d %s", psCounters[i].nGroup, psCounters[i].pszName);  
^  
C:/cygwin/home/admin/project/jni/example.c:77:1: warning: passing argument 1 of ‘PVRScopeSetGroup’ from incompatible pointer type [enabled by default]  
PVRScopeSetGroup(psData, uActiveGroupSelect); bActiveGroupChanged = false;  
^  
In file included from C:/cygwin/home/admin/project/jni/example.c:19:0:  
C:/cygwin/home/admin/PVRScopeDeveloper/Linux\_armv7/PVRScopeStats.h:219:6: note: expected ‘struct SPVRScopeImplData \* const’ but argument is of type 'int \*'  
void PVRScopeSetGroup(  
^  
C:/cygwin/home/admin/project/jni/example.c:83:1: warning: passing argument 1 of ‘PVRScopeReadCounters’ from incompatible pointer type [enabled by default]  
PVRScopeReadCounters(psData, NULL);  
^  
In file included from C:/cygwin/home/admin/project/jni/example.c:19:0:  
C:/cygwin/home/admin/PVRScopeDeveloper/Linux\_armv7/PVRScopeStats.h:209:5: note: expected ‘struct SPVRScopeImplData \* const’ but argument is of type 'int \*'  
int PVRScopeReadCounters(  
^  
C:/cygwin/home/admin/project/jni/example.c:90:1: warning: passing argument 1 of ‘PVRScopeReadCounters’ from incompatible pointer type [enabled by default]  
if(PVRScopeReadCounters(psData, &sReading))  
^  
In file included from C:/cygwin/home/admin/project/jni/example.c:19:0:  
C:/cygwin/home/admin/PVRScopeDeveloper/Linux\_armv7/PVRScopeStats.h:209:5: note: expected ‘struct SPVRScopeImplData \* const’ but argument is of type 'int \*'  
int PVRScopeReadCounters(  
^  
C:/cygwin/home/admin/project/jni/example.c:90:1: warning: passing argument 2 of ‘PVRScopeReadCounters’ from incompatible pointer type [enabled by default]  
if(PVRScopeReadCounters(psData, &sReading))  
^  
In file included from C:/cygwin/home/admin/project/jni/example.c:19:0:  
C:/cygwin/home/admin/PVRScopeDeveloper/Linux\_armv7/PVRScopeStats.h:209:5: note: expected ‘struct SPVRScopeCounterReading \* const’ but argument is of type 'int \*'  
int PVRScopeReadCounters(  
^  
C:/cygwin/home/admin/project/jni/example.c:94:16: error: request for member ‘nValueCnt’ in something not a structure or union  
if(i \< sReading.nValueCnt) {  
^  
C:/cygwin/home/admin/project/jni/example.c:96:25: error: request for member ‘pszName’ in something not a structure or union  
if (strcmp(psCounters[i].pszName, “GPU task load: 3D core”) == 0) {  
^  
C:/cygwin/home/admin/project/jni/example.c:97:34: error: request for member ‘pszName’ in something not a structure or union  
printf("%s : %f%", psCounters[i].pszName,  
^  
C:/cygwin/home/admin/project/jni/example.c:98:9: error: request for member ‘pfValueBuf’ in something not a structure or union  
sReading.pfValueBuf[i]);  
^  
C:/cygwin/home/admin/project/jni/example.c:101:30: error: request for member ‘pszName’ in something not a structure or union  
else if (strcmp(psCounters[i].pszName, “GPU task load: TA core”) == 0)  
^  
C:/cygwin/home/admin/project/jni/example.c:103:34: error: request for member ‘pszName’ in something not a structure or union  
printf("%s : %f%", psCounters[i].pszName,  
^  
C:/cygwin/home/admin/project/jni/example.c:104:9: error: request for member ‘pfValueBuf’ in something not a structure or union  
sReading.pfValueBuf[i]);  
^  
C:/cygwin/home/admin/project/jni/example.c:114:1: warning: passing argument 1 of ‘PVRScopeDeInitialise’ from incompatible pointer type [enabled by default]  
PVRScopeDeInitialise(&psData, &psCounters, &sReading);  
^  
In file included from C:/cygwin/home/admin/project/jni/example.c:19:0:  
C:/cygwin/home/admin/PVRScopeDeveloper/Linux\_armv7/PVRScopeStats.h:148:6: note: expected ‘struct SPVRScopeImplData \*\*’ but argument is of type 'int \*\*'  
void PVRScopeDeInitialise(  
^  
C:/cygwin/home/admin/project/jni/example.c:114:1: warning: passing argument 2 of ‘PVRScopeDeInitialise’ from incompatible pointer type [enabled by default]  
PVRScopeDeInitialise(&psData, &psCounters, &sReading);  
^  
In file included from C:/cygwin/home/admin/project/jni/example.c:19:0:  
C:/cygwin/home/admin/PVRScopeDeveloper/Linux\_armv7/PVRScopeStats.h:148:6: note: expected ‘struct SPVRScopeCounterDef \*\*’ but argument is of type 'int \*\*'  
void PVRScopeDeInitialise(  
^  
C:/cygwin/home/admin/project/jni/example.c:114:1: warning: passing argument 3 of ‘PVRScopeDeInitialise’ from incompatible pointer type [enabled by default]  
PVRScopeDeInitialise(&psData, &psCounters, &sReading);  
^  
In file included from C:/cygwin/home/admin/project/jni/example.c:19:0:  
C:/cygwin/home/admin/PVRScopeDeveloper/Linux\_armv7/PVRScopeStats.h:148:6: note: expected ‘struct SPVRScopeCounterReading \* const’ but argument is of type 'int \*'  
void PVRScopeDeInitialise(  
^  
[hr]

It seems that the compiler could not recognized the static library(.a file) of PVRScope.  
(I have tried other ABIs, but it does not work.)

Please give me some advice.

Any advice will help me.

Thank you for your reading.

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [October 28, 2015, 3:45pm UTC](https://forums.imgtec.com/t/native-c-program-for-android-using-pvrscope/2378/2 "2015-10-28T15:45:03Z")

</div>

Hi,

Thanks for reporting the issue. Which version of the SDK have you taken the PVRScope libraries from? 3.5? Would you be able to share the source code of your example with us to reproduce the issue?

A fix was implemented a while ago after another user reported C compatibility issues. If there are still problems with the latest release, I’ll file a bug against the library for you.

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![goliki1](https://avatars.discourse-cdn.com/v4/letter/g/c4cdca/32.png) [@goliki1](https://forums.imgtec.com/u/goliki1)\
**Post date:** [October 29, 2015, 3:26am UTC](https://forums.imgtec.com/t/native-c-program-for-android-using-pvrscope/2378/3 "2015-10-29T03:26:57Z")

</div>

Thank you for your reply.

I have used PVRScope libraries from 3.5.

From the example code(for PVRScopeStats) of PVRscope’s manual, some logging functions are replaced by printf[].

Below is the source code.

Regards,

Hwang.

[attachment file=“ex.txt”]

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [October 29, 2015, 9:34am UTC](https://forums.imgtec.com/t/native-c-program-for-android-using-pvrscope/2378/4 "2015-10-29T09:34:47Z")

</div>

Thanks for confirming the version of the library and sharing your source code. We will follow up with you once we have reproduced the issue.

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![szhipeng](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@szhipeng](https://forums.imgtec.com/u/szhipeng)\
**Post date:** [November 3, 2015, 1:30am UTC](https://forums.imgtec.com/t/native-c-program-for-android-using-pvrscope/2378/5 "2015-11-03T01:30:30Z")

</div>

Hi Keun-Ho,  
You can see that we define struct like this in our SDK:

```auto

struct SPVRScopeCounterDef
{
    const char *pszName; ///< Counter name, null terminated
    int nBoolPercentage; ///< true if the counter is a percentage
    unsigned int nGroup; ///< The counter group that the counter is in.
};

```

so the example code should like this:  
struct SPVRScopeCounterDef \*psCounters;  
The modified C file was attached.(PVRScopeStats.c)  
2. the Android.mk file should be modified like the following:  
`
++include $(CLEAR_VARS)
++LOCAL_MODULE:= supc++
++LOCAL_SRC_FILES := /home/kevin/Android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libsupc++.a
++include $(PREBUILT_STATIC_LIBRARY)`

++LOCAL\_STATIC\_LIBRARIES := PVRScope supc++  
++LOCAL\_LDFLAGS += -llog

After these change the code can be built successfully.😃

Thanks,  
Kevin
