This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

how to include some dll functions in a project


Dear all,

I am testing the USB HID generic AtUsbHid.dll from Atmel in order to build a
small pc application that can communicate with an ATusb162 through USB
canal.

Actually I can compile successfully when the functions from AtUsbHid.dll are
used in the main.c file.

File main.c that compile fine:
[code]
/*file main.c */
#include <stdio.h>
#include <windows.h>
#include "AtUsbHid.h"

int main(int arg, char* argv[])
{
  HINSTANCE hLib = NULL;
  hLib = LoadLibrary(AT_USB_HID_DLL);
  if(loadFuncPointers(hLib)) printf ("loaded");
  FreeLibrary(hLib);
  return 0;
}
[/code]

The command used was:
[code]
g++ -Wall main.c AtUsbHid.dll -o main
[/code]
--->>> Until this point it works just fine. :)

Problems arrive when I try to use the functions in another file.

Please have a look at the following:
The main.c file:
[code]
/*file main.c*/
#include "bidon.h"
int main(int arg, char* argv[])
{
  test();
  return 0;
}
[/code]
The bidon.h file:
[code]
/*file bidon.h*/
#ifndef _BIDON_H_
#define _BIDON_H_ 
#include <stdio.h>
#include <windows.h>
#include "AtUsbHid.h"

#define VID 0x03EB
#define PID 0x2013

extern void test(void);

#endif /*_BIDON_H_*/ 
[/code]

And the bidon.c file:
[code]
/*file: bidon.c*/
#include "bidon.h"

void test(void)
{
  HINSTANCE hLib = NULL;
  hLib = LoadLibrary(AT_USB_HID_DLL);
  if(loadFuncPointers(hLib)) printf("\r\nloaded"); 
  if(DYNCALL(findHidDevice(VID, PID))) printf("\r\nopened");
  DYNCALL(writeData)((UCHAR *)"11");
  Sleep(100);
  DYNCALL(writeData)((UCHAR *)"01");
  afficher();
  DYNCALL(closeDevice());
  FreeLibrary(hLib);
  printf("\r\nclosed\r\n");
}
[/code]

When compiling with:
[code]
g++ -Wall main.c bidon.c AtUsbHid.dll -o main
[/code]

I got the following error:
[code]
AtUsbHid.h:107: warning: 'bool loadFuncPointers(HINSTANCE__*)' defined but
not used
C:/DOCUME~1/SBIGLE~1.LHT/LOCALS~1/Temp/ccZYEZ1v.o:bidon.c:(.bss+0x0):
multiple definition of `_lpfindHidDevice'
C:/DOCUME~1/SBIGLE~1.LHT/LOCALS~1/Temp/ccGROaaE.o:main.c:(.bss+0x0): first
defined here
C
.....
...
..
.
[/code]


I would appreciate any comment or advice.
Thank you for helping.
Stephane

-- 
View this message in context: http://www.nabble.com/how-to-include-some-dll-functions-in-a-project-tp20625105p20625105.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]