-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FFMPEG ignores --enable-pic option #44134
Comments
Using the latest version of vcpkg for local installation does not reproduce the issue. Would you please provide a repro step or commands? I've tried |
Did you try to link ffmpeg with your dynamic library not executable? it will fail compilation. |
i meant ffpeg builds but it cant be linked |
The following usage test passes. cmake_minimum_required(VERSION 3.25.1)
project(Test VERSION 0.1.2.3 LANGUAGES CXX)
add_executable(main c.cpp)
target_compile_features(main PRIVATE cxx_std_23)
find_package(FFMPEG REQUIRED)
target_include_directories(main PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_directories(main PRIVATE ${FFMPEG_LIBRARY_DIRS})
target_link_libraries(main PRIVATE ${FFMPEG_LIBRARIES}) #ifdef __cplusplus
extern "C" {
#endif
#include "libavcodec/avcodec.h"
#include "libavutil/avutil.h"
#ifdef __cplusplus
}
#endif
#include <iostream>
int main() {
std::cout << "ffmpeg" << std::endl;
std::cout << av_version_info() << std::endl;
return 0;
}
Would you please provide a simple repro case? |
no, use add_library(main MODULE c.cpp) and it will fail |
#ifdef __cplusplus
extern "C" {
#endif
#include "libavcodec/avcodec.h"
#include "libavutil/avutil.h"
#ifdef __cplusplus
}
#endif
#include <iostream>
__attribute__ ((visibility ("default"))) int main() {
avcodec_find_encoder(AV_CODEC_ID_H264);
std::cout << "ffmpeg" << std::endl;
std::cout << av_version_info() << std::endl;
return 0;
} project(Test VERSION 0.1.2.3 LANGUAGES CXX)
add_library(main MODULE library.cpp)
target_compile_features(main PRIVATE cxx_std_23)
find_package(FFMPEG REQUIRED)
target_include_directories(main PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_directories(main PRIVATE ${FFMPEG_LIBRARY_DIRS})
target_link_libraries(main PRIVATE ${FFMPEG_LIBRARIES}) Build log:
Repo with this sample: https://github.com/orange-cpp/ffpmeg-fpic-error-cmake |
When i build ffmpeg on arch linux using
vcpkg install ffmpeg:x64-linux
i got error from linker:libswscale.a(swscale.o): warning: relocation against
ff_M24B' in read-only section.text' /usr/bin/ld: ibavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol
ff_pw_9' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: bad value
`
But in vcpkg output
--enable-pic
is set by default.How can i make FFMPEG link normaly in my .so program?
PS: I need to static linking of FFMPEG.
The text was updated successfully, but these errors were encountered: