1)使用emmake make生成llvm位代码会使llvm-ar出现一个错误,提示“归档文件截断或格式错误(归档文件的剩余大小太小。”)。
从这个错误的外观来看,归档文件很小,无法存储所有文件吗?我想知道如何解决该错误,或更具体地说,如何为库和源代码分别生成llvm位代码,然后再将它们链接到emcc中?我要使用的库是libavcodec和libavformat,它们存储在〜/ ffmpeg_build / lib
代码使用以下命令可以正常编译:g ++ ffmpegTest.cpp pkg-config --cflags --libs libavcodec libavformat
使用PKG_CONFIG_PATH =“ / home / daviddjh / ffmpeg_build / lib / pkgconfig”
2)通过不提及CMakeLists.txt中的库,尝试分别制作每个文件(ffmgTest.cpp ..),但出现“找不到'libavcodec / avcodec.h'文件”。
3)这是我的ffmpegTest.cpp:
#ifdef __cplusplus
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
#endif
#include <iostream>
int main(){
char filename[20] = "sample.mp4";
AVFormatContext *pFormatContext = avformat_alloc_context();
avformat_open_input(&pFormatContext, filename, NULL, NULL);
std::cout << "Format: " << pFormatContext->iformat->long_name << std::endl;
return 0;
}
和我的CList:
cmake_minimum_required(VERSION 3.5.1)
project(example)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
INCLUDE_DIRECTORIES(/home/daviddjh/ffmpeg_build/include/)
LINK_DIRECTORIES(/home/daviddjh/ffmpeg_build/lib/)
add_executable(ffmpegTest ffmpegTest.cpp)
TARGET_LINK_LIBRARIES(ffmpegTest libavcodec libavformat)
4)当我使用emmake make生成链接的LLVM位代码时,llvm-ar给出错误:
/home/daviddjh/emsdk/fastcomp/fastcomp/bin/llvm-ar: truncated or malformed archive (remaining size of archive too small for next archive member header at offset 170960388).
Traceback (most recent call last):
File "/home/daviddjh/emsdk/fastcomp/emscripten/emcc.py", line 3420, in <module>
sys.exit(run(sys.argv))
File "/home/daviddjh/emsdk/fastcomp/emscripten/emcc.py", line 1907, in run
final = shared.Building.link(linker_inputs, DEFAULT_FINAL, force_archive_contents=force_archive_contents, just_calculate=just_calculate)
File "/home/daviddjh/emsdk/fastcomp/emscripten/tools/shared.py", line 1978, in link
Building.read_link_inputs([x for x in files if not x.startswith('-')])
File "/home/daviddjh/emsdk/fastcomp/emscripten/tools/shared.py", line 1757, in read_link_inputs
object_names_in_archives = pool.map(extract_archive_contents, archive_names)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 253, in map
return self.map_async(func, iterable, chunksize).get()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 572, in get
raise self._value
我希望能够使用libav *库从.cpp生成位码。然后使用该位代码通过Emscripten生成WASM文件。