Merge pull request #9 from i2p/windows-libsam3
Adds support for Windows to both libsam and libsam3a.
This commit is contained in:
6
Makefile
6
Makefile
@ -16,7 +16,6 @@ OBJS := ${LIB_OBJS} ${TEST_OBJS}
|
||||
|
||||
LIB := libsam3.a
|
||||
|
||||
|
||||
all: build check
|
||||
|
||||
check: libsam3-tests
|
||||
@ -34,8 +33,11 @@ clean:
|
||||
rm -f libsam3-tests ${LIB} ${OBJS} examples/sam3/samtest
|
||||
|
||||
%.o: %.c Makefile
|
||||
${CC} ${CFLAGS} -c $< -o $@
|
||||
${CC} ${CFLAGS} $(LDFLAGS) -c $< -o $@
|
||||
|
||||
fmt:
|
||||
find . -name '*.c' -exec clang-format -i {} \;
|
||||
find . -name '*.h' -exec clang-format -i {} \;
|
||||
|
||||
info:
|
||||
@echo $(AR)
|
||||
|
36
README.md
36
README.md
@ -6,7 +6,7 @@ A C library for the [SAM v3 API](https://geti2p.net/en/docs/api/samv3).
|
||||
|
||||
## Development Status
|
||||
|
||||
Unmaintained, but PRs welcome!
|
||||
Maintained by idk, PRs are accepted on [I2P gitlab](https://i2pgit.org/i2p-hackers/libsam3)/[I2P gitlab](http://git.idk.i2p/i2p-hackers/libsam3), and on github at the official mirror repository: [i2p/libsam3](https://github.com/i2p/libsam3).
|
||||
|
||||
## Usage
|
||||
|
||||
@ -16,3 +16,37 @@ Copy the two files from one of the following locations into your codebase:
|
||||
- `src/libsam3a` - Asynchronous implementation.
|
||||
|
||||
See `examples/` for how to use various parts of the API.
|
||||
|
||||
## Cross-Compiling for Windows from debian:
|
||||
|
||||
Set your cross-compiler up:
|
||||
|
||||
``` sh
|
||||
export CC=x86_64-w64-mingw32-gcc
|
||||
export CFLAGS='-Wall -O2 '
|
||||
export LDFLAGS='-lmingw32 -lws2_32 -lwsock32 -mwindows'
|
||||
```
|
||||
|
||||
and run `make build`. Only libsam3 is available for Windows, libsam3a will be
|
||||
made available at a later date.
|
||||
`
|
||||
|
||||
## Linker(Windows)
|
||||
|
||||
When building for Windows remember to set the flags to link to the Winsock and Windows
|
||||
libraries.
|
||||
|
||||
`-lmingw32 -lws2_32 -lwsock32 -mwindows`
|
||||
|
||||
This may apply when cross-compiling or compiling from Windows with mingw.
|
||||
|
||||
## Cool Projects using libsam3
|
||||
|
||||
Are you using libsam3 to provide an a cool I2P based feature to your project? Let us know about it(and how
|
||||
it uses libsam3) and we'll think about adding it here*!
|
||||
|
||||
1. [Retroshare](https://retroshare.cc)
|
||||
|
||||
*Projects which are listed here must be actively maintained. Those which intentionally violate
|
||||
the law or the rights of a person or persons directly won't be considered. Neither will obvious
|
||||
trolling. The maintainer will make the final decision.
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@ -20,12 +19,27 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
//#include <winsock.h>
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#ifndef MSG_NOSIGNAL
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
#ifndef SHUT_RDWR
|
||||
#define SHUT_RDWR 2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __unix__
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int libsam3_debug = 0;
|
||||
|
||||
|
@ -10,9 +10,18 @@
|
||||
#ifndef LIBSAM3_H
|
||||
#define LIBSAM3_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
#define _SSIZE_T_DEFINED
|
||||
#undef ssize_t
|
||||
#ifdef _WIN64
|
||||
typedef signed int64 ssize_t;
|
||||
typedef int ssize_t;
|
||||
#endif /* _WIN64 */
|
||||
#endif /* _SSIZE_T_DEFINED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@ -22,13 +21,28 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
//#include <winsock.h>
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#ifndef MSG_NOSIGNAL
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
#ifndef SHUT_RDWR
|
||||
#define SHUT_RDWR 2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __unix__
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int libsam3a_debug = 0;
|
||||
|
||||
|
@ -18,6 +18,17 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
//#include <winsock.h>
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
//#define SOCK_CLOEXEC O_CLOEXEC
|
||||
//#define SOCK_NONBLOCK O_NONBLOCK
|
||||
#define SOCK_CLOEXEC 02000000
|
||||
#define SOCK_NONBLOCK FIONBIO
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user