emcmake没有找到安装的软件包

发布于 2025-02-08 22:30:16 字数 4405 浏览 0 评论 0原文

我正在尝试编译一个简单的C ++程序,该程序将CGAL用于WASM。问题在于,出于某种原因,使用emsmake cmake, 失败,尽管使用cmake用于编译常规可执行文件时,它可以正常工作。我非常熟悉编译C ++并与Emscripten合作,因此这很可能是一个菜鸟问题。

运行EMCMAKE(通知CGAL警告):

cgal % emcmake cmake .
configure: cmake . -DCMAKE_TOOLCHAIN_FILE=/Users/kitty/Downloads/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/Users/kitty/Downloads/emsdk/node/14.18.2_64bit/bin/node;--experimental-wasm-threads
-- This project requires the CGAL library, and will not be compiled.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kitty/Projects/cgal

运行常规CMAKE(无警告):

cgal % cmake .        
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /usr/local/lib/cmake/CGAL/CGALConfig.cmake:92 (message):
  CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the
  default value of CGAL::data_file_path()
Call Stack (most recent call first):
  CMakeLists.txt:10 (find_package)


-- Using header-only CGAL
-- Targetting Unix Makefiles
-- Using /Library/Developer/CommandLineTools/usr/bin/c++ compiler.
-- DARWIN_VERSION=21
-- Mac Leopard detected
-- Found GMP: /usr/local/lib/libgmp.dylib  
-- Found MPFR: /usr/local/lib/libmpfr.dylib  
-- Found Boost: /usr/local/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.48")  
-- Boost include dirs: /usr/local/include
-- Boost libraries:    
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Boost: /usr/local/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found version "1.78.0")  
CMake Warning at /usr/local/lib/cmake/CGAL/CGAL_enable_end_of_configuration_hook.cmake:99 (message):
  =======================================================================

  CGAL performance notice:

  The variable CMAKE_BUILD_TYPE is set to "".  For performance reasons, you
  should set CMAKE_BUILD_TYPE to "Release".

  Set CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE to TRUE if you want to disable
  this warning.

  =======================================================================
Call Stack (most recent call first):
  CMakeLists.txt:9223372036854775807 (CGAL_run_at_the_end_of_configuration)


-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kitty/Projects/cgal

运行make之后会产生可执行文件的可执行文件。

cmakelists.txt(大部分使用cgal_create_cmakelists实用程序生成):

# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.

cmake_minimum_required(VERSION 3.1...3.15)

project( executable )


# CGAL and its components
find_package( CGAL QUIET COMPONENTS  )

if ( NOT CGAL_FOUND )

  message(STATUS "This project requires the CGAL library, and will not be compiled.")
  return()  

endif()


# Boost and its components
find_package( Boost REQUIRED )

if ( NOT Boost_FOUND )

  message(STATUS "This project requires the Boost library, and will not be compiled.")

  return()  

endif()

# include for local directory

# include for local package


# Creating entries for target: executable
# ############################

add_executable( executable  test.cpp )

add_to_cached_list( CGAL_EXECUTABLE_TARGETS executable )

# Link the executable to CGAL and third-party libraries
target_link_libraries(executable PRIVATE CGAL::CGAL )

# Lines below are commented for now as they are not required for minimal repro
#set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
#set_target_properties(executable PROPERTIES LINK_FLAGS "-s WASM=1 -s EXPORTED_FUNCTIONS='[_main]'")

test.cpp:

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}

I'm trying to compile a simple C++ program which uses CGAL to WASM. The problem is that for some reason find_package(CGAL) fails when using emsmake cmake, though it works fine when using cmake for compiling regular executables. I'm pretty new to compiling C++ and working with Emscripten, so this is most likely a noob question.

Running emcmake (notice CGAL warning):

cgal % emcmake cmake .
configure: cmake . -DCMAKE_TOOLCHAIN_FILE=/Users/kitty/Downloads/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/Users/kitty/Downloads/emsdk/node/14.18.2_64bit/bin/node;--experimental-wasm-threads
-- This project requires the CGAL library, and will not be compiled.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kitty/Projects/cgal

Running regular cmake (no warning):

cgal % cmake .        
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /usr/local/lib/cmake/CGAL/CGALConfig.cmake:92 (message):
  CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the
  default value of CGAL::data_file_path()
Call Stack (most recent call first):
  CMakeLists.txt:10 (find_package)


-- Using header-only CGAL
-- Targetting Unix Makefiles
-- Using /Library/Developer/CommandLineTools/usr/bin/c++ compiler.
-- DARWIN_VERSION=21
-- Mac Leopard detected
-- Found GMP: /usr/local/lib/libgmp.dylib  
-- Found MPFR: /usr/local/lib/libmpfr.dylib  
-- Found Boost: /usr/local/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.48")  
-- Boost include dirs: /usr/local/include
-- Boost libraries:    
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Boost: /usr/local/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found version "1.78.0")  
CMake Warning at /usr/local/lib/cmake/CGAL/CGAL_enable_end_of_configuration_hook.cmake:99 (message):
  =======================================================================

  CGAL performance notice:

  The variable CMAKE_BUILD_TYPE is set to "".  For performance reasons, you
  should set CMAKE_BUILD_TYPE to "Release".

  Set CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE to TRUE if you want to disable
  this warning.

  =======================================================================
Call Stack (most recent call first):
  CMakeLists.txt:9223372036854775807 (CGAL_run_at_the_end_of_configuration)


-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kitty/Projects/cgal

Running make afterwards produces a working executable.

CMakeLists.txt (for the most part generated using cgal_create_CMakeLists utility):

# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.

cmake_minimum_required(VERSION 3.1...3.15)

project( executable )


# CGAL and its components
find_package( CGAL QUIET COMPONENTS  )

if ( NOT CGAL_FOUND )

  message(STATUS "This project requires the CGAL library, and will not be compiled.")
  return()  

endif()


# Boost and its components
find_package( Boost REQUIRED )

if ( NOT Boost_FOUND )

  message(STATUS "This project requires the Boost library, and will not be compiled.")

  return()  

endif()

# include for local directory

# include for local package


# Creating entries for target: executable
# ############################

add_executable( executable  test.cpp )

add_to_cached_list( CGAL_EXECUTABLE_TARGETS executable )

# Link the executable to CGAL and third-party libraries
target_link_libraries(executable PRIVATE CGAL::CGAL )

# Lines below are commented for now as they are not required for minimal repro
#set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
#set_target_properties(executable PROPERTIES LINK_FLAGS "-s WASM=1 -s EXPORTED_FUNCTIONS='[_main]'")

test.cpp:

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹过旳痕迹 2025-02-15 22:30:16

为了emcmake cmake ..要找到为WASM构建该项目并将其安装到Emscripten Sysroot中的CGAL。 (通常是emscripten/cache/sysroot)。 /usr/lib或/usr/local/lib中的任何库很可能是主机库,因此与WASM或EMSCRIPTEN不兼容。

In order for emcmake cmake .. to find the CGAL you would need to build that project for wasm and install it into the emscripten sysroot. (normally emscripten/cache/sysroot). Any libraries in /usr/lib or /usr/local/lib are most likely host libraries and therefore not compatible with wasm or emscripten.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文