Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Integrating two C programs

Status
Not open for further replies.

lucks

MIS
Mar 12, 2007
4
0
0
MU
hi.. am working on ARToolKit which is a software library in C. i want to create an interface for it and using Gtk+ which is also in C..

when i run both programs separately, they both run well. but when i try to run my interface application through ARtoolkit,it does not work.

i`ve tried to integrate Gtk+ with ARtoolkit but am having an error called "PACKAGE"...here is what i`ve done in the ARtoolkit file that i want to run (that is i`ve added these header file from Gtk:

#include <gtk/gtk.h>
#include "interface/src/callbacks.h"
#include "interface/src/interface.h"
#include "interface/src/support.h"
#include "interface/msvc/config.h"

i think am not doing the correct way of integration.if anyone can help me please:(

any help will be highly appreciated

thanks



 
Does your C compiler have an option to print all the include files that the compiler is accessing? If it does, switch it on: at least that will tell you what has been included so far and where there error is coming from.

If that doesn't give you any clues, could you post the exact error message. Just telling us that it is an error called "PACKAGE" doesn't give any clues.
 
hi xwb,

my compiler does not have the option to print the include files but we can see all the files in the same window that we are working..

here is my code for ARtookit (C program):

#ifdef _WIN32
#include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#ifndef __APPLE__
#include <GL/gl.h>
#include <GL/glut.h>
#else
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#endif
#include <AR/gsub.h>
#include <AR/video.h>
#include <AR/param.h>
#include <AR/ar.h>

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif


#include <gtk/gtk.h>
#include "interface/src/callbacks.h"
#include "interface/src/interface.h"
#include "interface/src/support.h"


#ifdef G_OS_WIN32

gchar *package_prefix = "";
gchar *package_data_dir ="";
gchar *package_locale_dir = "";

#endif

/* set up the video format globals */

#ifdef _WIN32
char *vconf "Data\\WDM_camera_flipV.xml";

#else
char *vconf = "";

#endif

int xsize, ysize;
int thresh = 100;
int count = 0;

char *cparam_name = "Data/camera_para.dat";
ARParam cparam;

//original pattern
//char *patt_name = "Data/patt.hiro"; //change this line of code to point to a new pattern

/*MY PATTERNS*/
//char *patt_name = "Data/patt.slash"; //testing my first pattern
char *patt_name = "Data/patt.mypattern"; //testing my first pattern


int patt_id;
double patt_width = 80.0;
double patt_center[2] = {0.0, 0.0};
double patt_trans[3][4];

static void init(void);
static void cleanup(void);
static void keyEvent( unsigned char key, int x, int y);
static void mainLoop(void);
static void draw( void );

/****the main from another C program**********/

int main(int argc, char **argv)
{
GtkWidget *win_main;
win_main = create_win_main ();
gtk_widget_show (win_main);
g_signal_connect ((gpointer) win_main, "destroy", G_CALLBACK(gtk_main_quit),
NULL);



glutInit(&argc, argv);
init();

arVideoCapStart();
argMainLoop( NULL, keyEvent, mainLoop );
return (0);
}

static void keyEvent( unsigned char key, int x, int y)
{
/* quit if the ESC key is pressed */
if( key == 0x1b ) {
printf("*** %f (frame/sec)\n", (double)count/arUtilTimer());
cleanup();
exit(0);
}
}

/* main loop */
static void mainLoop(void)
{
ARUint8 *dataPtr;
ARMarkerInfo *marker_info;
int marker_num;
int j, k;

/* grab a vide frame */
if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) {
arUtilSleep(2);
return;
}
if( count == 0 ) arUtilTimerReset();
count++;

argDrawMode2D();
argDispImage( dataPtr, 0,0 );

/* detect the markers in the video frame */
if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) {
cleanup();
exit(0);
}

arVideoCapNext();

/* check for object visibility */
k = -1;
for( j = 0; j < marker_num; j++ ) {
if( patt_id == marker_info[j].id ) {
if( k == -1 ) k = j;
else if( marker_info[k].cf < marker_info[j].cf ) k = j;
}
}
if( k == -1 ) {
argSwapBuffers();
return;
}

/* get the transformation between the marker and the real camera */
arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans);

draw();

argSwapBuffers();
}

static void init( void )
{
ARParam wparam;

/* open the video path */
if( arVideoOpen( vconf ) < 0 ) exit(0);
/* find the size of the window */
if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

/* set the initial camera parameters */
if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
printf("Camera parameter load error !!\n");
exit(0);
}
arParamChangeSize( &wparam, xsize, ysize, &cparam );
arInitCparam( &cparam );
printf("*** Camera Parameter ***\n");
arParamDisp( &cparam );

if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
printf("pattern load error !!\n");
exit(0);
}

/* open the graphics window */
argInit( &cparam, 1.0, 0, 0, 0, 0 );
}

/* cleanup function called when program exits */
static void cleanup(void)
{
arVideoCapStop();
arVideoClose();
argCleanup();
}

static void draw( void )
{
double gl_para[16];
GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};

argDrawMode3D();
argDraw3dCamera( 0, 0 );
glClearDepth( 1.0 );
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

/* load the camera transformation matrix */
argConvGlpara(patt_trans, gl_para);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd( gl_para );

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMatrixMode(GL_MODELVIEW);
glTranslatef( 0.0, 0.0, 25.0 );
//glutSolidCube(50.0);
//glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
glutSolidSphere(40, 20, 10);
glDisable( GL_LIGHTING );

glDisable( GL_DEPTH_TEST );
}


--------------------Configuration: simpleTest - Win32 Debug--------------------
Compiling...
main.c
c:\documents and settings\nitish\desktop\tt\artoolkit\examples\simple\interface\src\main.c(50) : error C2065: 'PACKAGE' : undeclared identifier

c:\documents and settings\nitish\desktop\tt\artoolkit\examples\simple\interface\src\main.c(71)

: warning C4022: 'g_free' : pointer mismatch for actual parameter 1

Error executing cl.exe.

simpleTestd.exe - 1 error(s), 1 warning(s)

well am trying to call the main from another program (Gtk) and i`ve comment it above...

here is the main file of the program (Gtk) which i want to call:

/*
* Initial main.c file generated by Glade. Edit as required.
* Glade will not overwrite this file.
*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <gtk/gtk.h>

#include "interface.h"
#include "support.h"


#ifdef G_OS_WIN32


gchar *package_prefix = "";
gchar *package_data_dir ="";
gchar *package_locale_dir = "";

#endif

int
/*mainn (int argc, char *argv[])*/
main (int argc, char *argv[])
{
GtkWidget *win_main;

gchar *pixmap_dir;
#ifdef G_OS_WIN32
package_prefix = g_win32_get_package_installation_directory (NULL, NULL);
package_data_dir = g_build_filename (package_prefix, "share", NULL);
package_locale_dir = g_build_filename (package_prefix, "share", "locale", NULL);
#endif

#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, package_locale_dir);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif

gtk_set_locale ();
gtk_init (&argc, &argv);


pixmap_dir = g_build_filename (package_data_dir, PACKAGE, "pixmaps", NULL);
add_pixmap_directory (pixmap_dir);
g_free (pixmap_dir);


/*
* The following code was added by Glade to create one of each component
* (except popup menus), just so that you see something after building
* the project. Delete any components that you don't want shown initially.
*/
win_main = create_win_main ();
gtk_widget_show (win_main);
g_signal_connect ((gpointer) win_main, "destroy", G_CALLBACK(gtk_main_quit),
NULL);

gtk_main ();

#ifdef G_OS_WIN32
g_free (package_prefix);
g_free (package_data_dir);
g_free (package_locale_dir);
g_free (PACKAGE);
#endif

return 0;
}
#ifdef _MSC_VER
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
/*return mainn (__argc, __argv);*/
return main (__argc, __argv);
}
#endif


any help is welcomed..thanks

 
PACKET is probably in the definition or ARParam. Possibly a macro. May be an include file problem. What I'd do is

1) go to the include directory and grep (if you're using Windows, findstr) for PACKET in the AR header files.
2) Make sure the header that defines it in included
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top