Compiling FFmpeg with Libass using MSVC - c++

First a bit of background.
I'm trying to compile ffmpeg on windows with the libass extensions/configuration option.
Using the visual studio project libass-msvc I built libass using Visual Studio as a static lib.
I then installed MinGW with MSYS and pkg-config. Following the instructions on the ffmpeg MSVC installation guide I configured the environment to build with the MSVC linker and to build in x64.
When I try to configure libass for compilation using ./configure --enable-libass --toolchain=msvc I get the following error in the log file:
File not found ass/ass.h
pkg-config can not find libass
I have tried the following to fix this.
Create a .pc file for libass and add this to the PKG_CONFIG_PATH environment variable. See file content below. (After doing this pkg-config libass --version prints 0.81, not the right version number but at least something.)
Copy libass .h files into a MinGW/include/ass folder and the .lib file into the MinGW/libs folder.
Add libass include and bin folders to PATH environment variable
Download libass and dependencies source then try to build it using MSYS with MSVC compiler. My aim here was to be able to use "make install" and let MinGW install libass to the correct locations. After hours of trying to fix linker errors, I abandoned this idea as some of the libass dependencies make files only work with the GCC GNU compiler.
Compile libass with GCC GNU using MinGW make/make install then try and install libass using the GNU libs. Again this led to linker errors (I know this was a bad idea but was worth a try).
Tried using extra lib and include build configuration options --extra-cflags="ffmpeg-dir/extra/include" \
--extra-ldflags="ffmped-dir/extra/ffmpeg_build/lib" then adding the libs and .h files into those locations
.pc file
libass.pc:
prefix=/MinGW
includedir=libass-directory/include
libdir=libass-director/x64/bin/
Name: libass
Description: Libass project
Version: 0.13.7
I am now completely stuck and out of ideas if anyone could give any insight or suggestions into what I'm doing wrong that would be fantastic.
Update
I created INCLUDE and LIBDIR environment path variable containing the libass paths. Which now correctly includes libass. However, I now get the following linker error for the function check_ass_library_init.
check_func_headers ass/ass.h ass_library_init
check_ld cc
check_cc
BEGIN ./ffconf.RZMYFWdc/test.c
1 #include
2 #include
3 long check_ass_library_init(void) { return (long)
ass_library_init; }
4 int main(void) { int ret = 0;
5 ret |= ((intptr_t)check_ass_library_init) & 0xFFFF;
6 return ret; }
END ./ffconf.RZMYFWdc/test.c
cl -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -
D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -
D_WIN32_WINNT=0x0502 -nologo -c -Fo./ffconf.RZMYFWdc/test.o
./ffconf.RZMYFWdc/test.c
test.c
./ffconf.RZMYFWdc/test.c(3): warning C4311: 'type cast': pointer truncation
from 'ASS_Library *(__cdecl *)(void)' to 'long'
./compat/windows/mslink -nologo -out:./ffconf.RZMYFWdc/test.exe
./ffconf.RZMYFWdc/test.o psapi.lib advapi32.lib shell32.lib ole32.lib
test.o : error LNK2019: unresolved external symbol ass_library_init
referenced in function check_ass_library_init
./ffconf.RZMYFWdc/test.exe : fatal error LNK1120: 1 unresolved externals
ERROR: libass not found using pkg-config
The libass test project which uses ass_library_init compiles fine using the same lib files, the libs appear to be fine.
From what I see from this line "./compat/windows/mslink -nologo -out:./ffconf.RZMYFWdc/test.exe ./ffconf.RZMYFWdc/test.o psapi.lib advapi32.lib shell32.lib ole32.lib" libass is not being passed to the linker.
I suspect that the configuration file is not creating the link to libass in the make file when compiling with MSVC.
Am I correct or am I going about compiling this in the wrong way?

Related

Finding libgtest linker library for codeblocks ide

I am trying to run gtest on the codeblocks ide in ubuntu 17.10. It keeps coming back with undefined reference to "x" error.
After some googling it seems that that the ide is missing linker libraries for gtest. Where may I find the linker libraries for gtest?
I have installed gtest using this command:
sudo apt install libgtest-dev
and test built it using this command:
g++ -I /usr/include/gtest -I /usr/src/gtest/ -c /usr/src/gtest/src/gtest-all.cc
The linker to gtest is -lgtest wich you should add in project/build options/Linker settings -> other linker options. Make sure to select the right target (Debug/release) on the left menu.
A good step by step guide has been made here
Based on the answer by Some programmer referencing linking googletestand codeblocks
I found libgtest.a and pthread in the following directories:
/usr/lib/libgtest.a
/usr/lib/x86_64-linux-gnu/libpthread.so
I added the two files through Settings --> Compiler... --> Linker Settings
My test now compiles.

Library not found for -ljson11 but -lsqlite 3 is found

I'm trying to implement this tutorial with the addition that I want to include the json11 C++ library.
I followed the same process for both, downloaded the repo from:
https://github.com/libmx3/mx3, added them to the /deps/ folder of my project, and ran GYP to generate the .xcodeproj files for both.
Then I create a C++ project, add both the projects into the workspace, and add the libraries under Build Phases->Link binaries with libraries.
When I hit run the build fails with ld: library not found for -ljson11
I have tried regenerating them and adding them into the main xcodeproj. and into the Target Dependencies.
I have double-checked the library projects and they are identical. I have also added the folders where the .a files are compiled in Library Search paths but none of this makes a difference. If I remove the json11 dependency the project compiles, but I can't understand why the sqlite3 is found and throws no errors but the identical json11 project won't work.
I can see the .a files in the Debug-build folder and there are no errors if I build them separately.
Heres the full build log
Ld /Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug/DjinniTest normal x86_64
cd /Users/myuser/Documents/Dev/djinni_test/cpp_project
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-arch x86_64
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-L/Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug
-L/Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug/..
-F/Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug
-filelist /Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Intermediates/DjinniTest.build/Debug/DjinniTest.build/Objects-normal/x86_64/DjinniTest.LinkFileList
-mmacosx-version-min=10.11
-stdlib=libc++
-ljson11
-lsqlite3
-Xlinker
-dependency_info
-Xlinker /Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Intermediates/DjinniTest.build/Debug/DjinniTest.build/Objects-normal/x86_64/DjinniTest_dependency_info.dat
-o /Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug/DjinniTest
ld: library not found for
-ljson11
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Edit: even if I add the compiled files into the project so that they turn black, it still complains that the ljson11 library is not found. Maybe there's something wrong with the way the library is compiled?
Both the libraries gave warning that "macosx" was not found in the supported platforms. When I added it into the json11 project settings, the build compiled and both the warnings disappeared.
SQlite3 still only has iOS(iphone,iphonesimulator) but it compiles fine. I wonder what the difference is.

Building a wxWidgets program in Code::Blocks

I'm trying to build this wxWidgets sample program using Code::Blocks 12.11 but the build fails no matter what I try.
For example, the build log shows the following (the project is under X:\programming\c++\HelloWxWidgets):
mingw32-g++.exe -Wall -fexceptions -g -D_GNUWIN32_ -D_WXMSW_ -DwxUSE_UNICODE -D_WXDEBUG_ -IC:\libraries\wxWidgets-2.8.12.01\include -IC:\libraries\wxWidgets-2.8.12.01\contrib\include -IC:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\mswud -c X:\programming\c++\HelloWxWidgets\hworld2.cpp -o obj\Debug2\hworld2.o
mingw32-g++.exe -LC:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib -o bin\Debug2\HelloWxWidgets.exe obj\Debug2\hworld2.o -static-libgcc C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a
C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a(monolib_window.o): In function ZN8wxWindow6UpdateEv':
C:\BuildAgent\work\wxPack\wxwidgets\build\msw/../../src/msw/window.cpp:1643: undefined reference toGdiFlush#0'
C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a(monolib_window.o): In function ZNK8wxWindow13GetTextExtentERK8wxStringPiS3_S3_S3_PK6wxFont':
C:\BuildAgent\work\wxPack\wxwidgets\build\msw/../../src/msw/window.cpp:2132: undefined reference toGetTextExtentPoint32W#16'
C:\BuildAgent\work\wxPack\wxwidgets\build\msw/../../src/msw/window.cpp:2133: undefined reference to `GetTextMetricsW#8'
And these are some of the build messages that I get
C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a(monolib_window.o)||In function ZN8wxWindow6UpdateEv':|
C:\BuildAgent\work\wxPack\wxwidgets\build\msw\..\..\src\msw\window.cpp|1643|undefined reference toGdiFlush#0'|
C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a(monolib_window.o)||In function ZNK8wxWindow13GetTextExtentERK8wxStringPiS3_S3_S3_PK6wxFont':|
C:\BuildAgent\work\wxPack\wxwidgets\build\msw\..\..\src\msw\window.cpp|2132|undefined reference toGetTextExtentPoint32W#16'|
C:\BuildAgent\work\wxPack\wxwidgets\build\msw....\src\msw\window.cpp|2133|undefined reference to `GetTextMetricsW#8'|
Here are the full build log and all of the build messages (by the way, I don't have a C:\BuildAgent directory)
I am using wxPack 2.8.12 (installed in C:\libraries\wxWidgets-2.8.12.01) and GCC 4.7.2 (installed separately from Code::Blocks in C:\mingw using mingw-get )
Here are the build options in Code::Blocks
compiler settings > defines
linker settings
search directories > compiler
search directories > linker
search directories > resource compiler
Thank you in advance of your help :)
Alright, I finally managed to get it working :)
I'm posting here the procedure to follow if, like me, someone wanted to use wxWidgets in an (initially) console project under Code::Blocks. With this, anyone should be able to build/run at least this sample code in a Wind0ws environment:
I'll assume that Code::Blocks and MinGW are correctly setup.
Download/Install wxMSW from http://www.wxwidgets.org/downloads/ (in my case, I downloaded wxMSW-2.8.12-Setup.exe and installed it in C:\libraries\wxWidgets-2.8.12)
Open a command prompt, wxWidgets needs to be built, I'll take the exemple of a statically-linked, monolithic, debug build that uses unicode (more infos here):
cd /D C:\libraries\wxWidgets-2.8.12\build\msw
mingw32-make -f makefile.gcc BUILD=debug SHARED=0 MONOLITHIC=1 UNICODE=1
:(mingw32-make will take some time to build the library)
Open Code::Blocks
Create a new console project, or if you already have a console project (and you plan to add a wxWidgets GUI to it) open it
Right-click on the project > Build options
Here are the build options that I used for the Debug build.
Build & Run
[EDIT] wx/app.h should be included in addition to wx/wx.h
#include <wx/wx.h>
#include <wx/app.h>
You probably need to add following libs to linker settings (I took the list from VS 2012 but for GCC should be the same, you will need to add -luuid -luser32 .... to linker advanced options)
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib
UPD: can see taht chris suggested to add gdi32 lib. Looks reasonable for me. At least missing functions from your logs are defined there.
I found a best way is that add ``wx-config --libs all` in your "other liner options" ,On this ,many issue will gone.
wxconfig screen shot

I can't even get the wxWidgets samples to compile using a

So I have been trying to get even just the damn samples for wxWidgets to compile with Mingw and I did like so mingw32-make -f makefile.gcc and I get the following error.
I do not have MSYS installed, and I have the latest version of Mingw
g++ -c -o gcc_mswud\minimal_minimal.o -g -O0 -mthreads -DHAVE_W32API_H -D__WXMS
W__ -D_UNICODE -I.\..\..\lib\gcc_lib\mswud -I.\..\..\include -W -Wall -I
. -I.\..\..\samples -DNOPCH -Wno-ctor-dtor-privacy -MTgcc_mswud\minimal_min
imal.o -MFgcc_mswud\minimal_minimal.o.d -MD -MP minimal.cpp
In file included from .\..\..\include/wx/defs.h:26:0,
from .\..\..\include/wx/wxprec.h:13,
from minimal.cpp:21:
.\..\..\include/wx/platform.h:256:22: fatal error: wx/setup.h: No such file or d
irectory
compilation terminated.
mingw32-make: *** [gcc_mswud\minimal_minimal.o] Error 1'
Any advice would be greatly appreciated
Also how exactly should I be compiling my own projects involving wxWidgets, what do I need to link against wxWidgets in mingw?
wx/setup.h is a file that is created during the compilation process; this file will be different for each different build type (Unicode, ANSI, Debug or Release, etc.). Most likely you compiled wxWidgets for one build type and are trying to compile the samples for a different build type.
As for the include / linker paths I have found the settings below to the bare minimum required to use wxWidgets in your own projects on Windows:
Include Paths
$(WXWIN)\include
$(WXWIN)\lib\vc_lib\mswud (u = Unicode and d=debug, this changes depending on what build type you want)
Pre-processor Definitions
WIN32
_DEBUG (only if you want to build with debugging info)
_WINDOWS
Character Set
"Use Unicode Character Set" (very important for Unicode builds; otherwise you will get compiler errors)
Additional Library Directories
$(WXWIN)\lib\vc_lib
Additional Dependencies
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
odbc32.lib
wxmsw28ud_core.lib
wxbase28ud.lib
wxexpatd.lib
wxjpegd.lib
wxpngd.lib
wxregexud.lib
wxtiffd.lib
wxzlibd.lib
wxmsw28ud_adv.lib
wxmsw28ud_aui.lib
wxmsw28ud_html.lib
wxWidgets libraries are post-fixed with "u" for Unicode and "d" for debug, you need to choose the libraries that match the build type you want. $(WXWIN) is the directory where you built wxWidgets (wxPack will create this environment variable for you to use).

compiling v8 on windows

When I am trying to compile like this
cl /Iinclude hello_world.cpp v8.lib
I get this error
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
and when I am trying to do it like this
cl /Iinclude v8.lib Winmm.lib WSock32.lib hello_world.cpp ws2_32.lib
I am getting this error
LINK : fatal error LNK1181: cannot open input file 'Winmm.lib'
how to fix this?
The compiler/linker can't find the Windows lib files. There are lots of ways to resolve this. For example, you can add the paths to the locations of the lib files to the LIB environment variable. Or you can pass the /LIBPATH option to the linker.
Finally, it doesn't look like you are compiling V8 here. It would appear that you are just trying to link to the V8 library that has already been compiled.