如何提供链接时找不到的功能

How to provide functions that cannot be found at linking?

本文关键字:功能 找不到 何提供 链接      更新时间:2023-10-16

当我尝试编译我的应用时,我会得到两个错误:

$ g -static -emit -swf -o cloudclient.swf -i ../boost/boost/boost_libraries/install -dir/incluct -i ../ffm peg-1.0/bin/include -l ../boost/boost_libraries/install-dir/lib -l ../ffmpeg-1.0/bin/lib timer.o audio_encoder.o audio_generator.o video_encoder.o video_generator_rainbow.o sim ple_synchronizer.o多路复用器.o transmitter.o graph_runner.o cloud_client.o -lswscale -lavformat -lavcodec -lavcodec -lavutil -lboostrongystem -lboostrongystem -lboost_date_date_time_time -lboost_thread -pthread -pthread -pthread -pthread -lm

lm
../ffmpeg-1.0/bin/lib/libswscale.a: error: undefined reference to 'exp'
../ffmpeg-1.0/bin/lib/libavcodec.a: error: undefined reference to 'log'
collect2: ld returned 1 exit status

如果logexp是我的问题,如果我放置-lm的任何地方,我无济于事,我想知道如何从字面上创建自己的存根而代替explog并将我的Libs与它们联系起来?....

您将在c文件中实现它们(而不是由C编译器编译,而不是C 编译器),或在C 文件中实现它们,然后给出然后给出外部" C"链接。例如:

extern "C" double log(double x)
{
    // ...
}

显然,解决链接问题会更好。您不必提供自己的标准C库例程的版本。