Skip to content

Commit 64a36d7

Browse files
committed
Better static linking instructions
Signed-off-by: Pttn <28868425+Pttn@users.noreply.github.com>
1 parent a7b8c7f commit 64a36d7

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ endif
1515

1616
all: rieMiner
1717

18-
release: CFLAGS += -DNDEBUG
19-
release: rieMiner
20-
2118
debug: CFLAGS += -g
2219
debug: rieMiner
2320

21+
static: CFLAGS += -D CURL_STATICLIB -I incs/
22+
static: LIBS := -static -L libs/ $(LIBS)
23+
static: rieMiner
24+
2425
rieMiner: main.o Miner.o StratumClient.o GBTClient.o Client.o WorkManager.cpp Stats.cpp tools.o mod_1_4.o mod_1_2_avx.o mod_1_2_avx2.o fermat.o primetest.o primetest512.o
2526
$(CXX) $(CFLAGS) -o rieMiner $^ $(LIBS)
2627

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,24 @@ Clone rieMiner with git like for Linux, go to its directory with cd, and compile
7272

7373
#### Static building
7474

75-
The produced executable will only run in the MSYS console, or if all the needed DLLs are next to the executable. To obtain a standalone executable, you need to link statically the dependencies. Normally, this is done just by adding "-static" at the LIBS line in the Makefile. Unfortunately, libcurl will give you a hard time, and you need to compile it yourself.
75+
The produced executable will only run in the MSYS console, or if all the needed DLLs are next to the executable. To obtain a standalone executable, you need to link statically the dependencies. Unfortunately, libcurl will give you a hard time, and you need to compile it yourself.
7676

77-
First, edit the Makefile to add "-D CURL_STATICLIB" at the end of the CFLAGS line and "-static" just after the "LIBS =" in the first LIBS line. You might also want to change the march argument to support other/olders processors.
77+
First, download the [latest official libcurl code](https://curl.haxx.se/download.html) on their website, under "Source Archives", and decompress the folder somewhere (for example, next to the rieMiner's one).
7878

79-
```
80-
CFLAGS = -Wall -Wextra -std=gnu++11 -O3 -march=native -fno-pie -no-pie -D CURL_STATICLIB
81-
[...]
82-
LIBS = -static -pthread -ljansson -lcurl -lcrypto -lgmpxx -lgmp -lws2_32 -Wl,--image-base -Wl,0x10000000
83-
```
84-
85-
Then, download the [latest official libcurl code](https://curl.haxx.se/download.html) on their website, under "Source Archives", and decompress the folder somewhere (for example, next to the rieMiner's one).
86-
87-
In the MSYS MinGW-w64 console, cd to the libcurl directory. We will now configure it to not build unused features:
79+
In the MSYS MinGW-w64 console, cd to the libcurl directory. We will now configure it to not build unused features, then compile it:
8880

8981
```bash
9082
./configure --disable-dict --disable-file --disable-ftp --disable-gopher --disable-imap --disable-ldap --disable-ldaps --disable-pop3 --disable-rtsp --disable-smtp --disable-telnet --disable-tftp --without-ssl --without-libssh2 --without-zlib --without-brotli --without-libidn2 --without-ldap --without-ldaps --without-rtsp --without-psl --without-librtmp --without-libpsl --without-nghttp2 --disable-shared --disable-libcurl-option
83+
make
9184
```
9285

93-
Then, compile libcurl with make. We now need to replace the existing libcurl headers and libs provided by MinGW:
86+
Once done:
9487

95-
* In the downloaded libcurl directory, go to the include directory and copy the "curl" folder to replace the one in X:\path\to\msys64\mingw64\include (make a backup if needed);
96-
* Do the same with the file "libcurl.a" in the libs/.lib folder to replace the one in X:\path\to\msys64\mingw64\lib (make a backup if needed).
88+
* Create "incs" and "libs" folders in the rieMiner directory;
89+
* In the downloaded libcurl directory, go to the include directory and copy the "curl" folder to the "incs" folder;
90+
* Do the same with the file "libcurl.a" from the libs/.lib folder to the rieMiner's "libs" folder.
9791

98-
Now, you should be able to compile rieMiner with make and produce a standalone executable.
92+
Now, you should be able to compile rieMiner with "make static" and produce a standalone executable.
9993

10094
## Run and configure this program
10195

0 commit comments

Comments
 (0)