Page 1 of 1

Compiling userlibs with LCCwin32 or PellesC

Posted: Tue Jan 29, 2008 9:53 am
by real
Hi,

I just have two questions regarding userlib creation in C, cause it seems that I am not able to recompile a userlib I successfully created once:

I'd like to compile a userlib with PellesC. So I created a new project (static lib), copied the source to the project directory (under {PB}\Library SDK\LccWin32\...), added my .c file to that project and tried to compile. But I got a lot of errors like these already while compiling the headers:
C:\Coding\PureBasic\Library SDK\LccWin32\PureLibrary.h(82): warning #2099: Missing type specifier.
C:\Coding\PureBasic\Library SDK\LccWin32\PureLibrary.h(82): warning #2067: Illegal use of '__stdcall'.
C:\Coding\PureBasic\Library SDK\LccWin32\PureLibrary.h(82): error #2120: Redeclaration of 'TCHAR' previously declared at C:\Programme\PellesC\Include\Win\winnt.h(176): found 'int' expected 'char'.
C:\Coding\PureBasic\Library SDK\LccWin32\PureLibrary.h(82): error #2001: Syntax error: found '*' - expecting ';'.
...
Could anybody explain, what I've done wrong?

:cry:

Like I mentioned: I was able to compile the userlib once - with LCCWin32. But PellesC is more comfortable for me. So, here's the source

Code: Select all

udpbroadcast.c:
~~~~~~~~~~~~~~~~~~~~

#include "udpbroadcast.h"

M_PBFUNCTION int PB_SendUDPBroadcast (int port, const TCHAR *message)
{
  SOCKET              sock;
  int                 one,bytes;
  struct sockaddr_in  remote;
  
  // Socket erzeugen
  sock = socket(PF_INET,SOCK_DGRAM,IPPROTO_IP);
  if ( sock == -1) {
    return 1;
  }
  one = 1;
  // Broadcasts zulassen
  if (setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(const char *)&one,sizeof(one)) == -1) {
    return 1;
  }
  remote.sin_family = AF_INET ;
  remote.sin_port = htons (port);
  remote.sin_addr.s_addr = INADDR_BROADCAST;
  // An den Broadcast versenden
  bytes = sendto(sock,message,strlen(message),0,(struct sockaddr *)&remote,sizeof(remote));
  if ( bytes == -1) {
    return 1;
  }
  else 
  closesocket(sock);
  return 0;
}

udpbroadcast.h:
~~~~~~~~~~~~~~~~~~~~

#include "../PureLibrary.h"
#include "../Object.h"
#include <winsock.h>

#define PB_SendUDPBroadcast     M_UnicodeFunction(PB_SendUDPBroadcast)

udpbroadcast.desc:
~~~~~~~~~~~~~~~~~~~~

; Langage used to code th library: ASM or C
;
C

; Number of windows DLL than the library need
;
1
WSOCK32

; Library type (Can be OBJ or LIB)
;
LIB

; Number of PureBasic library needed by the library
;
0

; Help directory name
;
SendUDPBroadcast

;
; Library functions (FunctionName, Arg1, Arg2, ...)
;
SendUDPBroadcast, long, string, (Port, Message$) - Send UDP broadcast messages
Long | Unicode
Hope you can help me up. Regards
René

Posted: Tue Jan 29, 2008 11:55 pm
by citystate
I don't know that much about uselib creation, but from the error stack you've posted, it looks like your problem lies in PureLibrary.h, any chance of posting it?

Posted: Wed Jan 30, 2008 2:29 pm
by real
PureLibrary.h is included in PureBasic package and installed to {PB}\Library SDK\LccWin32

René