使用 Adobe Alchemy 的 libFLAC 移植问题
我正在尝试使用 Adobe Alchemy 移植 FLAC 编码器以在 Flash 中使用,但无法找出问题所在。
我在 Windows 上使用 Alchemy for Cygwin。它已正确安装和配置。
以下是我移植 FLAC 编码器所遵循的步骤:
- 下载最新版本的 FLAC 源 (1.2.1)
- 配置 FLAC 源 (
./configure --enable-static=true --enable-shared =false
)启用alchemy(配置前alc-on
) - 启用alchemy编译libFLAC(src/libFLAC文件夹中的
make
) - 复制头文件并将静态库(libFLAC.a)编译到 alchemy 文件夹(分别为 ${ACLHEMY_HOME}/usr/local/include 和 ${ACLHEMY_HOME}/usr/local/lib )
- 最后,以这种方式编译 SWC:
gccencodeflac.c -O3 -Wall -swc -lFLAC -oencodeflac.swc
或(无论如何)gccencodeflac.c -O3 -Wall -swc -lflac -oencodeflac.swc
encodeflac.c 是 FLAC 源代码中包含的示例的修改版本 (examples/c/encode/file/main .c) 并采用与 ActionScript ByteArrays 一起使用。
SWC 将编译,不会出现警告或错误。但最终的swc大小只有85kb,而静态库大小(libFLAC.a)约为1mb!另外,编码不起作用。 尝试在 AS 中使用它时出现以下错误:[故障]异常,信息=未定义符号:FLAC_stream_encoder_new
是不是说明swc中不包含静态库呢?为什么?
提前致谢。
I'm trying to port FLAC encoder using Adobe Alchemy for use in flash but can't figure out where the problem is.
I'm using Alchemy for Cygwin on Windows. It is properly installed and configured.
The following are the steps that I have followed in order to port FLAC encoder:
- Download the latest version of FLAC sources (1.2.1)
- Configure FLAC sources (
./configure --enable-static=true --enable-shared=false
) with the alchemy enabled (alc-on
before configure) - Compile libFLAC with the alchemy enabled (
make
in src/libFLAC folder) - Copy header files and compiled static library (libFLAC.a) to alchemy folders (${ACLHEMY_HOME}/usr/local/include and ${ACLHEMY_HOME}/usr/local/lib respectively)
- Finally, compile SWC in that way:
gcc encodeflac.c -O3 -Wall -swc -lFLAC -o encodeflac.swc
or (whatever)gcc encodeflac.c -O3 -Wall -swc -lflac -o encodeflac.swc
encodeflac.c is the modified version of example included in FLAC sources (examples/c/encode/file/main.c) and adopted to work with ActionScript ByteArrays.
The swc will compile without warnings or errors. But the final swc size is only 85kb, while the static library size (libFLAC.a) is about 1mb! Also, the encoding is not working.
I get the following error when trying to use it in AS:[Fault] exception, information=Undefined sym: FLAC_stream_encoder_new
Does it mean that the static library is not included in swc? Why?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Alchemy 的 swc 链接器没有很好的错误报告,这使得调试变得困难。发生的情况是链接器找不到该库。如何修复它:
不幸的是,让它实际链接最终会产生链接时错误:
我在尝试将 libFLAC (v1.2.1) 构建为一个整体(而不仅仅是库)。当某种 C 代码生成 Alchemy 无法处理的 LLVM 字节码时,就会发生此错误。 (目前还不清楚这是 LLVM 产生的问题还是 Alchemy 的错误。)
您必须找出有问题的代码在哪里,并将其更改为 Alchemy 喜欢的代码(而不实际更改逻辑!)。我似乎记得有人在使用 ffmpeg 时遇到过类似的问题:
http://forums.adobe.com/message/2905914#2905914
Alchemy's swc linker doesn't have very good error reporting, which makes debugging it hard. What's happening is that the linker isn't finding the lib. How to fix it:
Unfortunately, getting it to actually link ends up producing a link-time error:
I saw this same error when trying to build libFLAC (v1.2.1) as a whole (not just the library). This error happens when there's some kind of C code that produces LLVM bytecode that Alchemy can't handle. (It's unclear if this is a problem with what LLVM produces or a bug with Alchemy.)
You have to figure out where the offending code is and change it into something that Alchemy likes (without actually changing the logic!). I seem to remember someone having a similar problem with ffmpeg:
http://forums.adobe.com/message/2905914#2905914
我花了一段时间,但我设法在stream_encoder.c(版本1.2.1)的第956行找到了这个分配的链接错误:
它实际上似乎与宽方法的符号名称有关。还没想出好的解决办法。当我这样做时,我会修改我的答案。请注意,只有当块大小太大(16 位时超过 4096)时,这才是一个问题,默认情况下从来不会出现这种情况,因此您可以安全地注释掉分配,而不是处理真正的问题...
请注意:当您实际使用 Flac 库并且您得到的只是零时,请检查 bitwriter.c 中的 SWAP_BE_WORD_TO_HOST 宏。由于某种原因 ntohl 只返回零。尝试像这样定义您自己的字节顺序交换器:
希望它可以帮助任何尝试在 alchemy 中编译 Flac 库的人。
Took me a while but I managed to track down the linking error to this assignment on line 956 in stream_encoder.c (version 1.2.1):
It actually seems to have something to do with the symbol name of the wide method. Haven't figured out a good solution yet. I'll amend my answer when I do. Do note that this is only an issue if the block size is too big (more than 4096 at 16 bits), which by default never is the case, so you can safely comment out the assignment and not deal with the real problem...
And just a heads up: when you are actually using the Flac library and all you're getting is zeros, check the SWAP_BE_WORD_TO_HOST macro in bitwriter.c. For some reason ntohl is only returning zeros. Try defining your own endianness swapper like this:
Hope it helps anyone trying to get the Flac lib to compile in alchemy.