使用 Adob​​e Alchemy 的 libFLAC 移植问题

发布于 2024-11-07 08:32:26 字数 994 浏览 0 评论 0原文

我正在尝试使用 Adob​​e Alchemy 移植 FLAC 编码器以在 Flash 中使用,但无法找出问题所在。
我在 Windows 上使用 Alchemy for Cygwin。它已正确安装和配置。
以下是我移植 FLAC 编码器所遵循的步骤:

  1. 下载最新版本的 FLAC 源 (1.2.1)
  2. 配置 FLAC 源 (./configure --enable-static=true --enable-shared =false)启用alchemy(配置前alc-on
  3. 启用alchemy编译libFLAC(sr​​c/libFLAC文件夹中的make
  4. 复制头文件并将静态库(libFLAC.a)编译到 alchemy 文件夹(分别为 ${ACLHEMY_HOME}/usr/local/include 和 ${ACLHEMY_HOME}/usr/local/lib )
  5. 最后,以这种方式编译 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:

  1. Download the latest version of FLAC sources (1.2.1)
  2. Configure FLAC sources (./configure --enable-static=true --enable-shared=false) with the alchemy enabled (alc-on before configure)
  3. Compile libFLAC with the alchemy enabled (make in src/libFLAC folder)
  4. Copy header files and compiled static library (libFLAC.a) to alchemy folders (${ACLHEMY_HOME}/usr/local/include and ${ACLHEMY_HOME}/usr/local/lib respectively)
  5. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜嗑 2024-11-14 08:32:26

Alchemy 的 swc 链接器没有很好的错误报告,这使得调试变得困难。发生的情况是链接器找不到该库。如何修复它:

  1. gcc 区分大小写。您必须使用 -lFLAC (不是 -lflac)
  2. alchemy 需要构建 libFLAC.a 时生成的 FLAC.l.bc 文件

不幸的是,让它实际链接最终会产生链接时错误:

Cannot yet select: 0x198b960: i32 = ConstantPool < i64 6881500230622117888> 0
0   llc                                 0x00636dfe _ZNSt8_Rb_treeIN4llvm3sys4PathES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE13insert_uniqueERKS2_ + 6078
1   llc                                 0x006373a2 _ZNSt8_Rb_treeIN4llvm3sys4PathES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE13insert_uniqueERKS2_ + 7522
2   libSystem.B.dylib                   0x9402f2bb _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   libSystem.B.dylib                   0x940a323a raise + 26
5   libSystem.B.dylib                   0x940af679 abort + 73
6   llc                                 0x002f862b _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel10SelectCodeEN4llvm9SDOperandE + 187
7   llc                                 0x002fa193 _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel10SelectRootEN4llvm9SDOperandE + 819
8   llc                                 0x002e6a2c _ZN4llvm19X86_64TargetMachineD0Ev + 65116
9   llc                                 0x003de4ca _ZN4llvm11StoreSDNodeD1Ev + 1610
10  llc                                 0x0040d3fe _ZN4llvm11StoreSDNodeD1Ev + 193918
11  llc                                 0x0040f92e _ZN4llvm11StoreSDNodeD1Ev + 203438
12  llc                                 0x005d1926 _ZN4llvm12FunctionPassD1Ev + 20998
13  llc                                 0x005d1f3a _ZN4llvm12FunctionPassD1Ev + 22554
14  llc                                 0x005d20c5 _ZN4llvm12FunctionPassD1Ev + 22949
15  llc                                 0x00002e44 _mh_execute_header + 7748
16  llc                                 0x00001f36 _mh_execute_header + 3894
17  ???                                 0x00000006 0x0 + 6

我在尝试将 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:

  1. gcc is case-sensitive. You must use -lFLAC (not -lflac)
  2. alchemy needs the FLAC.l.bc file that was generated when you built libFLAC.a

Unfortunately, getting it to actually link ends up producing a link-time error:

Cannot yet select: 0x198b960: i32 = ConstantPool < i64 6881500230622117888> 0
0   llc                                 0x00636dfe _ZNSt8_Rb_treeIN4llvm3sys4PathES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE13insert_uniqueERKS2_ + 6078
1   llc                                 0x006373a2 _ZNSt8_Rb_treeIN4llvm3sys4PathES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE13insert_uniqueERKS2_ + 7522
2   libSystem.B.dylib                   0x9402f2bb _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   libSystem.B.dylib                   0x940a323a raise + 26
5   libSystem.B.dylib                   0x940af679 abort + 73
6   llc                                 0x002f862b _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel10SelectCodeEN4llvm9SDOperandE + 187
7   llc                                 0x002fa193 _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel10SelectRootEN4llvm9SDOperandE + 819
8   llc                                 0x002e6a2c _ZN4llvm19X86_64TargetMachineD0Ev + 65116
9   llc                                 0x003de4ca _ZN4llvm11StoreSDNodeD1Ev + 1610
10  llc                                 0x0040d3fe _ZN4llvm11StoreSDNodeD1Ev + 193918
11  llc                                 0x0040f92e _ZN4llvm11StoreSDNodeD1Ev + 203438
12  llc                                 0x005d1926 _ZN4llvm12FunctionPassD1Ev + 20998
13  llc                                 0x005d1f3a _ZN4llvm12FunctionPassD1Ev + 22554
14  llc                                 0x005d20c5 _ZN4llvm12FunctionPassD1Ev + 22949
15  llc                                 0x00002e44 _mh_execute_header + 7748
16  llc                                 0x00001f36 _mh_execute_header + 3894
17  ???                                 0x00000006 0x0 + 6

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

初雪 2024-11-14 08:32:26

我花了一段时间,但我设法在stream_encoder.c(版本1.2.1)的第956行找到了这个分配的链接错误:

encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_wide

它实际上似乎与宽方法的符号名称有关。还没想出好的解决办法。当我这样做时,我会修改我的答案。请注意,只有当块大小太大(16 位时超过 4096)时,这才是一个问题,默认情况下从来不会出现这种情况,因此您可以安全地注释掉分配,而不是处理真正的问题...

请注意:当您实际使用 Flac 库并且您得到的只是零时,请检查 bitwriter.c 中的 SWAP_BE_WORD_TO_HOST 宏。由于某种原因 ntohl 只返回零。尝试像这样定义您自己的字节顺序交换器:

#define SWAP_BE_WORD_TO_HOST(x) (x<<24|(x&0x0000FF00)<<8|(x&0x00FF0000)>>8|x>>24)

希望它可以帮助任何尝试在 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):

encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_wide

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:

#define SWAP_BE_WORD_TO_HOST(x) (x<<24|(x&0x0000FF00)<<8|(x&0x00FF0000)>>8|x>>24)

Hope it helps anyone trying to get the Flac lib to compile in alchemy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文