Hello,
I am new to Pelles C.
I have deep experiences with C under Unix plattforms,
but none with C under Win32.
Actually I try to create a dll file which shall contain a function mytest()
I'd like to call from several different exe files.
To do this I've got a Demo.h template which looks like this:
#ifndef DEMO_H
#define DEMO_H
typedef char bool;
struct DEMO_DATASTRUCT
{
int year,month,day,starttime,endtime;
bool plotme;
bool ascii_been_here;
};
extern "C" double __declspec(dllexport) mytest(DEMO_DATASTRUCT *price_ptr,
int currentptr, int *int_args, int num_int_args, double *double_args,
int num_double_args, char **string_args, int num_string_args);
#endif
The according c-source Demo.c file has this content:
#include <windows.h>
#include "Demo.h"
//---------------------------------------------------------------------------
extern "C" double __declspec(dllexport) mytest(DEMO_DATASTRUCT *price_ptr,
int currentptr, int *int_args, int num_int_args, double *double_args,
int num_double_args, char **string_args, int num_string_args)
{
/* well, this function actually does nothing usefull,
however, it should compile without failure */
return 0.4711;
}
#pragma argsused
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return 1;
}
My question regarding Pelles C is,
how must this template be modified to compile it as a dll library.
I'd appreciate, if anyone could explain me this.
Thanks in advance
Christoph
For example:
Demo.h
#ifndef DEMO_H
#define DEMO_H
typedef char bool;
typedef struct tagDEMO_DATASTRUCT
{
int year,month,day,starttime,endtime;
bool plotme;
bool ascii_been_here;
} DEMO_DATASTRUCT;
#ifdef __cplusplus
extern "C"
{
#endif
double __declspec(dllexport) mytest(DEMO_DATASTRUCT *price_ptr,
int currentptr, int *int_args, int num_int_args, double *double_args,
int num_double_args, char **string_args, int num_string_args);
#ifdef __cplusplus
}
#endif
#endif
Demo.c
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "Demo.h"
//---------------------------------------------------------------------------
double __declspec(dllexport) mytest(DEMO_DATASTRUCT *price_ptr,
int currentptr, int *int_args, int num_int_args, double *double_args,
int num_double_args, char **string_args, int num_string_args)
{
/* well, this function actually does nothing usefull,
however, it should compile without failure */
return 0.4711;
}
#pragma argsused
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return 1;
}
Thank you very much.
The compiler also creates
C:\Programme\PellesC\Projects\demo\demo.exp
C:\Programme\PellesC\Projects\demo\demo.lib
What are these files good for?
And another question, please, too:
if I want to access a function residing in an other already finished dll,
how do I have to declare it within my Demo.c ?
I have a swe32.dll which has a function built in
which is called swe_date_conversion() for instance.
The function is defined as
int swe_date_conversion(
int yyyy, int month, int day,
double hour,
double *tjd);
I want to call it in function mytest() as coded in Demo.c
Now mytest() looks like:
double __declspec(dllexport) mytest(DEMO_DATASTRUCT *price_ptr,
int currentptr, int *int_args, int num_int_args, double *double_args,
int num_double_args, char **string_args, int num_string_args)
{
double tjd = 0.0;
int vdate = swe_date_conversion(2008, 4, 9, 12.0, &tjd);
return tjd;
}
Actually I get "POLINK: error: Unresolved external symbol '__imp__swe_date_conversion'."
I thinks it's a matter of declaration here.
Please can you show me how to declare the swe_date_conversion() correctly?
Quote from: Feierabend on April 09, 2008, 09:56:57 AMActually I get "POLINK: error: Unresolved external symbol '__imp__swe_date_conversion'."
I thinks it's a matter of declaration here.
Please can you show me how to declare the swe_date_conversion() correctly?
Include the swe32.lib in the Linker options of the Project options for your project.