PureData 是一种用于声音合成的编程语言。LibPD 是它的包装器,因此我们可以在 Java/C#/Android 等中使用补丁。这是包含它的 GitHub 页面:https ://github.com/libpd/libpd
现在要在 Java 中使用 LibPD,我认为首先我应该将它的库导入我的项目,然后使用它的类和方法来调用我的补丁并调整它。问题是,我找不到要添加到项目中的 jar 文件。我是否必须“构建”一些东西才能生成 jar 文件?
如果有人向我解释程序,我将不胜感激。
谢谢
更新 1[2017-01-11]:
在关注 @umläute 的帖子后,我收到以下错误:(我MinGW
在 Windows 7/64 位和MinGW-make
for 中使用make
)
C:\Users\Name\Documents\GitHub>cd libpd
C:\Users\Name\Documents\GitHub\libpd>git submodule init
C:\Users\Name\Documents\GitHub\libpd>git submodule update
C:\Users\Name\Documents\GitHub\libpd>make javalib
'make' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Name\Documents\GitHub\libpd>mingw32-make javalib
process_begin: CreateProcess(NULL, uname, ...) failed.
'sed' is not recognized as an internal or external command,
operable program or batch file.
'sed' is not recognized as an internal or external command,
operable program or batch file.
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_arithmetic.o pure-data/src/d_arithmetic.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_array.o pure-data/src/d_array.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_ctl.o pure-data/src/d_ctl.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_dac.o pure-data/src/d_dac.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_delay.o pure-data/src/d_delay.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_fft.o pure-data/src/d_fft.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_fft_fftsg.o pure-data/src/d_fft_fftsg.c
pure-data/src/d_fft_fftsg.c: In function 'mayer_dofft':
pure-data/src/d_fft_fftsg.c:88:11: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by
default]
buf = alloca(n * (2 * sizeof(FFTFLT)));
^
pure-data/src/d_fft_fftsg.c: In function 'mayer_realfft':
pure-data/src/d_fft_fftsg.c:121:11: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by
default]
buf = alloca(n * sizeof(FFTFLT));
^
pure-data/src/d_fft_fftsg.c: In function 'mayer_realifft':
pure-data/src/d_fft_fftsg.c:139:11: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by
default]
buf = alloca(n * sizeof(FFTFLT));
^
pure-data/src/d_fft_fftsg.c: In function 'pd_fft':
pure-data/src/d_fft_fftsg.c:156:30: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by
default]
FFTFLT *buf2 = (FFTFLT *)alloca(2 * npoints * sizeof(FFTFLT)), *bp2;
^
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_filter.o pure-data/src/d_filter.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_global.o pure-data/src/d_global.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_math.o pure-data/src/d_math.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_osc.o pure-data/src/d_osc.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_resample.o pure-data/src/d_resample.c
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o pure-data/src/d_soundfile.o pure-data/src/d_soundfile.c
pure-data/src/d_soundfile.c:17:21: fatal error: pthread.h: No such file or directory
#include <pthread.h>
^
compilation terminated.
<builtin>: recipe for target 'pure-data/src/d_soundfile.o' failed
mingw32-make: *** [pure-data/src/d_soundfile.o] Error 1
更新 2 [2017-01-11]:
我已经安装了MSYS2
, mingw32
and 64
and make
(感谢@milleniumbug 的帮助)。我已经为mingw64
和make
to添加了目录PATH
。现在当我这样做时,make javalib
我得到了这个错误:
C:\Users\Name\Documents\GitHub\libpd>make javalib
gcc -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper -I./libpd_wrapper/util -DWINVER=0x502 -DWIN
32 -D_WIN32 -DPD_INTERNAL -I"C:\Program Files\Java\jdk1.8.0_45/include" -I"C:\Program Files\Java\jdk1.8.0_45/include/win
32" -O3 -c -o jni/z_jni_plain.o jni/z_jni_plain.c
In file included from jni/z_jni_shared.c:8:0,
from jni/z_jni_plain.c:8:
jni/z_jni.h:2:10: fatal error: jni.h: No such file or directory
#include <jni.h>
^~~~~~~
更新 3 [4-11-2017]:
修复 jni.h
了问题。我的 PATH 指向旧的 jdk 而不是更新的 jdk。现在我收到此错误:
C:/msys32/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Cannot export libpd
_set_concatenated_printhook: symbol not found
C:/msys32/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture o
f input file `libpd_wrapper/util/z_print_util.o' is incompatible with i386:x86-64 output
libpd_wrapper/util/z_print_util.o:z_print_util.c:(.text+0x3a): undefined reference to `_strlen'
libpd_wrapper/util/z_print_util.o:z_print_util.c:(.text+0x75): undefined reference to `_strncat'
libpd_wrapper/util/z_print_util.o:z_print_util.c:(.text+0xad): undefined reference to `_strncat'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:163: java-build/org/puredata/core/natives/windows/x86_64//pdnative.dll] Error 1
用 32 位 MinGW gcc 测试它......仍然是同样的错误......
更新 4 [2017 年 6 月 11 日]:
修复了问题
看来我已经设法解决了。这是我通常所做的:
1- 首先我安装了 msys2 并彻底安装它,MinGW32
并且注意:如果您从旧的原始站点获得它MinGW64
,请删除它。它不再更新,您可能会遇到依赖性问题。
2- 将 PATH 更改为使用 MinGW32(因此应报告 32 位版本)
3- 将 JAVA_HOME 更改为更新后的 jdk 目录。似乎更新 java 不会自动更新 env。变量(这解决了问题)。
4-通过命令安装和获取(按照存储库自述文件中的说明)
5-
6-
7-make
mingw32
gcc -v
jni header not found
git
libpd
git
make clean
make clean libpd
make clean javalib
我希望这可以帮助别人