我正在尝试创建一个嵌入FFMPEG功能的C ++程序。 为此,我举了一个FFMPEG示例,并使用g ++对其进行了重新编译(仅在需要时添加extern“ C”)。 编译成功,但未定义符号的链接失败。
pipeline = [
{
"$match": {
"images" : {
"$ne" : None,
"$exists": True,
}
}
},
{
"$match": {
"img_status": {
"$exists": False,
}
}
},
{
"$group":{
"_id" : "$vendor_link",
"images" : {"$first": "$images"},
"uuid" : {"$first": "$uuid"},
"source" : {"$first": "$source"}
}
},
]
pprint(list(self.collection.aggregate(pipeline)))
检查nm,我发现实际上没有名称修饰,因此外部C似乎运行良好:
const WebSocket = require('ws');
var quote
// BitMEX Connection
'use strict';
const BitMEXClient = require('./index');
const client = new BitMEXClient({testnet: false});
client.on('error', console.error);
client.on('open', () => console.log('Listening for BVOL.'));
client.on('close', () => console.log('Connection closed.'));
client.on('initialize', () => console.log('BitMEX API Connected.'));
client.addStream('XBTUSD', 'trade', function (data, symbol, tableName)
{
if (!data.length) return;
var a = data[data.length - 1];
console.log(a.size,a.timestamp);
});
检查库,对于“缺失”符号之一,我可以看到它已实现
<ion-button color="{{color}}" (click)="action.emit(null)" disabled [attr.disabled]="(condition)?condition:null">
{{title}}</ion-button>
在C语言中编译时,它可以完美运行(当然没有extern C),这让我想知道我还缺少什么?
在下面找到FFMPEG示例代码以供参考(decode_video.cpp):
cc -I/usr/include/x86_64-linux-gnu -Wall -g -fPIC -c -o bin/decode_video.o decode_video.cpp
cc -Wl,--export-dynamic,--no-undefined -L /usr/lib/x86_64-linux-gnu/ -shared -lavdevice -lavutil -lavcodec bin/decode_video.o -o decode_video.so
bin/decode_video.o: In function `decode(AVCodecContext*, AVFrame*, AVPacket*, char const*)':
/home/admin1/ffmpeg_examples/decode_video.cpp:60: undefined reference to `avcodec_send_packet'
/home/admin1/ffmpeg_examples/decode_video.cpp:67: undefined reference to `avcodec_receive_frame'
bin/decode_video.o: In function `main':
/home/admin1/ffmpeg_examples/decode_video.cpp:108: undefined reference to `av_packet_alloc'
/home/admin1/ffmpeg_examples/decode_video.cpp:116: undefined reference to `avcodec_find_decoder'
/home/admin1/ffmpeg_examples/decode_video.cpp:122: undefined reference to `av_parser_init'
/home/admin1/ffmpeg_examples/decode_video.cpp:128: undefined reference to `avcodec_alloc_context3'
/home/admin1/ffmpeg_examples/decode_video.cpp:139: undefined reference to `avcodec_open2'
/home/admin1/ffmpeg_examples/decode_video.cpp:150: undefined reference to `av_frame_alloc'
/home/admin1/ffmpeg_examples/decode_video.cpp:165: undefined reference to `av_parser_parse2'
/home/admin1/ffmpeg_examples/decode_video.cpp:184: undefined reference to `av_parser_close'
/home/admin1/ffmpeg_examples/decode_video.cpp:185: undefined reference to `avcodec_free_context'
/home/admin1/ffmpeg_examples/decode_video.cpp:186: undefined reference to `av_frame_free'
/home/admin1/ffmpeg_examples/decode_video.cpp:187: undefined reference to `av_packet_free'
答案 0 :(得分:1)
感谢@WhozCraig帮助我弄清楚了。 链接时我以为我保留了完整的库符号时使用了错误的标志,但这是错误的标志。因此,链接器只通过了一次,对象顺序错误(因为我自然认为这没关系) 要保留完整的库符号,请将--whole-archive传递给链接器:
-Wl,--whole-archive