Embedded pdfium in C++ application - c++

I'm currently trying to build a C++ application witch is able to convert PDF files to images.
I want to use pdfium to do this.
So I built pdfium as explain in the wiki and copied headers and generated libs in my cmake project.
When I try to build my application I get the following error:
src/include/pdfium-linux64/v8/include/libplatform/libplatform.h:8:33: fatal error: include/v8-platform.h: no such file or directory
In fact in this file there is:
#include "include/v8-platform.h"
But directories are like this:
include
| pdfium-linux64
| | v8
| | | include
| | | | libplatform
| | | | \ libplatform.h
| | | | v8-platform.h
| | | \ ...
| | \ ...
| \ ...
\ ...
So it could not work..
Does anyone have an idea of what to do to fix this issue?
Thanks in advance.

Thanks to pdfshaver project, I found a solution:
directly install pdfium through .deb package
add gcc option:
-I/usr/include/pdfium/v8
-L/usr/lib/pdfium
-lpthread
-lpdfium
-lfpdfapi
-lfxge
-lfdrm
-lfpdfdoc
-lfxcodec
-lfxcrt
-lfxedit
-lpdfwindow
-ljsapi
-lv8_libplatform
-lv8_snapshot
-lv8_base
-lv8_libbase
-licui18n
-licuuc
-licudata
-lformfiller
-lfpdftext
-lfpdfdoc
-lbigint
-ljavascript
-lpthread

Related

Compile C++ code with SDL2 file using Cmake

I'm trying to compile a c++ program with the SDL package using cmake but I have issues finding the SDL.h file when I compile it with the make command.
Currently the CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 17)
project(TestProject VERsion 1.0 DESCRIPTION "Game project" LANGUAGES CXX)
add_compile_options(-Wall -Wextra -pedantic -Werror)
add_library(Gamelib ${PROJECT_SOURCE_DIR}/Source/Game/game.cc)
target_include_directories(Gamelib PUBLIC ${PROJECT_SOURCE_DIR}/Source/include
${PROJECT_SOURCE_DIR}/SDL/include)
add_executable(main ${PROJECT_SOURCE_DIR}/Source/main.cc)
target_link_libraries(main Gamelib)
The project structure looks like this:
|--project
|
+-- CMakeLists.txt
|
+-- Source
| |
| +--Game
| | |
| | +-- game.cc
| |
| +--include
| | |
| | +--game.h
| |
| +-- main.cc
|
|
+--SDL
|
+--include
I also tried with using the find_package command but then I ended up with a linker error instead. Does anybody have an idea of how I can solve this?

Including SDL in program makes it have no output and instantly quit [duplicate]

This question already has answers here:
How to copy DLL files into the same folder as the executable using CMake?
(12 answers)
Program was not found .dll file
(1 answer)
Closed 2 years ago.
I'm trying to make a program with SDL2.0 but the program doesn't show any output and it quit instantly.
I am using Windows 10 x64 and I am doing this on VSCode, latest CMake version.
I actually tried amd64, amd64_x86, x86, x86_amd64 toolchains, same thing happens.
A normal hello world program worked well but when importing SDL.h it wouldn't do anything, no output and delays.
C++ Program (main.py):
#include "SDL.h"
#include <stdio.h>
int main( int argc, char* args[] )
{
printf("Hi\n");
SDL_Init(SDL_INIT_VIDEO);
SDL_Delay(5 * 1000);
SDL_Quit();
return 0;
}
When debugging the log stated that "MuserSDL.exe' has exited with code -1073741515 (0xc0000135)".
CMake file:
cmake_minimum_required(VERSION 3.0.0)
project(MuserSDL VERSION 0.1.0)
include(CTest)
enable_testing()
include_directories(sdl/include)
link_directories(sdl/lib/x64)
message(${PROJECT_SOURCE_DIR})
add_executable(MuserSDL src/main.cpp)
target_link_libraries(MuserSDL SDL2 SDL2main)
target_include_directories(MuserSDL PUBLIC sdl/include)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
The tree printed by tree /a /f (Reduced)
C:.
| .gitignore
| CMakeLists.txt
| LICENSE
| README.md
|
+---.vscode
| settings.json
|
+---build (...)
|
+---sdl
| | BUGS.txt
| | ...
| |
| +---docs (...)
| |
| +---include
| | begin_code.h
| | close_code.h
| | SDL.h
| | ...
| |
| \---lib
| +---x64
| | SDL2.dll
| | SDL2.lib
| | SDL2main.lib
| | SDL2test.lib
| |
| \---x86 (...)
|
\---src
main.cpp
Solution found here. I should copy the sdl libraries under the target executable directory.

How cmake handle include_directories() for a project with nested folder

The problem is solved, it is due to other dependency of my project, it has nothing wrong with cmake. Thanks for everyone trying to help in the question.
Here is my project tree Tree 1:
project
| + src
| | + other_src
| | | - abc.cpp
| | | - abc.h
| | - main.cpp
| - CMakeLists.txt
3rd_party
| + pcap
| | - pcap.h
| - pcap.h
Inside my CMakeLists.txt, I do:
include_directories("/path/to/3rd_party")
Inside my abc.cpp, I have:
#include "pcap.h"
Then I do cmake and make. I get error pcap.h: No such file or directory
I then change my project tree Tree 2:
project
| + src
| | - abc.cpp
| | - abc.h
| | - main.cpp
| - CMakeLists.txt
3rd_party
| + pcap
| | - pcap.h
| - pcap.h
Without modifying my CMakeLists.txt, I do cmake and make again. The header file is found.
How can I build this project while my source code is placed in different folders?

How to organize project using cmake and separated headers

I am currently starting a new project using C++ and CMake,
in my last project I organized the code the following:
src
|--foo
| |--bar.cpp
| |--bar.hpp
| |--CMakeLists.txt
|--baz
| |--anotherFoo
| | |--Bahama.cpp
| | |--Bahama.hpp
| | |--CMakeLists.txt
| |--baz.cpp
| |--baz.hpp
| |--CMakeLists.txt
|--CMakeLists.txt
so every subdirectory got its own CMakeLists.txt, which was included as library from other CMakeList files.
Now I want to separate the .hpp and the .cpp files.
Something like this:
src
|--foo
| |--bar.cpp
| |--CMakeLists.txt
|--baz
| |--anotherFoo
| | |--Bahama.cpp
| | |--CMakeLists.txt
| |--baz.cpp
| |--CMakeLists.txt
|--CMakeLists.txt
include
|--foo
| |--bar.hpp
| |--CMakeLists.txt
|--baz
| |--anotherFoo
| | |--Bahama.hpp
| | |--CMakeLists.txt
| |--baz.hpp
| |--CMakeLists.txt
|--CMakeLists.txt
What I am supposed to do with the CmakeLists files?
Do I also need a CMakeLists file in every subdirectory, like I did in my example above? Or is there another way to do this?
What do I write in this CMake files
In the future I also want to add documentation with doxygen, how can I enable Doxygen support via Cmake in a structure like this?
should also every subdirectory get its own?

QTest and .pro workflow

This is my (very simplified) directory tree :
C:.
| common.h
| QMelt.pro
|
+---src
| +---app
| | main.cpp
| | melt.cpp
| | melt.h
| |
| +---io
| | alsfilestreambase.h
| | alsfilesystem.cpp
| | alsfilesystem.h
|
\---test
+---io
| io_test.pro
| io_test.pro.user
|
\---src
alsfilesystemtest.cpp
alsfilesystemtest.h
What I'm trying to achieve is to configure io_test.pro - which is an unit test project (using QTest) - to be able to test the io namespace.
Here is my current io_test.pro :
QT += testlib
QT -= gui
TARGET = tst_io
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
#Test sources
SOURCES += src/alsfilesystemtest.cpp
HEADERS += src/alsfilesystemtest.h
#Testing sources
SOURCES += ../../src/io/alsfilesystem.cpp
HEADERS += ../../src/io/alsfilesystem.h
DEFINES += SRCDIR=\\\"$$PWD/src\\\"
INCLUDEPATH += $$PWD/../..
My problem is that I have linker errors at build time. These errors are on method using QMelt project (the project I want to test) dependecy, included by alsfilesystem.
So my question is what modifications should I bring to io_test.pro in order to use the .obj built by QMelt.pro ?