Link Scaleform to build applications in Qt Creator - linker

I want to create an application and use Scaleform in it. I use Qt Creator so I added Scaleform's includes and libs in the .pro but I have errors at compilation.
Here is what I added in the .pro (some lines may not be useful but it was only to test as it doesn't work without anyway) :
INCLUDEPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Src"
INCLUDEPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Src/GFx"
INCLUDEPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Src/Kernel"
INCLUDEPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Src/Render"
INCLUDEPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Include"
DEPENDPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Src"
DEPENDPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Src/GFx"
DEPENDPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Src/Kernel"
DEPENDPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Src/Render"
DEPENDPATH += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Include"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfx.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfx_air.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfx_as2.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfx_as3.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/3rdParty/pcre/Lib/Win32/Msvc14/Debug/pcre.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/3rdParty/curl-7.29.0/lib/Win32/Msvc14/Debug/libcurl.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfxexpat.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfxplatform_d3d9.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfxplatform_d3d11.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfxplatform_gl.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfxrender_d3d9.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfxrender_d3d11.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfxrender_gl.lib"
LIBS += "C:/Program Files (x86)/Autodesk/Scaleform/GFx SDK 4.5/Lib/Win32/Msvc14/Debug/libgfxsound_fmod.lib"
In my .cpp file:
#include "GFx_Kernel.h"
#include "GFx.h" //causes the errors
#include "GFx_Renderer_D3D9.h"
This results in the following errors :
libgfx.lib(Amp_Message.obj) : error LNK2019: unresolved external symbol _deflate referenced in function "public: virtual bool __thiscall Scaleform::GFx::AMP::Message::Compress(class Scaleform::Array<unsigned char,2,struct Scaleform::ArrayDefaultPolicy> &)const " (?Compress#Message#AMP#GFx#Scaleform##UBE_NAAV?$Array#E$01UArrayDefaultPolicy#Scaleform###4##Z)
...
...
fatal error LNK1120: 54 unresolved externals
Usually, it's due to a missing lib or a lib which is not compiled with the same compiler as the application, but here, all is built in MSVC2015, 32 bits.
However, the libgfx.lib I have is dated on the 07.09.2016 and I didn't built it from Scaleform SDK since there is apparently no project to build it (whereas it's possible to rebuilt other libs like libgfxexpat.lib).
I think the problem may be due to that. Am I wrong? And is there any project in Scaleform SDK (I installed sf_4.5.32_win_vc14_lib.exe) to build that lib?

_deflate comes from zlib, be sure you're linking it into your application. Your output claims 54 unresolved symbols - I'm going to assume it's because you haven't linked in any of Scaleform's other dependencies also.
Scaleform distributions come in a few different flavors - the 'lib' versions do not give you source code, and thus, you cannot recompile their libraries. This is useful if you want to change the compilation options, make modifications, or debug it, but otherwise you should be able to make a fully functional application with the 'lib' libraries.

Related

How to add a custom library (e.g. glew) to mingw-w64?

I'm using windows and my goal is to add the glew library (http://glew.sourceforge.net/index.html) to mingw. I have downloaded mingw-w64 via GitHub (https://github.com/mstorsjo/llvm-mingw/releases/tag/20210423). It comes with a "bin", "lib" and "include" folder. Within the "bin" folder I do "make" to execute my project's makefile which inlcudes the line
LDLIBS=-lm -lGL -lGLEW -lglfw
I have copied "glew32.lib" to "mingw/lib", "GL/glew.h" and "GL/wglew.h" to "mingw/include/GL" and "bin/glew32.dll" to "mingw/bin".
In my source code i have included the header file with
#include <GL/glew.h>
When i do "make" i get an error on that line:
GL/glew.h: No such file or directory
How do you add custom libraries like glew to mingw?
When using a library use the -I compiler flag to tell the compiler where to find the include files (in your case the path containing the GL folder) and the -L linker flag to tell the linker where to find the libraries.
To link with the library use the -l flag. The library itself is a a lib*.a file (or lib*.dll.a for shared libraries). For the -l flag the library is specified without prefix and suffix, so if your library is called libglew.a the flag will be -lglew.
It is also possible to specified the full path to the lib*.a file instead of -L and -l flags, and with MinGW, if you have the .dll file you can even try to specify the path of the .dll file and the linker will know what to do.

sub-directory dependencies in CMake

I am working on a chip8 emulator in C and I am using CMake to handle the compilation and linking of libraries in my project.
my working directory looks like this
build >
cmake >
FindSDL2.cmake
library >
SDL2
bin >
include >
lib >
share >
src >
Chip8 >
Chip8.c
Disassembler >
Disassembler.c
Display >
Display.c
main.c
CMakeLists.txt
this is my CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(chip_8 VERSION 0.1.0)
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/library/SDL2/)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
find_package(SDL2 REQUIRED)
add_executable(chip_8 ${CMAKE_SOURCE_DIR}/src/main.c)
target_include_directories(chip_8 PUBLIC ${SDL2_INCLUDE_DIR})
target_link_libraries(chip_8 ${SDL2_LIBRARY})
My display.c requires the SDL2 library. While I could just put all the executables in the add_executable, but that would mean I would also get to include SDL.h in all of the c files, which I don't want I only want to include in the display.h. The above CMakeLists.txt was made when I wanted to add the SDL2 library locally in the project directory, instead of it sitting in the system files of mingw (the bin, include and lib folders of mingw).
How do I change the structure of my project or the CMakeLists.txt so that I can include SDL2 in the display.c in the Display sub-directory

Eclipse with cmake4eclipse: Editor does not recognize symbols defined in CMakeLists.txt

Windows 10 Version 1809
Eclipse IDE for C/C++ Developers (Version: 2019-06 (4.12.0))
cmake4eclipse 2.1.1
cmake version 3.17.0
GNU Make 4.2.1
repository for a simple example project: https://bitbucket.org/ChristianW/cmake_driven_example_arm-none-eabi-gcc/src/master/
When using the arm-none-eabi-gcc compiler, the Eclipse C/C++ Editor does not recognize my symbols set in the CMakeLists.txt.
...
if(1)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
else()
set(CMAKE_C_COMPILER gcc)
endif()
...
When using the gcc compiler, the Eclipse C/C++ Editor does recognize my symbols set in the CMakeLists.txt.
...
if(0)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
else()
set(CMAKE_C_COMPILER gcc)
endif()
...
In both cases building the project is working.
Any ideas what's the problem here?
Kind regards,
Christian
Edit: content of CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
#set(CMAKE_MAKE_PROGRAM "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe")
set(CMAKE_MAKE_PROGRAM "C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/mingw32-make.exe")
#set(CMAKE_MAKE_PROGRAM "C:/Tools/ON Semiconductor/RSL10_IDE_3_3/IDE_V3.2.2.13/arm_tools/bin/make.exe")
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_C_OBJCOPY arm-none-eabi-objcopy)
if(1)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
else()
set(CMAKE_C_COMPILER gcc)
endif()
project(cmake_driven_example_arm-none-eabi-gcc C)
set(SOURCES
main.c
modules/math/math.c
)
include_directories(
modules/math
)
set(CMAKE_C_FLAGS "-DINCLUDE_MATH")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMYVAR=5")
# Invoking: Cross ARM C Linker
set(CMAKE_EXE_LINKER_FLAGS "-Xlinker --gc-sections")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T\"${CMAKE_SOURCE_DIR}/sdk_packages/rsl10_sdk/source/firmware/cmsis/source/GCC/sections_modified.ld\"")
# build elf file
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/sdk_packages/rsl10_sdk/lib/ble_core/Release/libblelib.a
${CMAKE_SOURCE_DIR}/sdk_packages/rsl10_sdk/lib/ble_core/Release/libkelib.a
)
related cmake4eclipse topic
The indexer was set to "Use a fixed build configuration".
That's why I could build in different configurations, but the Editor always showed the flag values of my specified configuration (=Debug).
It should be possible to use project specific (PS) indexer settings, but...
There is a bug within Eclipse which leads to an unintuitive behaviour of the indexer (see bug205299):
WS: Window > Preferences > C/C++ > Indexer > Build configuration for the indexer: Use the build configuration specified in the projects's indexer settings
PS: Project Properties > C/C++ General > Indexer > User active build configuration
Solution: Use workspace specific (WS) indexer settings: Use active build configuration
Maybe there was also a problem caused by the path to the compiler:
"...\IDE_V3.2.2.13\arm_tools\bin\arm-none-eabi-gcc.exe"
-> dots in the folder name IDE_V3.2.2.13
It gave me these warnings: (fyi: in the sample project I have not defined the entry symbol Reset_Handler)
With moving arm_tools folder, the Eclipse Editor recognized the symbols.

How to configure Visual Studio Code includePath for Arduino and Teensy

I'm working with Arduino and Teensy boards from inside VS code. I can build and program everything fine, but the highlighting and code following functions built into VS Code don't work.
Previously, my custom headers weren't loading or highlighting, but this answer got that working for me. Now I have the right libraries on my include path (and I can click and follow them to the correct source) but some names still don't work:
My includePath appears to be configured correctly, as I mentioned I can follow the includes and it opens the correct sources:
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files (x86)/Arduino/**",
"C:/Program Files (x86)/Arduino/hardware/teensy/avr/cores/teensy/**",
"C:/Program Files (x86)/Arduino/hardware/teensy/avr/libraries/ADC/**",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/**",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/variants/standard/**",
"C:/Program Files (x86)/Arduino/hardware/tools/avr/lib/gcc/avr/5.4.0/include/**"
]
I can confirm the header is on the includePath and has the names defined I'm looking for:
Somehow VS Code is still saying the identifier is undefined.
Any ideas?
Just install the Arduino extension and run vscode command Arduino: initialize. You will need to select board and
File .vscode\c_cpp_properties.json and .vscode\arduino.json will automatically created.

How to compile the LIBVLC example code on windows using gcc

I want to build the libvlc example (https://wiki.videolan.org/LibVLC_Tutorial) so i downloaded the sources and also copied libvlc.dll and libvlccore.dll (from my vlc installation) into the current directory. Then i try to compile it by issuing
gcc example.c -o example -I./include -L./lib -L./ -llibvlc
but get the error
example.c:3:22: fatal error: vlc/vlc.h: No such file or directory
#include <vlc/vlc.h>
^
I hope this is enough information, i controlled all paths and files twice. Thank you in advance.
you need vlc sdk, not just files from vlc source code ;
you need dll files for your already compiled application, but for build you need .lib files - also part of sdk;
for this you need to build them - for this step refer to https://medium.com/#tobias.strg/compiling-vlc-3-x-in-2020-a390c6a73c24;
no doubt you can use some nigthly builds of vlc (check for zip files with "debug" suffix) https://artifacts.videolan.org/vlc-3.0/nightly-win64/20220420-0220;
after you got sdk pack for your platform you can compile - pointing to headers files from sdk, and linking with libs from sdk;

Resources