
Recherche avancée
Autres articles (89)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir
Sur d’autres sites (13573)
-
ffmpeg code does not link (undefined reference to avcodec_register_all
28 janvier 2013, par SriramI am trying to compile a simple introductory program using
ffmpeg
that tries to check if themp3
codec is available. While the code compiles OK, I am facing difficulty in solving linker errors. Here is the code :#include
#include
#include <libavcodec></libavcodec>avcodec.h>
float *generateSinusoid(unsigned int sampleRate, unsigned int nSecondsAudio) {
unsigned int nsamples = (nSecondsAudio * sampleRate);
float *arr;
arr = (float*) malloc(sizeof(float) * nsamples);
int i = 0;
for(i = 0; i < nsamples; i++) {
arr[i] = 20 * sin(2.f * (M_PI) * (330/sampleRate) * i); /*frequency of 330H
z*/
}
return arr;
}
int main(int argc, char *argv[]) {
avcodec_register_all();
AVCodec *codec;
unsigned int sampleRate = 22050; /*assumed.*/
unsigned int nSecondsAudio = 4;
float *arr;
arr = (float *) malloc(sizeof(float) * nSecondsAudio * sampleRate);
/*Step 1. Generate sinusoid.*/
arr = generateSinusoid(sampleRate, nSecondsAudio);
/* Step 2. See if encoder exists.*/
/*codec = avcodec_find_encoder(AV_CODEC_ID_MP3);*/
if(!codec) { /*codec = NULL.*/
printf("MP3 codec not found!!!!");
} else {
printf("MP3 codec found!!!");
}
return 0;
}The code is compiled and linked like so :
encoding_mp3: encoding_mp3.o
gcc encoding_mp3.o -o encoding_mp3 -L/cygdrive/c/Users/Desktop/webserver/cygnus/lib/w32api -L/cygdrive/c/Users/Desktop/webserver/cygnus/ffmpeg/ffmpeg_dev/lib -lm -luser32 -lpthread -lavcodec
encoding_mp3.o: encoding_mp3.c
gcc -I/cygdrive/c/Users/Desktop/webserver/cygnus/ffmpeg/ffmpeg_dev/include -I/cygdrive/c/Users/Desktop/webserver/cygnus/usr/include -g -c encoding_mp3.c -o encoding_mp3.o
clean:
rm encoding_mp3.o encoding_mp3Linking gives the following error :
gcc -I/cygdrive/c/Users/Desktop/webserver/cygnus/ffmpeg/ffmpeg_dev/include -I/cygdrive/c/Users/Desktop/webserver/cygnus/usr/include -g -c encoding_mp3.c -o encoding_mp3.o
gcc encoding_mp3.o -o encoding_mp3 -L/cygdrive/c/Users/Desktop/webserver/cygnus/lib/w32api -L/cygdrive/c/Users/Desktop/webserver/cygnus/ffmpeg/ffmpeg_dev/lib -lm -luser32 -lpthread -lavcodec
encoding_mp3.o: In function `main':
/cygdrive/c/Users/Desktop/webserver/cygnus/ffmpeg/work/encoding_mp3.c:31: undefined reference to `_avcodec_register_all'
collect2: ld returned 1 exit status
make: *** [encoding_mp3] Error 1I have gone through most of the threads on SO regarding this problem and here is what I have tried so far :
Put libraries at the end of all non-option arguments
Commented out code that references functions. This seems to work. The
undefined reference
errors go away after all function calls are removed, though the presence of a structAVCodec
does not cause any problems.Any help on this is most welcome.
-
CMake specifies link libraries in wrong order [duplicate]
18 janvier 2021, par Jamie RoyerI'm following a youtube video on building a project with CMake and FFmpeg. The author is using a Mac and I'm using Ubuntu 20.04. I've been following along successfully until hitting this problem. cmake —version returns 3.16.3


For some reason it is specifying the libraries too early so nothing is imported :


~/video-app/build# cmake ..
~/video-app/build# make VERBOSE=1
...
/usr/bin/c++ \
 -lavcodec -lavformat \ # << Too early
 CMakeFiles/video-app.dir/src/main.cpp.o \
 CMakeFiles/video-app.dir/src/load_frame.cpp.o \
 -o video-app \ # << Should be here
 lib/glfw/src/libglfw3.a \
 -lGL -lGLU -lpthread /usr/lib/x86_64-linux-gnu/librt.so -lm -ldl



If I manually run the command with the -l (dash ell) reordered, it compiles successfully.


Here is the contents of the two CMakeLists.txt files.


# video-app/CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(video-app C CXX)
set(CMAKE_CXX_STANDARD 14)
add_subdirectory(lib/glfw)
add_subdirectory(lib/FFmpeg)
list(APPEND EXTRA_LIBS "-lGL -lGLU")
list(APPEND SOURCES src/main.cpp src/load_frame.cpp)
add_executable(video-app ${SOURCES})
target_link_libraries(video-app FFmpeg glfw ${EXTRA_LIBS})



# video-app/lib/CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(FFmpeg)
find_package(PkgConfig REQUIRED)
# There are seven libraries in original - only two shown here for brevity.
pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec)
pkg_check_modules(AVFORMAT REQUIRED IMPORTED_TARGET libavformat)
add_library(FFmpeg INTERFACE IMPORTED GLOBAL)
target_include_directories(FFmpeg INTERFACE
 ${AVCODEC_INCLUDE_DIRS}
 ${AVFORMAT_INCLUDE_DIRS})
target_link_options(FFmpeg INTERFACE
 ${AVCODEC_LDFLAGS}
 ${AVFORMAT_LDFLAGS})



I tried :


- 

- Changing the order of target_link_libraries in top CMake file. Funny thing is, it worked once.
- I tried adding target_link_libraries to FFmpeg CMake file.
- Searching for stackover.com for answers and reading CMake documentation.








-
Cannot link with libswscale properly using cmake. Undefined symbols for architecture x86_64 : sws_getContext()
8 novembre 2022, par J. JohnsonI'm building a small project that will output video. I'm trying to link to libswscale to convert RGBA to YUV420, however, the linker
ld
cannot successfully find libswscale symbols.

Undefined symbols for architecture x86_64:
 "sws_getContext(int, int, AVPixelFormat, int, int, AVPixelFormat, int, SwsFilter*, SwsFilter*, double const*)", referenced from:
 VideoWriter::writeFrame(std::__1::vector >) in video_writer.cpp.o



The offending line of code is this.


struct SwsContext *sws_ctx = sws_getContext(
 avCodecContext->width, avCodecContext->height, AV_PIX_FMT_RGBA,
 avCodecContext->width, avCodecContext->height, AV_PIX_FMT_YUV420P,
 SWS_BILINEAR, NULL, NULL, NULL);



When I use -v on clang I see that the libswscale.dylib is being passed to
ld
. The dylib exists on the file system and is the same version as the library's header, as verified byotool
.

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.15.0 11.1 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -o bin/main -search_paths_first -headerpad_max_install_names CMakeFiles/main.dir/src/main.cpp.o CMakeFiles/main.dir/src/window.cpp.o CMakeFiles/main.dir/src/video_writer.cpp.o -rpath /usr/local/lib /usr/local/lib/libGLEW.2.2.0.dylib /usr/local/lib/libboost_program_options-mt.dylib -framework OpenGL /usr/local/Cellar/sdl2_image/2.6.2/lib/libSDL2_image.dylib /usr/local/lib/libSDL2.dylib /usr/local/Cellar/ffmpeg/5.1.2/lib/libavcodec.dylib /usr/local/Cellar/ffmpeg/5.1.2/lib/libswscale.dylib /usr/local/Cellar/ffmpeg/5.1.2/lib/libavutil.dylib -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a -F/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks



This is my cmake file.


cmake_minimum_required(VERSION 3.19.2)

project(FragTool VERSION 1.0)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

# --- c++ build settings --- #
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++ -O0")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(CMAKE_BUILD_TYPE Debug)

# --- dependencies --- #
find_package(GLEW REQUIRED)
find_package(Boost 1.79.0 COMPONENTS program_options REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
 libavcodec
 libswscale
 libavutil
)

pkg_check_modules(LIBSDL2 REQUIRED IMPORTED_TARGET
 sdl2
 sdl2_image
)

set(EXECUTABLE main)
add_executable(${EXECUTABLE} src/main.cpp)
target_sources(${EXECUTABLE} PRIVATE
 ${CMAKE_SOURCE_DIR}/src/window.cpp
 ${CMAKE_SOURCE_DIR}/src/video_writer.cpp
)

target_include_directories(${EXECUTABLE} PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_include_directories(${EXECUTABLE} PRIVATE ${GLEW_INCLUDE_DIRS})

target_link_libraries(${EXECUTABLE} PRIVATE GLEW::glew)
target_link_libraries(${EXECUTABLE} PRIVATE ${Boost_LIBRARIES})
target_link_libraries(${EXECUTABLE} PRIVATE PkgConfig::LIBSDL2)
target_link_libraries(${EXECUTABLE} PRIVATE PkgConfig::LIBAV)



I'm stumped as to what could be causing the linker to fail, given that it is being passed the libswscale dylib correctly as far as I can tell. I checked for any other versions of the dylib on the system that maybe are shadowing it, but didn't see any.