microsoft / DirectXMesh

DirectXMesh geometry processing library
https://walbourn.github.io/directxmesh/
MIT License
787 stars 151 forks source link

Using on linux #73

Closed niyunsheng closed 2 years ago

niyunsheng commented 2 years ago

Thanks for your job. I want to know wow to use this tool on Linux system?

I think it is not possible to compile directly on Linux. When I do this, I will report an error

/usr/local/include/directxmath/DirectXMath. h: 150:10: fatal error: sal.h: no file or directory
#include "sal.h"
^~~~~~~
Compilation interrupted.

The file sal.h is only available on windows I think.

So I tring to use vcpkg tool. I installed it successfully, but it can't run.

CMakeLists.txt

cmake_minimum_required(VERSION 3.1.0) set(VCPKG_DIR /home/nys/libs/vcpkg) set(CMAKE_TOOLCHAIN_FILE ${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file") message("using vcpkg: " ${CMAKE_TOOLCHAIN_FILE}) project(vckpg_demo) set(directxmesh_DIR ${VCPKG_DIR}/installed/x64-linux/share/directxmesh/) find_package(directxmesh CONFIG REQUIRED) add_executable(${PROJECT_NAME} main.cpp) target_link_libraries(${PROJECT_NAME} Microsoft::DirectXMesh Microsoft::DirectXMesh::Utilities)

main.cpp

int main(){ return 0; }

when I using cmake .., I got the errror message:

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
using vcpkg: /home/nys/libs/vcpkg/scripts/buildsystems/vcpkg.cmake
CMake Warning (dev) at /home/nys/libs/vcpkg/installed/x64-linux/share/directxmesh/directxmesh-config.cmake:27 (if):
  Policy CMP0057 is not set: Support new IN_LIST if() operator.  Run "cmake
  --help-policy CMP0057" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  IN_LIST will be interpreted as an operator when the policy is set to NEW.
  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  CMakeLists.txt:11 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at /home/nys/libs/vcpkg/installed/x64-linux/share/directxmesh/directxmesh-config.cmake:27 (if):
  if given arguments:

    "(" "NOT" "directxmesh_FIND_COMPONENTS" ")" "OR" "(" "library" "IN_LIST" "directxmesh_FIND_COMPONENTS" ")"

  Unknown arguments specified
Call Stack (most recent call first):
  CMakeLists.txt:11 (find_package)

-- Configuring incomplete, errors occurred!
walbourn commented 2 years ago

As noted on the wiki, you can obtain an open source sal.h for Linux from GitHub, although with GCC there are some known include header issues you should be aware of.

Note the DirectXMath vcpkg port automatically downloads the sal.h header from that location for non-Win32 platforms.