Browse Source

Windows build now working properly

Was opening PNG files (which are binary...) with `r` instead of `rb` which caused problems on windows
Added `libsndfile-1` back into FindLibSndFile.cmake, since it's needed
Package `sndfile.dll` instead of `libsndfile-1.dll` since thats what the binary looks for
tags/v1.8.0
Xerbo 3 years ago
parent
commit
f1979a74d9
6 changed files with 18 additions and 16 deletions
  1. +8
    -8
      .gitignore
  2. +2
    -2
      CMakeLists.txt
  3. +2
    -2
      README.md
  4. +1
    -0
      build_windows.sh
  5. +1
    -1
      cmake/FindLibSndFile.cmake
  6. +4
    -3
      src/pngio.c

+ 8
- 8
.gitignore View File

@@ -48,11 +48,11 @@
*.wav
aptdec

# VSCode
.vscode
# CMake
build
libpng*/
zlib*/
.vscode/
build/
libpng/
zlib/
winbuild/
winpath/
libsndfile-1.0.29-win64.zip
libsndfile-1.0.29-win64/

+ 2
- 2
CMakeLists.txt View File

@@ -5,7 +5,7 @@ project(aptdec)
file(GLOB_RECURSE C_SOURCE_FILES src/*.c)
add_executable(aptdec ${C_SOURCE_FILES})

add_compile_definitions(PALETTE_DIR="${CMAKE_SOURCE_DIR}/palettes")
add_compile_definitions(PALETTE_DIR="../palettes")

# Math
target_link_libraries(aptdec PRIVATE m)
@@ -53,7 +53,7 @@ else()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")

install(TARGETS aptdec DESTINATION "bin/")
install(FILES libpng16.dll libsndfile-1.dll libzlib.dll DESTINATION "bin/")
install(FILES libpng16.dll sndfile.dll libzlib.dll DESTINATION "bin/")
install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes/" DESTINATION "palettes/")
endif()



+ 2
- 2
README.md View File

@@ -123,9 +123,9 @@ cmake ..
make
```

Since cmake is now being used for building, windows support has come. You can build for windows with the `build_windows.sh` script, you will need wine and mingw64 installed:
Since CMake is now being used for building, windows support has come. You can build for windows with the `build_windows.sh` script, you will need the following:
```
./build_windows.sh
sudo apt install wget cmake make mingw-w64 git unzip
```

## Further Reading


+ 1
- 0
build_windows.sh View File

@@ -37,6 +37,7 @@ cp "libsndfile-1.0.29-win64/include/sndfile.h" $TEMP_PATH/include/sndfile.h

# Copy DLL's into root for CPack
cp $TEMP_PATH/bin/*.dll ../
mv ../libsndfile-1.dll ../sndfile.dll

# Build aptdec
mkdir -p winbuild && cd winbuild


+ 1
- 1
cmake/FindLibSndFile.cmake View File

@@ -1,7 +1,7 @@
# Find libsndfile
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h)

SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile)
SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile libsndfile-1)
FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH)

IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)


+ 4
- 3
src/pngio.c View File

@@ -142,7 +142,8 @@ int mapOverlay(char *filename, rgb_t **crow, int nrow, int zenith, int MCIR) {
}

int readRawImage(char *filename, float **prow, int *nrow) {
FILE *fp = fopen(filename, "r");
FILE *fp = fopen(filename, "rb");
printf("%s", filename);
if(!fp) {
fprintf(stderr, "Cannot open %s\n", filename);
return 0;
@@ -206,12 +207,12 @@ int readRawImage(char *filename, float **prow, int *nrow) {
}

int readPalette(char *filename, rgb_t **pixels) {
FILE *fp = fopen(filename, "r");
FILE *fp = fopen(filename, "rb");
if(!fp) {
char buffer[1024];
// PALETTE_DIR is set through CMake
sprintf(buffer, PALETTE_DIR"/%s", filename);
fp = fopen(buffer, "r");
fp = fopen(buffer, "rb");
if(!fp){
fprintf(stderr, "Cannot open %s\n", filename);
return 0;


Loading…
Cancel
Save