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 fortags/v1.8.0
@@ -48,11 +48,11 @@ | |||||
*.wav | *.wav | ||||
aptdec | aptdec | ||||
# VSCode | |||||
.vscode | |||||
# CMake | |||||
build | |||||
libpng*/ | |||||
zlib*/ | |||||
.vscode/ | |||||
build/ | |||||
libpng/ | |||||
zlib/ | |||||
winbuild/ | |||||
winpath/ | |||||
libsndfile-1.0.29-win64.zip | |||||
libsndfile-1.0.29-win64/ |
@@ -5,7 +5,7 @@ project(aptdec) | |||||
file(GLOB_RECURSE C_SOURCE_FILES src/*.c) | file(GLOB_RECURSE C_SOURCE_FILES src/*.c) | ||||
add_executable(aptdec ${C_SOURCE_FILES}) | add_executable(aptdec ${C_SOURCE_FILES}) | ||||
add_compile_definitions(PALETTE_DIR="${CMAKE_SOURCE_DIR}/palettes") | |||||
add_compile_definitions(PALETTE_DIR="../palettes") | |||||
# Math | # Math | ||||
target_link_libraries(aptdec PRIVATE m) | target_link_libraries(aptdec PRIVATE m) | ||||
@@ -53,7 +53,7 @@ else() | |||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") | set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") | ||||
install(TARGETS aptdec DESTINATION "bin/") | 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/") | install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes/" DESTINATION "palettes/") | ||||
endif() | endif() | ||||
@@ -123,9 +123,9 @@ cmake .. | |||||
make | 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 | ## Further Reading | ||||
@@ -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 | # Copy DLL's into root for CPack | ||||
cp $TEMP_PATH/bin/*.dll ../ | cp $TEMP_PATH/bin/*.dll ../ | ||||
mv ../libsndfile-1.dll ../sndfile.dll | |||||
# Build aptdec | # Build aptdec | ||||
mkdir -p winbuild && cd winbuild | mkdir -p winbuild && cd winbuild | ||||
@@ -1,7 +1,7 @@ | |||||
# Find libsndfile | # Find libsndfile | ||||
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h) | 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) | FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH) | ||||
IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY) | IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY) | ||||
@@ -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) { | int readRawImage(char *filename, float **prow, int *nrow) { | ||||
FILE *fp = fopen(filename, "r"); | |||||
FILE *fp = fopen(filename, "rb"); | |||||
printf("%s", filename); | |||||
if(!fp) { | if(!fp) { | ||||
fprintf(stderr, "Cannot open %s\n", filename); | fprintf(stderr, "Cannot open %s\n", filename); | ||||
return 0; | return 0; | ||||
@@ -206,12 +207,12 @@ int readRawImage(char *filename, float **prow, int *nrow) { | |||||
} | } | ||||
int readPalette(char *filename, rgb_t **pixels) { | int readPalette(char *filename, rgb_t **pixels) { | ||||
FILE *fp = fopen(filename, "r"); | |||||
FILE *fp = fopen(filename, "rb"); | |||||
if(!fp) { | if(!fp) { | ||||
char buffer[1024]; | char buffer[1024]; | ||||
// PALETTE_DIR is set through CMake | // PALETTE_DIR is set through CMake | ||||
sprintf(buffer, PALETTE_DIR"/%s", filename); | sprintf(buffer, PALETTE_DIR"/%s", filename); | ||||
fp = fopen(buffer, "r"); | |||||
fp = fopen(buffer, "rb"); | |||||
if(!fp){ | if(!fp){ | ||||
fprintf(stderr, "Cannot open %s\n", filename); | fprintf(stderr, "Cannot open %s\n", filename); | ||||
return 0; | return 0; | ||||