[Proj] Using proj on Windows

Anthony Dunk AnthonyD at rocketmail.com
Wed Feb 8 23:21:52 EST 2006


Hi Jeff,

You need to dynamically load the PROJ DLL using some code such as the
following:

//
// PROJ4 DLL interface
//

static HINSTANCE g_ProjDLL = NULL;

typedef struct { double u, v; } projUV;

// Proj DLL function pointers
static projPJ       (*pfn_pj_init_plus)(const char *) = NULL;
static projPJ       (*pfn_pj_init)(int, char**) = NULL;
static projUV       (*pfn_pj_fwd)(projUV, projPJ) = NULL;
static projUV       (*pfn_pj_inv)(projUV, projPJ) = NULL;
static void     (*pfn_pj_free)(projPJ) = NULL;
static int      (*pfn_pj_transform)(projPJ, projPJ, long, int, 
                                    double *, double *, double * ) =
NULL;
static int         *(*pfn_pj_get_errno_ref)(void) = NULL;
static char        *(*pfn_pj_strerrno)(int) = NULL;
static char        *(*pfn_pj_get_def)(projPJ,int) = NULL;
static void         (*pfn_pj_dalloc)(void *) = NULL;

static BOOL LoadProjDLL()
{
	g_ProjDLL = LoadLibrary("proj.dll");
	if (g_ProjDLL==NULL) return FALSE;

    pfn_pj_init = (projPJ (*)(int, char**)) GetProcAddress( g_ProjDLL,
"pj_init");
    
    if( pfn_pj_init == NULL )  return( FALSE );

    pfn_pj_init_plus = (projPJ (*)(const char *)) GetProcAddress(
g_ProjDLL, "pj_init_plus");
    pfn_pj_fwd = (projUV (*)(projUV,projPJ))      GetProcAddress(
g_ProjDLL, "pj_fwd" );
    pfn_pj_inv = (projUV (*)(projUV,projPJ))      GetProcAddress(
g_ProjDLL, "pj_inv" );
    pfn_pj_free = (void (*)(projPJ))		      GetProcAddress( g_ProjDLL,
"pj_free" );
    pfn_pj_transform = (int (*)(projPJ,projPJ,long,int,double*,
                                double*,double*)) GetProcAddress(
g_ProjDLL, "pj_transform" );
    pfn_pj_get_errno_ref = (int *(*)(void))		  GetProcAddress(
g_ProjDLL, "pj_get_errno_ref" );
    pfn_pj_strerrno = (char *(*)(int))			  GetProcAddress( g_ProjDLL,
"pj_strerrno" );
    pfn_pj_get_def = (char *(*)(projPJ,int))      GetProcAddress(
g_ProjDLL, "pj_get_def" );
    pfn_pj_dalloc = (void (*)(void*))			  GetProcAddress( g_ProjDLL,
"pj_dalloc" );

	return TRUE;
}


Cheers,
Anthony.


--- Jeff Holt <jjholt at hiwaay.net> wrote:

> 
> I need to use proj.dll within a VC++ (version 6) project, however I
> can't
> find a .lib file to link against. Is there a distribution that has a
> proj.lib? Or do I have to get the source and create one myself?
> 
> Thanks!
> 
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
> 




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Proj mailing list