Skip to content
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

vcpkg include directories incorrect #75

Closed
shiiion opened this issue Jun 15, 2021 · 10 comments
Closed

vcpkg include directories incorrect #75

shiiion opened this issue Jun 15, 2021 · 10 comments
Assignees

Comments

@shiiion
Copy link

shiiion commented Jun 15, 2021

It seems that when installing using vcpkg, the headers expect that the include root is in the sail directory, but vcpkg places the includes under sail. To include something in your own project, you need

#include <sail/sail-c++/sail-c++.h>

but the sail headers includes other sail headers as

#include <sail-c++/...>

Am I missing something here? Was this project updated since it was set up for vcpkg that caused this?

@HappySeaFox HappySeaFox self-assigned this Jun 15, 2021
@HappySeaFox
Copy link
Owner

HappySeaFox commented Jun 15, 2021

Hi! Do you use CMake? With CMake, you get correct include paths. Sample standalone project:

CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

project(SAIL VERSION 1.0.0
             DESCRIPTION "sail-probe"
             LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(sail-probe sail-probe.cpp)

find_package(SailC++ REQUIRED)
target_link_libraries(sail-probe SAIL::sail-c++)

sail-probe.cpp

#include <sail-c++/sail-c++.h>

int main(int argc, char *argv[]) {

    sail::image_reader reader;
    sail::image image;

    SAIL_TRY(reader.probe(argv[1], &image));

    return 0;
}

Compilation

mkdir build
cd build
cmake -A x64 -DCMAKE_TOOLCHAIN_FILE=D:\projects\git.vcpkg.sail\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release

Running

>Release\sail-probe.exe "D:/images/png/xin-gray-1bit.png"
SAIL: [D] [io_file.c:177] Opening file 'D:/images/png/xin-gray-1bit.png' in 'rb' mode
SAIL: [D] [context_private.c:696] Allocated a new thread-local context 00000000004FFF40
SAIL: [I] [context_private.c:655] Version 0.9.0
SAIL: [D] [context_private.c:54] Add 'D:\projects\sail-test\build\Release' to the DLL search paths
SAIL: [D] [context_private.c:181] SAIL_MY_CODECS_PATH environment variable is not set. Not loading codecs from it
SAIL: [D] [context_private.c:364] Enumerated codecs:
SAIL: [D] [context_private.c:369] 1. BMP [Bitmap Picture] 1.1.2
SAIL: [D] [context_private.c:369] 2. GIF [Graphics Interchange Format] 1.3.1
SAIL: [D] [context_private.c:369] 3. JPEG [Joint Photographic Experts Group] 1.3.4.1
SAIL: [D] [context_private.c:369] 4. PNG [Portable Network Graphics] 1.1.3
SAIL: [D] [context_private.c:369] 5. TIFF [Tagged Image File Format] 1.0.1
SAIL: [D] [context_private.c:677] Initialized in 27 ms.
SAIL: [D] [codec_info.c:115] Read magic number: '89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52'
SAIL: [D] [codec_info.c:126] Found codec info: 'PNG'
SAIL: [D] [helpers.c:330] PNG: Found ICC profile 'Dot Gain 20%' 912 bytes long
SAIL: [D] [palette-c++.cpp:129] NULL pointer has been passed to sail::palette(). The object is untouched

@HappySeaFox
Copy link
Owner

Please re-open in case of any issues.

@AlexMollard
Copy link

I am still having this issue and am trying not to use CMake, has this been fixed for Visual Studio 2022?

1>C:\vcpkg\installed\x64-windows-static\include\sail\sail\sail_junior.h(33,14): fatal  error C1083: Cannot open include file: 'sail-common/error.h': No such file or directory

It is the same wether I use x86, x64 or x64-static.

@HappySeaFox
Copy link
Owner

@AlexMollard Do you use the MSVS vcpkg integration?

@AlexMollard
Copy link

Yeah, I am currently using a few other libraries without issue.

@HappySeaFox
Copy link
Owner

As a temporary workaround, try adding VcpkgInstalledDir/include/sail to the project include path. See https://vcpkg.readthedocs.io/en/latest/users/buildsystems/msbuild-integration

@AlexMollard
Copy link

AlexMollard commented Dec 16, 2022

Tried your suggestion but still am having trouble, All files are being linked now but can't seem to figure out why SailPixelFormat is unknown.

> In file included from C:\vcpkg\installed\x64-windows\include\sail/sail-c++/image-c++.h:38:
> C:\vcpkg\installed\x64-windows\include\sail/sail-c++/palette-c++.h(65,13): error : unknown type name 'SailPixelFormat'

Also just tried in CMake with the same error this is my current CMake:

cmake_minimum_required(VERSION 3.10)

set(CMAKE_TOOLCHAIN_FILE "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")

project(UIEngine VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

## Blob all the source files into a variable
file(GLOB_RECURSE UIEngine_SRC
    "Engine/*.h"
    "Engine/*.hpp"
    "Engine/*.c"
    "Engine/*.cpp"
    "Game/*.h"
    "Game/*.hpp"
    "Game/*.c"
    "Game/*.cpp"
    "Components/*.h"
    "Components/*.hpp"
    "Components/*.c"
    "Components/*.cpp"
)

## Create the executable
add_executable(UIEngine ${UIEngine_SRC})

target_include_directories(UIEngine PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/Engine
    ${CMAKE_CURRENT_SOURCE_DIR}/Game
    ${CMAKE_CURRENT_SOURCE_DIR}/Components
)

## Link the libraries

#Sail
find_package(SailC++ REQUIRED)
target_link_libraries(UIEngine SAIL::sail-c++)

#glm
find_package(glm CONFIG REQUIRED)
target_link_libraries(UIEngine glm::glm)

#glfw
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(UIEngine glfw)

#glew
find_package(GLEW CONFIG REQUIRED)
target_link_libraries(UIEngine GLEW::GLEW)

#flecs
find_package(flecs CONFIG REQUIRED)
target_link_libraries(UIEngine flecs::flecs)

#free type
find_package(freetype CONFIG REQUIRED)
target_link_libraries(UIEngine freetype)

@HappySeaFox
Copy link
Owner

Oh, I see. I didn't notice this error before as I use universal sail headers. I think you can try the following potential fixes:

  1. Use universal includes: #include <sail-c++/sail-c++.h>. They already include sail-common/common.h with the necessary definition
  2. Or, include sail-common/common.h before including any sail cpp headers.

@HappySeaFox
Copy link
Owner

HappySeaFox commented Dec 16, 2022

There may be more errors like take. I've just pushed several fixes.

Until the fixes reach vcpkg, using universal includes is recommended.

For C++: #include <sail-c++/sail-c++.h>
For C: #include <sail/sail.h>

@HappySeaFox
Copy link
Owner

SAIL-RC2 with the missing includes fix has been merged into vcpkg. Please update the local copy of vcpkg and install rc2. Adding VcpkgInstalledDir/include/sail to the project include path is still required if you don't use cmake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants