Tag Archives: C

[Solved] KDevelop Error: Failed to specify program to start

The build was successful, but the runtime encountered an error

Failed to specify program to start

Solution:

    1. Check if Run/Current Launch Configuration is the current project
    2. If it is New Compiled Binary Launcher, select the current project
    3. If there is no current project name, go to the next option Configure Launches
    4. Click on the current project name
    5. AddCompiled Binary
    6. Go back to the first step and find that there are options, select
    7. Execute, run successfully

[Solved] Hikvision SDK: NET_DVR_GetDVRConfig failed Device does not support this function

Problem:

I have written some code based on Hikvision’s sdk for controlling the camera. One section of the program is mainly used to get NVR channel configuration information

The codes is as below:
I use the function NET_DVR_GetDVRConfig

#include  #include "HCNetSDK.h" int main() { NET_DVR_Init(); //Set connection time and reconnect time NET_DVR_SetConnectTime(2000, 1); NET_DVR_SetReconnect(10000, true); // 注册设备 LONG lUserID; //Login parameters, including device address, login user, password, etc. NET_DVR_USER_LOGIN_INFO struLoginInfo = { 0 }; struLoginInfo.bUseAsynLogin = 0; //同步登录方式 strcpy(struLoginInfo.sDeviceAddress, "192.168.20.106"); //设备IP地址 struLoginInfo.wPort = 8000; //设备服务端口 strcpy(struLoginInfo.sUserName, "admin"); //设备登录用户名 strcpy(struLoginInfo.sPassword, "111111hk"); //设备登录密码 //设备信息, 输出参数 NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = { 0 }; lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40); if (lUserID < 0) { printf("Login failed, error code: %d\n", NET_DVR_GetLastError()); NET_DVR_Cleanup(); return -1; } NET_DVR_IPPARACFG_V40 ipcfg; DWORD bytesReturned = 0; ipcfg.dwSize = sizeof(NET_DVR_IPPARACFG_V40); int iGroupNO = 0; bool resCode = NET_DVR_GetDVRConfig(lUserID, NET_DVR_GET_IPPARACFG_V40, iGroupNO, &ipcfg, sizeof(NET_DVR_IPPARACFG_V40), &bytesReturned); if (! resCode) { DWORD code = NET_DVR_GetLastError(); std::cout << "NET_DVR_GetDVRConfig failed " << NET_DVR_GetErrorMsg((LONG*)(&code)) << std::endl; NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return -1; } std::cout << "设备组 " << ipcfg.dwGroupNum << " 数字通道个数 " << ipcfg.dwDChanNum << " 起始通道 " << ipcfg.dwStartDChan << std::endl << std::endl; for (int i = 0; i < ipcfg.dwDChanNum; i++) { NET_DVR_PICCFG_V30 channelInfo; bytesReturned = 0; channelInfo.dwSize = sizeof(NET_DVR_PICCFG_V30); int channelNum = i + ipcfg.dwStartDChan; NET_DVR_GetDVRConfig(lUserID, NET_DVR_GET_PICCFG_V30, channelNum, &channelInfo, sizeof(NET_DVR_PICCFG_V30), &bytesReturned); std::cout <<"通道号 "<< channelNum << "\t通道名称 " << channelInfo.sChanName; std::cout << "\t用户名 " << ipcfg.struIPDevInfo[i].sUserName << "\t密码 " << ipcfg.struIPDevInfo[i].sPassword; std::cout << "\t设备ID " << (int)ipcfg.struIPDevInfo[i].szDeviceID; std::cout << "\tip地址 " << ipcfg.struIPDevInfo[i].struIP.sIpV4 << "\t端口 " << ipcfg.struIPDevInfo[i].wDVRPort << std::endl; } //释放SDK资源 NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return 0; } 

The code was running ok, but when migrating to another machine, something went wrong.
Report the error: NET_DVR_GetDVRConfig failed Device does not support this function

Note the phrase:
If the number of IP channels supported by the device is greater than 0, then the remote parameter configuration interface NET_DVR_GetDVRConfig can be used.
This means that to use this function, you need to check the number of IP channels supported by the device first.
Also, the manual gives a sample program (check first, then call)
The sample procedure is as follows.
ps: there is a point I want to spit, the manual on the ET_DVR_GetDVRConfig function explanation, there is no mention of this issue, causing me to look for a long time to find here to write. Since this function is not supported by all devices, then the norm should be written to check first, then call.

#include  #include  #include "Windows.h" #include "string.h" #include "HCNetSDK.h" using namespace std; void main() { int i=0; BYTE byIPID,byIPIDHigh; int iDevInfoIndex, iGroupNO, iIPCh; DWORD dwReturned = 0; //--------------------------------------- // 初始化 NET_DVR_Init(); //设置连接时间与重连时间 NET_DVR_SetConnectTime(2000, 1); NET_DVR_SetReconnect(10000, true); //--------------------------------------- // 注册设备 LONG lUserID; //Login parameters, including device address, login user, password, etc. NET_DVR_USER_LOGIN_INFO struLoginInfo = {0}; struLoginInfo.bUseAsynLogin = 0; //同步登录方式 strcpy(struLoginInfo.sDeviceAddress, "192.0.0.64"); //设备IP地址 struLoginInfo.wPort = 8000; //设备服务端口 strcpy(struLoginInfo.sUserName, "admin"); //设备登录用户名 strcpy(struLoginInfo.sPassword, "abcd1234"); //设备登录密码 //设备信息, 输出参数 NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = {0}; lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40); if (lUserID < 0) { printf("Login failed, error code: %d\n", NET_DVR_GetLastError()); NET_DVR_Cleanup(); return; } printf("The max number of analog channels: %d\n",struDeviceInfoV40.struDeviceV30.byChanNum); //模拟通道个数 printf("The max number of IP channels: %d\n", struDeviceInfoV40.struDeviceV30.byIPChanNum + struDeviceInfoV40.struDeviceV30.byHighDChanNum * 256);//IP通道个数 //获取IP通道参数信息 NET_DVR_IPPARACFG_V40 IPAccessCfgV40; memset(&IPAccessCfgV40, 0, sizeof(NET_DVR_IPPARACFG)); iGroupNO=0; if (! NET_DVR_GetDVRConfig(lUserID, NET_DVR_GET_IPPARACFG_V40, iGroupNO, &IPAccessCfgV40, sizeof(NET_DVR_IPPARACFG_V40), &dwReturned)) { printf("NET_DVR_GET_IPPARACFG_V40 error, %d\n", NET_DVR_GetLastError()); NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return; } else { for (i=0;i<IPAccessCfgV40.dwDChanNum;i++) { switch(IPAccessCfgV40.struStreamMode[i].byGetStreamType) { case 0: //直接从设备取流 if (IPAccessCfgV40.struStreamMode[i].uGetStream.struChanInfo.byEnable) { byIPID=IPAccessCfgV40.struStreamMode[i].uGetStream.struChanInfo.byIPID; byIPIDHigh=IPAccessCfgV40.struStreamMode[i].uGetStream.struChanInfo.byIPIDHigh; iDevInfoIndex=byIPIDHigh*256 + byIPID-1-iGroupNO*64; printf("IP channel no.%d is online, IP: %s\n", i+1, IPAccessCfgV40.struIPDevInfo[iDevInfoIndex].struIP.sIpV4); } break; case 1: //从流媒体取流 if (IPAccessCfgV40.struStreamMode[i].uGetStream.struPUStream.struStreamMediaSvrCfg.byValid) { printf("IP channel %d connected with the IP device by stream server.\n", i+1); printf("IP of stream server: %s, IP of IP device: %s\n",IPAccessCfgV40.struStreamMode[i].uGetStream.\ struPUStream.struStreamMediaSvrCfg.struDevIP.sIpV4, IPAccessCfgV40.struStreamMode[i].uGetStream.\ struPUStream.struDevChanInfo.struIP.sIpV4); } break; default: break; } } } //配置IP通道5; iIPCh=4; //支持自定义协议 NET_DVR_CUSTOM_PROTOCAL struCustomPro; if (! NET_DVR_GetDVRConfig(lUserID, NET_DVR_GET_CUSTOM_PRO_CFG, 1, &struCustomPro, sizeof(NET_DVR_CUSTOM_PROTOCAL), &dwReturned)) //获取自定义协议1 { printf("NET_DVR_GET_CUSTOM_PRO_CFG error, %d\n", NET_DVR_GetLastError()); NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return; } struCustomPro.dwEnabled=1; //启用主码流 struCustomPro.dwEnableSubStream=1; //启用子码流 strcpy((char *)struCustomPro.sProtocalName,"Protocal_RTSP"); //自定义协议名称:Protocal_RTSP,最大16字节 struCustomPro.byMainProType=1; //主码流协议类型: 1- RTSP struCustomPro.byMainTransType=2; //主码流传输协议: 0-Auto, 1-udp, 2-rtp over rtsp struCustomPro.wMainPort=554; //主码流取流端口 strcpy((char *)struCustomPro.sMainPath,"rtsp://192.168.1.65/h264/ch1/main/av_stream");//主码流取流URL struCustomPro.bySubProType=1; //子码流协议类型: 1-RTSP struCustomPro.bySubTransType=2; //子码流传输协议: 0-Auto, 1-udp, 2-rtp over rtsp struCustomPro.wSubPort=554; //子码流取流端口 strcpy((char *)struCustomPro.sSubPath,"rtsp://192.168.1.65/h264/ch1/sub/av_stream");//子码流取流URL if (! NET_DVR_SetDVRConfig(lUserID, NET_DVR_SET_CUSTOM_PRO_CFG, 1, &struCustomPro, sizeof(NET_DVR_CUSTOM_PROTOCAL))) //设置自定义协议1 { printf("NET_DVR_SET_CUSTOM_PRO_CFG error, %d\n", NET_DVR_GetLastError()); NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return; } printf("Set the custom protocol: %s\n", "Protocal_RTSP"); NET_DVR_IPC_PROTO_LIST m_struProtoList; if (! NET_DVR_GetIPCProtoList(lUserID, &m_struProtoList)) //Get the front-end protocols supported by the device { printf("NET_DVR_GetIPCProtoList error, %d\n", NET_DVR_GetLastError()); NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return; } IPAccessCfgV40.struIPDevInfo[iIPCh].byEnable=1; //启用 for (i = 0; i<m_struProtoList.dwProtoNum; i++) { if(strcmp((char *)struCustomPro.sProtocalName,(char *)m_struProtoList.struProto[i].byDescribe)==0) { IPAccessCfgV40.struIPDevInfo[iIPCh].byProType=m_struProtoList.struProto[i].dwType; //选择自定义协议 break; } } //IPAccessCfgV40.struIPDevInfo[iIPCh].byProType=0; //厂家私有协议 strcpy((char *)IPAccessCfgV40.struIPDevInfo[iIPCh].struIP.sIpV4,"192.168.1.65"); //前端IP设备的IP地址 IPAccessCfgV40.struIPDevInfo[iIPCh].wDVRPort=8000; //前端IP设备服务端口 strcpy((char *)IPAccessCfgV40.struIPDevInfo[iIPCh].sUserName,"admin"); //前端IP设备登录用户名 strcpy((char *)IPAccessCfgV40.struIPDevInfo[iIPCh].sPassword,"12345"); //前端IP设备登录密码 IPAccessCfgV40.struStreamMode[iIPCh].byGetStreamType=0; IPAccessCfgV40.struStreamMode[iIPCh].uGetStream.struChanInfo.byChannel=1; IPAccessCfgV40.struStreamMode[iIPCh].uGetStream.struChanInfo.byIPID=(iIPCh+1)%256; IPAccessCfgV40.struStreamMode[iIPCh].uGetStream.struChanInfo.byIPIDHigh=(iIPCh+1)/256; //IP通道配置,包括添加、删除、修改IP通道等 if (! NET_DVR_SetDVRConfig(lUserID, NET_DVR_SET_IPPARACFG_V40, iGroupNO, &IPAccessCfgV40, sizeof(NET_DVR_IPPARACFG_V40))) { printf("NET_DVR_SET_IPPARACFG_V40 error, %d\n", NET_DVR_GetLastError()); NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return; } else { printf("Set IP channel no.%d, IP: %s\n", iIPCh+1, IPAccessCfgV40.struIPDevInfo[iIPCh].struIP.sIpV4); } //注销用户 NET_DVR_Logout(lUserID); //释放SDK资源 NET_DVR_Cleanup(); return; } 

[Solved] JNI Error: Fatal signal 11 (SIGSEGV)

2022-09-14 09:19:01.092 3562-3580/com.derry.opengl A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x24 in tid 3580 (GLThread 103) 

I often encounter this kind of error report, making me very bummed.

I tried a solution (rooted phone or emulator, otherwise the error log file can not be found): 1.

1. find the file where the logs are located: data/tombstones

2. Find the file with this latest date

3. save the file to the desktop (I did not encounter problems with permissions using the emulator, so I can export directly) If you encounter insufficient permissions, you need to use su superuser permissions (chmod 777 xxxxx)

4. open the log file: there are error logs inside (this point is not enough permissions for me) specific analysis of the problem, this point is mainly to explain how to view this log file

--------- log main 09-14 09:18:58.184 3562 3562 D : houdini no need remount 09-14 09:18:58.201 3562 3562 I art : Late-enabling -Xcheck:jni 09-14 09:18:58.236 3562 3562 E libnb : load libnb 09-14 09:18:58.252 3562 3562 D houdini : [3562] Initialize library(version: 7.1.1b_x.49852 RELEASE)... successfully. 09-14 09:18:58.254 3562 3562 W art : Unexpected CPU variant for X86 using defaults: x86 09-14 09:18:58.719 3562 3562 W art : Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 09-14 09:18:58.782 3562 3562 I art : Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener; 09-14 09:18:58.783 3562 3562 I art : at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.widget.ActionBarContainer.(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance0!( java.lang.Object[]) (Constructor.java:-2) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflate(org.xmlpull.v1. XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1. XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1. XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377) 09-14 09:18:58.783 3562 3562 I art : at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140) 09-14 09:18:58.783 3562 3562 I art : at void com.derry.opengl.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6692) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118) 09-14 09:18:58.783 3562 3562 I art : at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2621) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2729) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1480) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Looper.loop() (Looper.java:154) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6176) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Method.invoke!( java.lang.Object, java.lang.Object[]) (Method.java:-2) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:893) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:783) 09-14 09:18:58.783 3562 3562 I art : Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.derry.opengl-1/base.apk"],nativeLibraryDirectories=[/data/app/com.derry.opengl-1/lib/arm, /data/app/com.derry.opengl-1/base.apk! /lib/armeabi-v7a, /system/lib, /vendor/lib]] 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) 09-14 09:18:58.783 3562 3562 I art : at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.widget.ActionBarContainer.(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance0!( java.lang.Object[]) (Constructor.java:-2) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflate(org.xmlpull.v1. XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1. XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1. XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377) 09-14 09:18:58.783 3562 3562 I art : at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140) 09-14 09:18:58.783 3562 3562 I art : at void com.derry.opengl.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6692) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118) 09-14 09:18:58.783 3562 3562 I art : at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2621) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2729) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1480) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Looper.loop() (Looper.java:154) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6176) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Method.invoke!( java.lang.Object, java.lang.Object[]) (Method.java:-2) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:893) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:783) 09-14 09:18:58.783 3562 3562 I art : 09-14 09:18:58.843 3562 3562 W System.err: java.io.FileNotFoundException: /sdcard/lbpcascade_frontalface.xml (Permission denied) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.open(Native Method) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:221) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:169) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.utils.FileUtil.copyAssets2SDCard(FileUtil.java:16) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLRenderer.(MyGLRenderer.java:43) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.init(MyGLSurfaceView.java:29) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.(MyGLSurfaceView.java:21) 09-14 09:18:58.844 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) 09-14 09:18:58.844 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createView(LayoutInflater.java:645) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 09-14 09:18:58.844 3562 3562 W System.err: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 09-14 09:18:58.844 3562 3562 W System.err: at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MainActivity.onCreate(MainActivity.java:19) 09-14 09:18:58.844 3562 3562 W System.err: at android.app.Activity.performCreate(Activity.java:6692) 09-14 09:18:58.845 3562 3562 W System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.-wrap12(ActivityThread.java) 09-14 09:18:58.847 3562 3562 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480) 09-14 09:18:58.848 3562 3562 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 09-14 09:18:58.848 3562 3562 W System.err: at android.os.Looper.loop(Looper.java:154) 09-14 09:18:58.848 3562 3562 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6176) 09-14 09:18:58.848 3562 3562 W System.err: at java.lang.reflect.Method.invoke(Native Method) 09-14 09:18:58.848 3562 3562 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) 09-14 09:18:58.848 3562 3562 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 09-14 09:18:58.857 3562 3562 W System.err: java.io.FileNotFoundException: /sdcard/seeta_fa_v1.1.bin (Permission denied) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.open(Native Method) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:221) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:169) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.utils.FileUtil.copyAssets2SDCard(FileUtil.java:16) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLRenderer.(MyGLRenderer.java:45) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.init(MyGLSurfaceView.java:29) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.(MyGLSurfaceView.java:21) 09-14 09:18:58.862 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) 09-14 09:18:58.862 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createView(LayoutInflater.java:645) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 09-14 09:18:58.863 3562 3562 W System.err: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 09-14 09:18:58.863 3562 3562 W System.err: at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 09-14 09:18:58.863 3562 3562 W System.err: at com.derry.opengl.MainActivity.onCreate(MainActivity.java:19) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.Activity.performCreate(Activity.java:6692) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.-wrap12(ActivityThread.java) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480) 09-14 09:18:58.863 3562 3562 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 09-14 09:18:58.863 3562 3562 W System.err: at android.os.Looper.loop(Looper.java:154) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6176) 09-14 09:18:58.863 3562 3562 W System.err: at java.lang.reflect.Method.invoke(Native Method) 09-14 09:18:58.863 3562 3562 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) 09-14 09:18:58.863 3562 3562 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 09-14 09:18:58.998 3562 3562 D : static HostConnection *HostConnection::createUnique(): call 09-14 09:18:58.999 3562 3562 D : HostConnection::get() New Host Connection established 0xd2dfcd30, tid 3562 09-14 09:18:59.103 3562 3586 I OpenGLRenderer: Initialized EGL, version 1.4 09-14 09:18:59.103 3562 3586 D OpenGLRenderer: Swap behavior 1 09-14 09:18:59.105 3562 3586 D : HostConnection::get() New Host Connection established 0xd2dfcf10, tid 3586 09-14 09:18:59.416 3562 3580 D : HostConnection::get() New Host Connection established 0xd7012480, tid 3580 09-14 09:18:59.794 3562 3580 E EGL_emulation: eglQueryContext 32c0 EGL_BAD_ATTRIBUTE 09-14 09:18:59.794 3562 3580 E EGL_emulation: tid 3580: eglQueryContext(1413): error 0x3004 (EGL_BAD_ATTRIBUTE)

How to Solve linq Statement IsNullOrWhiteSpace Error

Using the IsNullOrWhiteSpace method in a linq statement will report an error,

Error message: System.NotSupportedException: ‘LINQ to Entities does not recognize the method ‘Boolean lsNullOrWhiteSpace(System.String)’ method, and this method cannot be translated into a store expression.’

You can use the method below to solve:

You can also use IsNullOrEmpty, IsNullOrEmpty method does not report an error, normal operation

The following figure is the analysis of these two methods:

[Solved] yum Install gcc Error: Error: Package: glibc-headers-2.17-317.el7.x86_64

When installing Nignx
Installing the GCC compiler

yum install -y gcc

Report an error as below:

Error: Package: glibc-headers-2.17-317.el7.x86_64 (base)
           Requires: glibc = 2.17-317.el7
           Installed: glibc-2.17-322.el7_9.i686 (@c6-update)
               glibc = 2.17-322.el7_9
           Available: glibc-2.17-317.el7.i686 (base)
               glibc = 2.17-317.el7
Error: Package: glibc-devel-2.17-317.el7.x86_64 (base)
           Requires: glibc = 2.17-317.el7
           Installed: glibc-2.17-322.el7_9.i686 (@c6-update)
               glibc = 2.17-322.el7_9
           Available: glibc-2.17-317.el7.i686 (base)
               glibc = 2.17-317.el7
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Show one installed version higher than the required version

Resolved by downgrading.

yum downgrade glibc glibc-devel glibc-common glibc-headers

Installation success!

Installed:
  gcc.x86_64 0:4.8.5-44.el7                                                                                                                                           

Dependency Installed:
  cpp.x86_64 0:4.8.5-44.el7 glibc-devel.x86_64 0:2.17-317.el7 glibc-headers.x86_64 0:2.17-317.el7 kernel-headers.x86_64 0:3.10.0-1160.el7 libmpc.x86_64 0:1.0.1-3.el7
  mpfr.x86_64 0:3.1.1-4.el7

Complete!

[Solved] error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘

Error log

Text

Octal value is out of range

1> E:\CProject\test12\Source. c(5,10): error C2041: illegal digit ‘8’ for base ‘8’

Hexadecimal value is out of range

1> E:\CProject\test12\Source. c(5,10): error C2059: syntax error: ‘bad suffix on number’
1> E:\CProject\test12\Source. c(5,10): error C2153: integer literals must have at least one digit
1> E:\CProject\test12\Source. c(5,13): error C2021: expected exponent value, not ‘;’
1> E:\CProject\test12\Source. c(5,10): warning C4244: ‘initializing’: conversion from ‘double’ to ‘int’, possible loss of data
1> Done building project “test12.vcxproj” – FAILED.

Screenshot (hexadecimal value exceeds the range)

Solution:

C2041 series error: this kind of number, which is generally octal or hexadecimal, is out of range
for example:

  1. 09; because there is no 9 in octal
  2. 0xq; because hex doesn’t have the q character.

This requires us to carefully check whether the relevant figures exceed the range.

[Solved] fatal error C1189: #error: STL1003: Unexpected compiler, expected C++ compiler

Error Log:

screenshot

text version:

F:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\yvals_core.h(23,1): fatal error C1189: #error: STL1003: Unexpected compiler, expected C++ compiler.
F:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\yvals_core.h(23,1): fatal error C1189: #error: STL1003: Unexpected compiler, expected C++ compiler.

 

Error

Solution:
This problem is because the C++ header file is referenced in the C file. Just replace cmath with math.h.

C++ Compile Error: error: invalid conversion from ‘void*‘ to ‘char*‘ [-fpermissive]

error: invalid conversion from ‘void*‘ to ‘char*‘ [-fpermissive]

#include <stdio.h>
#include<malloc.h>
#define IN
#define OUT

// Get file size
int FileSize(IN char *file)
{
	FILE *fil;
	fil = fopen(file,"rb");
	fseek(fil,0L,SEEK_END);
	int filesize = ftell(fil);
	fseek(fil,0,0);
	return filesize;
}

// read the file
int ReadFileData(IN char *fileName, OUT char *filedata)
{
	FILE *fpIN;
	int fileSizes = FileSize(fileName);
	fpIN = fopen(fileName,"rb");
	fread(filedata,1,fileSizes,fpIN);
	fclose(fpIN);
}

// write the file
int WriteToFile(char *filedata, int size, OUT char *outFileName)
{
	FILE *fpOUT;
	fpOUT = fopen(outFileName,"w+");
	fwrite(filedata,1,size,fpOUT);
	fclose(fpOUT);
}

int main()
{
	char *origin_file = "test.cpp";
	int orgfilesize = FileSize(origin_file);  // Get file size



	char *file_data=  malloc(orgfilesize);      // Allocate file size memory
    if (file_data == NULL)
        return NULL;
	ReadFileData(origin_file, file_data);     // read the file
	char *outFile = "test.txt";
	WriteToFile(file_data,orgfilesize,outFile);  // write the file

	return 0;
}

The following line of code

char *file_data=  malloc(orgfilesize);

Malloc function is used to allocate space in C language. The return type is void*. Void* indicates a pointer of undetermined type. C. C++ specifies that the void* type can cast any other type of pointer.

The malloc() function actually finds a space of a specified size in memory and ranges the first address of that space to a pointer variable.
Here the pointer variable can be a single pointer or the first address of an array.
It depends on the size of the malloc() function.

Use GCC compilation to directly pass and print out the following results

Original String: testing.

When compiling with g++, an error and warning will appear, as follows

error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

The reason for the error is that c++ is designed to be more secure than C, and it cannot automatically convert void * to other pointer types.

The reason for warning is that the program attempts to convert the string literal (const char [] in c++ and char [] in C language) to char * type,,

char *file_data= (char*) malloc(orgfilesize); 
# The return value of the malloc function is a void*, which is assigned to a variable by adding a forced conversion in front of malloc

Introduction to malloc function
malloc function is often used in C language and c++ to dynamically allocate memory space for variables. Malloc requests the system to allocate memory space of the specified size bytes

function void malloc(int size)

explain:

Malloc requests the system to allocate memory space of the specified size bytes. If the allocation is successful, a pointer to the allocated memory is returned; otherwise, a null pointer is returned
this function is included in the header file: \include < malloc.h> you should import the header file *< malloc.h>  or  < stdlib.h>** when you are using

Note: when the memory is no longer used, the free() function should be used to free the memory block
Common usage

1. When you do not know the definite memory required by a variable

For example, when defining an array, the size of the array is not known until the program is compiled. In this case, you can use the malloc function

int main()
{
	int n;
	scanf("%d",&n);
	int *m=(int *)malloc(sizeof(int)*n);  //Defining a pointer variable that points to n int is equivalent to opening an array of n int elements.
	// If n is very large, more than 1000000, then opening an int array of this size will cause a stack overflow.
	int m[1000000]; //Stack overflow will occur.
	return 0;
}

2. Allocate space for structural variables
define a common variable of structure type. You can dynamically apply for memory without malloc. The CPU will allocate memory for structure variables.

typedef struct
{
    int n;
    char *p;
}node;

int  main()
{
	node a;  //The definition is a structured ordinary variable, you can request memory without using malloc, the CPU will allocate memory for this structured variable
    a.n=4;
    printf("%d",a->n); //can output successfully
    node *b; //defines a structure pointer variable, the CPU will open up memory for this pointer with a size of 4 bytes. But to store the data members of the structure this space is not enough, it will raise a segment error, at this time you must malloc request a structure type size of dynamic memory to store the data members.
    //b=(node *)malloc(sizeof(node));
    printf("%d",sizeof(b)); // use sizeof(b) to see the size of b is 4
    char p[]="abcd";
    printf("%d",b->n);
    (a->p)=p;
    printf("%c",a->p[0]);
    return 0;
}

If malloc is not used to allocate space for structure pointer variable B, warning: ‘B’ is used uninitialized in this function [-wuninitialized]|.

3. When defining a structure, you need to pay attention to allocating space for its members in turn
in normal use, after allocating space for a structure with malloc function, operate on its member variable (pointer type).

For example, when the pointer p=null, it will always report “program received signal SIGSEGV, segmentation fault.”
use malloc function

[Solved] Ubuntu Eclipse C/C++ Error: launch failed.binary not found

Questions

Running on windows, there is either a problem with the installation of mingw64, or the header file cannot be found. Anyway, it is to verify whether the simulator can be used. What is the trouble? Just switch to Linux. The following are the results of running on Ubuntu.

Process

To run the square studio export project, follow the readme of the exported project,

    1. install gcc
sudo apt-get install gcc g++ gdb build-essential
    2. install sdl
sudo apt-get install libsdl2-dev

3. Install eclipse c/c++
4. Select the parent folder of the exported project as “Workspace”
5. Select File->Import->General->Exisiting project into Workspace click “Next” and browse the project
6. Build the project with Project->Build
7. Run the project with Run->Run.
Then report an error: could not found lpng

 

Solution:

    1Install lpng
sudo apt-get install libpng-dev

2. install CDT

help-> Check for updates

check CDT and install 

3. Modify the compiler

4. Just follow steps 6 and 7 above. The effect drawing is as follows

The semget function error: errno is set to 28 [How to Solve]

When running semget under Linux to create semaphores, it returns – 1 and the creation fails;

1. This function is a system function. You can only confirm the actual error code with errno, print errno through strError, and return no space left on device. Is the system space insufficient? Insufficient space to create semaphores?

2. Go to errno. H to check the error message enospc corresponding to the actual error code. What does this field mean?

3. Does the semget function have its own error field? Check the function manual: check the man Manual of semget function: a semaphore set has to be created but the system limit for the maximum number of semaphore sets (semmni), or the system-wide maximum number of semaphores. Semaphore exceeds system limit.

It is basically determined that it is caused by the system semaphore. First, temporarily modify the kernel semaphore parameters and run again to see whether it has been solved.

4. The following commands are used in viewing semaphores

#1)The sysctl command can view and set system kernel parameters
# The 4 corresponding values from left to right are SEMMSL, SEMMNS, SEMOPM and SEMMNI.
sysctl -a | grep sem #View the setting value of the system semaphore
kernel.sem = 250 32000 32 128


#2) There are three ways to modify: the numbers are for reference only
echo 610 86620 100 142 > /proc/sys/kernel/sem

sysctl -w kernel.sem="610 86620 100 142"

echo "kernel.sem=610 86620 100 142" >> /etc/sysctl.conf`


#3) View the current semaphore and pid of the system as well as user information, view more information and check --help
ipcs -s -p -c


#4) Delete the semaphore method of the specified semid, and check more usage --help
ipcrm -s semid


#5) Delete all semid semaphore methods
ipcrm  -asem

5. Here, in the process of finding semaphore resource leakage, in order to facilitate real-time viewing of semaphore information, the semaphore output is written into the script and printed circularly

#ipcs.sh
echo “ipcs -s loop”

while [ 1 ]
do
	sleep 1
	ipcs -s
done

6. Note: the final problem here is to see why the semaphore in the code exceeds the limit. Normally, the semaphore will not exceed the system limit.

[Solved] Vs error: link: fatal error lnk1168: unable to open for writing

Project scenario:

use VS to program in C language and generate solution report – > Execution error


Problem Description:

error: link: fatal error lnk1168: unable to open C:\users\86139\desktop\plan\notes\C\tryproject \ debug\tryproject.exe for writing

#include <stdio.h>
#include "math.h"//Since the library function sqrt() is to be used

int main(){
	//Requirement: determine if the quadratic function has real roots, and output if it does?
	double a,b,c,disc,x1,x2,p,q;//declare variables
	printf("Please enter the values of a,b,c respectively: \n");
	scanf("%lf%lf%lf",&a,&b,&c);//enter the value and store it at address a,b,c
	disc=b*b-4*a*c;//discriminant
	if(disc<0){
		printf("This equation has no real roots!!!");
	}else{//disc>=0
		p=-b/(2.0*a);
		q=sqrt(disc)/(2.0*a);
		x1=p+q;
		x2=p-q;
		printf("此方程的两实根为:\nx1=%7.2f\nx2=%7.6f\n",x1,x2);
	}
}

Cause analysis:

the process may already exist, so it cannot be opened and run


Solution:

just finish the process of the program. You can open “process manager” (Task Manager), Ctrl + Alt + delete, find the corresponding process, and right-click to finish.