Skip to content

Commit

Permalink
Fix windows build, and windows build docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Relintai committed Jan 21, 2024
1 parent fb6de89 commit ed5efaf
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 10 deletions.
1 change: 1 addition & 0 deletions compile_windows_sfwl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ ccache g++ -Wall \
sfwl/object/array.o sfwl/object/dictionary.o sfwl/object/ref_ptr.o \
sfwl/object/resource.o \
sfwl/main.o \
-lShlwapi -lws2_32 \
-o game

2 changes: 1 addition & 1 deletion demos/build_scripts/sfwl/compile_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ g++ -Wall -g -c main.cpp -o main.o

# You might need to add -lpthread and/or -latomic depending on your compiler version

g++ -Wall -g sfwl.o main.o -o game
g++ -Wall -g sfwl.o main.o -lShlwapi -lws2_32 -o game
2 changes: 1 addition & 1 deletion sfw/core/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ T *_nullptr() {
* Windows badly defines a lot of stuff we'll never use. Undefine it.
*/

#ifdef _WIN32
#if defined(_WIN64) || defined(_WIN32)
#undef min // override standard definition
#undef max // override standard definition
#undef ERROR // override (really stupid) wingdi.h standard definition
Expand Down
6 changes: 6 additions & 0 deletions sfw/object/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ Variant Array::pop_at(int p_pos) {
return ret;
}

#if defined(_WIN64) || defined(_WIN32)
// Windows...
#undef min
#undef max
#endif

Variant Array::min() const {
Variant minval;
for (int i = 0; i < size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion sfwl/core/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ T *_nullptr() {
* Windows badly defines a lot of stuff we'll never use. Undefine it.
*/

#ifdef _WIN32
#if defined(_WIN64) || defined(_WIN32)
#undef min // override standard definition
#undef max // override standard definition
#undef ERROR // override (really stupid) wingdi.h standard definition
Expand Down
6 changes: 6 additions & 0 deletions sfwl/object/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ Variant Array::pop_at(int p_pos) {
return ret;
}

#if defined(_WIN64) || defined(_WIN32)
// Windows...
#undef min
#undef max
#endif

Variant Array::min() const {
Variant minval;
for (int i = 0; i < size(); i++) {
Expand Down
32 changes: 29 additions & 3 deletions tools/doc/compilation_no_renderer.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@

## IDE Setup

If you use an ide, just add these files to your project (so the .cpp file gets compiled), and you are done.
If you use an ide, add these files to your project (so the .cpp file gets compiled).

If you are using MingW (If you use the g++ command on windows, that is MingW!), then
find a section in your ide that says something similar to `link to libraries`. Usually
is't under a linker settings section, and add the following entries: `Shlwapi`, `ws2_32`.

If you use anything else, you are done.

## Manual setup

### g++ / mingw
### g++ - Linux / OSX

If you are using a compiler directly, then just add `sfw.cpp` or `sfwl.cpp` to the list of files that you are compiling:


```
g++ -g sfw.cpp main.cpp -o prog
```
Expand All @@ -32,6 +37,27 @@
g++ -g sfw.o main.o -o prog
```

### g++ / mingw - Windows

If you are using a compiler directly, then add `sfw.cpp` or `sfwl.cpp` to the list of files that you are compiling,
and link to `lShlwapi` and `ws2_32`:


```
g++ -g sfw.cpp main.cpp -lShlwapi -lws2_32 -o prog
```

Note: -g means add debug information to the executable.

If you are creating object files:

```
g++ -g -c sfw.cpp -o sfw.o
g++ -g -c main.cpp -o main.o

g++ -g sfw.o main.o -lShlwapi -lws2_32 -o prog
```

### MSVC

If you are using a compiler directly, then just add `sfw.cpp` or `sfwl.cpp` to the list of files that you are compiling:
Expand Down
7 changes: 5 additions & 2 deletions tools/merger/sfwl/sfwl_core.cpp.inl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <ctime>
#include <wchar.h>
#include <cstdint>
#include <memory.h>

#if !defined(_WIN64) && !defined(_WIN32)
#include <sys/time.h>
#include <unistd.h>
#endif

#ifndef SFWL_H
#include "sfwl.h"
#endif
Expand Down
7 changes: 5 additions & 2 deletions tools/merger/sfwl/sfwl_full.cpp.inl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <ctime>
#include <wchar.h>
#include <cstdint>
#include <memory.h>

#if !defined(_WIN64) && !defined(_WIN32)
#include <sys/time.h>
#include <unistd.h>
#endif

#ifndef SFWL_H
#include "sfwl.h"
#endif
Expand Down

0 comments on commit ed5efaf

Please sign in to comment.