glib compilation with ios - ios

I am trying to compile glib in ios, i have got an error in gio/tests/appinfo-test.h
#include <stdlib.h>
#include <gio/gio.h>
int
main (int argc, char *argv[])
{
const gchar *envvar;
gint pid_from_env;
envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
g_assert (envvar != NULL);
pid_from_env = atoi (envvar);
g_assert_cmpint (pid_from_env, ==, getpid ());
envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE");
g_assert_cmpstr (envvar, ==, SRCDIR "/appinfo-test.desktop"); //got the error here that "Use of undefined identifier 'SRCDIR' "
return 0;
}
please help me out...Thank you

I can not figure out with given information how you tried to compile the sample code in your ios, but you can add
#define SRCDIR
before main().
The sample code seems to be glib/gio/tests/appinfo-test.c in the source repository. SRCDIR is defined as -DSRCDIR=\""$(srcdir)"\" in the Makefile.am.

Related

pthread error code 3025 (ENOENT) on the as400/IBM i?

When I have the following C source code, which is running on an IBM i Midrange, then I get a non-zero result from pthread_create, specifically 3025, which is ENOENT (No such path or directory), which doesn't make any sense to me. Anyone have any thoughts on what the error actually means in this context.
#define _MULTI_THREADED
#define _XOPEN_SOURCE 520
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
void* workerThread(void* parm) {
// Do some work here
pthread_exit(NULL);
}
int main(int argc, char* argv[]) {
pthread_t t;
int rc;
rc = pthread_create(&t, NULL, workerThread, NULL);
if (rc != 0) {
char *msg = strerror(errno);
perror("pthread_create failed");
}
// Other code here
return 0;
}
pthread_create doesn't set errno. You should be checking strerror of rc.
http://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_create.html
char *msg = strerror(rc);

matlab stops working when getting printf order from a mex file

i am new to C++ and coding
how ever i attemped to make a mex file to use in matlab
the mex file has a problem for printing a parameter
i have sent the error picture
the code also is as below
`#include <windows.h>
#include <mex.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdint.h>
#include "./mavlink/v1.0/common/mavlink.h" //MAV_CMD_COMPONENT_ARM_DISARM is just defined
#include "C:\Users\SONY\Documents\Visual Studio 2010\Projects\code_test_2/inttypes.h"
#define STRICTfstat
#define WIN32_LEAN_AND_MEAN
#define CALL_TYPE_INIT 0
#define CALL_TYPE_CODE 1
#define CALL_TYPE_DECODE 2
#define CALL_TYPE_ARM 3
#define CALL_TYPE_DISARM 4
#ifndef MAV_CMD_COMPONENT_ARM_DISARM
#define MAV_CMD_COMPONENT_ARM_DISARM 400
#endif
unsigned char buf[4096]; // we put send and recive data in it enshaallah
int receive_chan = 0;
int system_id = 0;
int component_id = 0;
int APM_Sys_ID=0; // we use it instead of target sys ID
int APM_Comp_ID=0; // we use it instead of target component ID
mavlink_status_t status_copy;
mavlink_heartbeat_t system_heart_beat;
mavlink_message_t msg;
mavlink_attitude_t attitude; // it specifies the type of attitude. it says attitude is a data of type mavlink_attitude (hosein)
mavlink_rc_channels_raw_t rc_channels_raw;
void mexFunction(
int nlhs,
mxArray *plhs[],
int nrhs,
mxArray *prhs[]
)
{
double *CALL_TYPE = mxGetPr(prhs[0]);
if (*CALL_TYPE == CALL_TYPE_CODE){
uint16_t chan1_raw,chan2_raw,chan3_raw,chan4_raw,chan5_raw,chan6_raw,chan7_raw,chan8_raw;
printf("salam\n");
double *Actuators = mxGetPr(plhs[1]); // here we get the Actuators value which is prepared in matlab (it is sent from matlab to visula studio)
chan1_raw=1000*Actuators[0+8*0]+1000;
//chan2_raw=1000*Actuators[1+8*0]+1000;
//chan3_raw=1000*Actuators[2+8*0]+1000;
//chan4_raw=1000*Actuators[3+8*0]+1000;
//chan5_raw=1000*Actuators[4+8*0]+1000;
//chan6_raw=1000*Actuators[5+8*0]+1000;
//chan7_raw=1000*Actuators[6+8*0]+1000;
//chan8_raw=1000*Actuators[7+8*0]+1000;
/*mavlink_msg_rc_channels_override_pack(
system_id,
component_id,
&msg,//msg is out put and it is the way mavlink has determined and ali has no role on it
APM_Sys_ID,//we replaced target_system with APM_Sys_ID (this is the change we made in original code)
APM_Comp_ID,
chan1_raw,
chan2_raw,
chan3_raw,
chan4_raw,
chan5_raw,
chan6_raw,
chan7_raw,
chan8_raw);
*/
printf("% PRIu16\n",chan1_raw);
//printf("%i",chan2_raw);
//printf("%i",chan3_raw);
//printf("%i",chan4_raw);
//printf("%i",chan5_raw);
//printf("%i",chan6_raw);
}
}`
so please give me help for solving this problem if it is possible

How to get task port of SpringBoard in iOS7 (Jailbroken)?

I know we can use contextIdAtPosition and taskPortOfContextId to get the mach_port_t of the front top app, but when inside some app, we can not use contextIdAtPosition to get the context id of SpringBoard (it's at background), so how can we get the mach_port_t of SpringBoard? Thank you!
according to http://theiphonewiki.com/wiki//System/Library/LaunchDaemons/com.apple.SpringBoard.plist, the SpringBoard has exposed a lot of services. two of them might (or might not) be of your interests:
"com.apple.iohideventsystem"
"com.apple.springboard"
Here is the sample code to query the ports by service names.
#include <mach/mach.h>
#include "bootstrap.h"
#include <stdio.h>
#include <stdlib.h>
#define CHECK_MACH_ERROR(a) do {kern_return_t rr = (a); if ((rr) != KERN_SUCCESS) \
{ printf("Mach error %x (%s) on line %d of file %s\n", (rr), mach_error_string((rr)), __LINE__, __FILE__); abort(); } } while (0)
int main(int argc, char **argv, char **envp)
{
mach_port_t bp = MACH_PORT_NULL;
mach_port_t sp = MACH_PORT_NULL;
kern_return_t err = task_get_bootstrap_port(mach_task_self(), &bp);
CHECK_MACH_ERROR(err);
printf("bp:%d\n", bp);
err = bootstrap_look_up(bp, "com.apple.iohideventsystem", &sp);
CHECK_MACH_ERROR(err);
printf("iohideventsystem:%d\n", sp);
err = bootstrap_look_up(bp, "com.apple.springboard", &sp);
CHECK_MACH_ERROR(err);
printf("springboard:%d\n", sp);
// need to deallocate ports before exit
return 0;
}
The output:
my-iPad:~ root# /usr/bin/port_query
bp:519
iohideventsystem:4099
springboard:4355
There is a SpringboardService framework.
It has a function SBSSpringBoardServerPort() which returns Springboard mach port.
Note: Each application may have multiple mach ports, so I am not sure that it's one which you need.

Setsockopt() returning error number 10042

So I am getting started with SCTP and have written the basics of the SCTP server application(which I intend to modify to make it a peer-to-peer app). The code is incomplete but I compiled and ran it to test the socket options and the first setsockopt returns error 10042(protocol not supported). I have determined that it's the first call of setsockopt() that returns an error. So here is the incomplete code:
#include "stdafx.h"
#include <iostream>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#ifndef UNICODE
#define UNICODE
#endif
#define WIN32_LEAN_AND_MEAN
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <WS2spi.h>
#include <ws2sctp.h>
#include <wsipv6ok.h>
#include <if.h>
#include "ws2isatap.h"
#include "if_tunnel.h"
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "sctpsp.lib")
using namespace std;
using namespace System;
static int LISTENQ = 5;
void isatap_enable(void);
int main(int argc, char* argv[]){
WSADATA wsaData;
int iResult;
int optv = 10;
u_long imode = 1;
bool connected = false;
char *optval = (char*)&optv;
int optlen = sizeof(optval);
sockaddr_in6 servAddr;
sctp_sndrcvinfo sr;
sctp_event_subscribe evnts;
sctp_initmsg init;
memset(&sr,0,sizeof(sr));
memset(&evnts,0,sizeof(evnts));
memset(&init,0,sizeof(init));
memset(&servAddr,0,sizeof(servAddr));
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != NO_ERROR) {
wprintf(L"WSAStartup function failed with error: %d\n", iResult);
return 1;
}
SOCKET servSock = socket(AF_INET6,SOCK_STREAM,IPPROTO_SCTP);
if(servSock==INVALID_SOCKET){
printf("Socket function failed with error: %d\n",GetLastError());
return 1;
}
if(setsockopt(servSock,IPPROTO_IPV6,IPV6_PROTECTION_LEVEL,optval,sizeof(optval))<0){
printf("setsockopt function failed with error: %d\n", GetLastError());
return 1;
}
u_int servPort = 5000;
servAddr.sin6_family = AF_INET6;
servAddr.sin6_addr = in6addr_any;
servAddr.sin6_port = htons(servPort);
if(setsockopt(servSock,IPPROTO_SCTP,SCTP_EVENTS,(const char*)&evnts,sizeof(evnts)) < 0){
printf("setsockopt function failed with error: %d\n", GetLastError());
return 1;
}
ioctlsocket(servSock,FIONBIO, &imode);
if(bind(servSock,(struct sockaddr*)&servAddr,sizeof(servAddr))<0){
printf("Bind function failed with error: %d\n", GetLastError());
return 1;
}
evnts.sctp_data_io_event = 1;
evnts.sctp_association_event = *(u_char*)optval;
for(;;){
if(listen(servSock,LISTENQ) < 0){
printf("Listen function failed with error: %d/n",GetLastError());
return 1;
}else{
printf("Listening on port %d\n",servPort);
}
}
}
If it's related to python packages nameko/kombu/amqp, then it's reported here Issue with 2.1.4 version.
Temporary soln: Roll-back the version to 2.1.3 till it's fixed.
OK guys, I fixed it(for now lol). What I did is substitute the IPPROTO_IPV6 with IPPROTO_SCTP and it seems to work.

OPEN CV Program execution error?

I am running my below code in eclipse, i have include the path and libraries successfuly, but when run the code it shows an error.
#include <cv.h>
#include<stdio.h>
#include <highgui.h>
//using namespace cv;
int main()
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
printf("this is open cv programming");
return 0;
}
Your main() signature is incomplete
try
int main(int argc, char* argv[])
these parameters represent:
argc // an int indicating the number of arguments passed in to the function
argv[] // an array of character strings, the actual arguments.
The first argument argv[0] is the program name ... so argc is always a minimum of 1.
The second argument, argv[1] will be the first argument your user passes in, bringing argc up to 2. That is what your program is expecting, a single argument from the user, argc == 2.
Try to use the latest version of OpenCV i.e. 2.4.3....however right now you can try to link the debug libraries e.g. opencv_core2.4.xd and run the program to get the Mat image format working.
what is the version of opencv you are using?
try the following code and test...get some picture and run it....
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main()
{
Mat im = imread("C:\\some_picture.jpg");
if(im.empty())
return -1;
imshow("TEST",im);
waitKey();
return 0;
}

Resources