### Install Dependencies and Setup iOS Project Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-mobile-reactnative-cli/README.md Installs project dependencies using npm and sets up the native iOS project by installing CocoaPods. ```bash npm install cd ios pod install cd .. ``` -------------------------------- ### Start Metro Server Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-mobile-reactnative-cli/README.md Starts the Metro bundler, which is essential for running React Native applications. ```bash npm start ``` -------------------------------- ### Run Application on iOS Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-mobile-reactnative-cli/README.md Builds and launches the React Native application on an iOS simulator or device. ```bash npm run ios ``` -------------------------------- ### Navigate and Run Cpp.js App Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/create-a-project.md Commands to navigate into the newly created project directory, install project dependencies, and start the development server. This allows users to see their Cpp.js app running in real-time. ```shell cd npm install npm run dev ``` -------------------------------- ### Run Application on Android Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-mobile-reactnative-cli/README.md Builds and launches the React Native application on an Android emulator or device. ```bash npm run android ``` -------------------------------- ### Initialize a New Cpp.js Project Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-core-create-app/README.md Installs and executes `create-cpp.js` to scaffold a new Cpp.js project. It guides the user through prompts for project name, type, framework (e.g., React), and bundler (e.g., Vite). ```bash npm init cpp.js@latest ``` -------------------------------- ### Develop and Build Cpp.js Project Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-core-create-app/README.md Common commands to navigate into the newly created project directory, install dependencies, start the development server, and build the application for production. ```bash cd npm install npm run dev ``` ```bash npm run build ``` -------------------------------- ### Install @cpp.js/sample-lib-source Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-source/README.md Installs the @cpp.js/sample-lib-source package using npm. This is the initial step to integrate the library into your project. ```sh npm install @cpp.js/sample-lib-source ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/bugra9/cpp.js/blob/main/website/README.md Installs all necessary project dependencies using Yarn. This is the first step before running any other commands. ```shell $ yarn ``` -------------------------------- ### Install Homebrew Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/prerequisites.md Shell command to install Homebrew, a package manager for macOS. Homebrew is used to install Cocoapods. ```shell /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### C++ Header File Example Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/nodejs.md A simple C++ header file defining a class with a static method that returns a string. This serves as the native code to be compiled. ```cpp #pragma once #include class MySampleClass { public: static std::string sample() { return "Hello World!"; } }; ``` -------------------------------- ### CMake Project Setup and Variable Definitions Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-zlib/assets/CMakeLists.txt Initializes the CMake project, sets the minimum required version, defines project name and language, and sets version and installation directory variables. It also enables testing and includes various CMake modules for feature checks. ```cmake cmake_minimum_required(VERSION 2.4.4...3.15.0) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) project(zlib C) set(VERSION "1.3.1") option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON) set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") include(CheckTypeSize) include(CheckFunctionExists) include(CheckIncludeFile) include(CheckCSourceCompiles) enable_testing() ``` -------------------------------- ### Install @cpp.js/sample-lib-prebuilt-matrix Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-prebuilt-matrix/README.md Installs the matrix multiplier library using npm. This is the first step to integrate the library into your project. ```sh npm install @cpp.js/sample-lib-prebuilt-matrix ``` -------------------------------- ### Install @cpp.js/package-proj Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-proj/README.md Install the @cpp.js/package-proj package using npm. This is the initial step for integrating the library into your project. ```sh npm install @cpp.js/package-proj ``` -------------------------------- ### Install @cpp.js/package-webp Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-webp/README.md Installs the @cpp.js/package-webp package using npm. This is the initial step to integrate the webp library into your project. ```sh npm install @cpp.js/package-webp ``` -------------------------------- ### Header Inclusion and Installation Source: https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/assets/CMakeLists.txt This section finds header files using globbing, sets include directories for the target library, and installs the library and its headers. It uses `target_include_directories` for specifying include paths and `install` commands for deploying the library and header files. ```cmake file(GLOB_RECURSE HEADER_FILES ${HEADER_GLOB}) target_include_directories("${PROJECT_NAME}" PUBLIC "${HEADER_DIR}") install(TARGETS "${PROJECT_NAME}" DESTINATION "lib") if(NOT "${HEADER_FILES}" STREQUAL "") target_sources("${PROJECT_NAME}" PUBLIC FILE_SET HEADERS BASE_DIRS "${HEADER_DIR}" FILES "${HEADER_FILES}") install(TARGETS "${PROJECT_NAME}" FILE_SET HEADERS DESTINATION "include") endif() ``` -------------------------------- ### Install ZLIB libraries and headers Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-zlib/assets/CMakeLists.txt Installs the ZLIB shared or static library, its runtime and archive files, headers, man pages, and pkgconfig files. Installation is skipped if SKIP_INSTALL_LIBRARIES, SKIP_INSTALL_HEADERS, or SKIP_INSTALL_FILES are defined. ```cmake if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) if (BUILD_TYPE STREQUAL "SHARED") install(TARGETS zlib RUNTIME DESTINATION "${INSTALL_BIN_DIR}" ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) elseif(BUILD_TYPE STREQUAL "STATIC") install(TARGETS zlibstatic RUNTIME DESTINATION "${INSTALL_BIN_DIR}" ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) endif() endif() if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") endif() if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") endif() if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") endif() ``` -------------------------------- ### Build ZLIB example binaries Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-zlib/assets/CMakeLists.txt If ZLIB_BUILD_EXAMPLES is enabled, this section creates 'example' and 'minigzip' executables from C source files and links them against the ZLIB library. It also includes 64-bit versions if HAVE_OFF64_T is defined. ```cmake if(ZLIB_BUILD_EXAMPLES) add_executable(example test/example.c) target_link_libraries(example zlib) add_test(example example) add_executable(minigzip test/minigzip.c) target_link_libraries(minigzip zlib) if(HAVE_OFF64_T) add_executable(example64 test/example.c) target_link_libraries(example64 zlib) set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") add_test(example64 example64) add_executable(minigzip64 test/minigzip.c) target_link_libraries(minigzip64 zlib) set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") endif() endif() ``` -------------------------------- ### Install @cpp.js/sample-lib-cmake Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-cmake/README.md Install the @cpp.js/sample-lib-cmake package using npm. This is the initial step to integrate the library into your project. ```sh npm install @cpp.js/sample-lib-cmake ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-backend-nodejs-wasm/README.md Installs the necessary project dependencies using the pnpm package manager. This is a common first step for setting up Node.js projects. ```bash pnpm install ``` -------------------------------- ### Example Cpp.js Build Script (package.json) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cli/build.md This is a minimal example of a package.json file demonstrating how to configure a build script using Cpp.js. The 'build' script specifically targets WebAssembly as the platform. This allows for easy integration into CI/CD pipelines or local development workflows. ```json { "name": "cf-worker-example", "scripts": { "build": "cppjs build -p WebAssembly" } } ``` -------------------------------- ### Install @cpp.js/package-sqlite3 Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-sqlite3/README.md Install the @cpp.js/package-sqlite3 package using npm. This is the initial step to integrate the sqlite3 library into your project. ```sh npm install @cpp.js/package-sqlite3 ``` -------------------------------- ### Start Local Development Server Source: https://github.com/bugra9/cpp.js/blob/main/website/README.md Starts a local development server for live previewing changes. The server automatically reloads on code modifications. ```shell $ yarn start ``` -------------------------------- ### Install @cpp.js/package-iconv Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-iconv/README.md Installs the @cpp.js/package-iconv package using npm. This is the first step to integrate the iconv library into your project. ```sh npm install @cpp.js/package-iconv ``` -------------------------------- ### Check Docker Version Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/prerequisites.md Command to verify the installed Docker version. Ensure Docker is installed to manage development environments. ```shell docker --version ``` -------------------------------- ### Usage in C++ Code Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-iconv/README.md Demonstrates how to use the iconv library within C++ code by including the header and accessing the version. This example shows how to get the libiconv version. ```cpp #include std::string Native::sample() { return to_string(_LIBICONV_VERSION); } ``` -------------------------------- ### Install @cpp.js/plugin-metro Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-metro/README.md Installs the @cpp.js/plugin-metro package as a development dependency using various package managers. ```sh npm install @cpp.js/plugin-metro --save-dev ``` ```sh yarn add @cpp.js/plugin-metro --dev ``` ```sh pnpm add @cpp.js/plugin-metro --save-dev ``` ```sh bun add @cpp.js/plugin-metro --dev ``` -------------------------------- ### Install @cpp.js/package-geotiff Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-geotiff/README.md Installs the @cpp.js/package-geotiff package using npm. This is the initial step to integrate the GeoTIFF library into your project. ```sh npm install @cpp.js/package-geotiff ``` -------------------------------- ### Install @cpp.js/package-spatialite using npm Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-spatialite/README.md This command installs the @cpp.js/package-spatialite package from npm. This is the initial step to integrate the library into your project. ```sh npm install @cpp.js/package-spatialite ``` -------------------------------- ### Add Serve and Start Script to package.json Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/standalone.md This snippet shows how to add the `serve` package as a dev dependency and include a `start` script in `package.json` to run a local development server. ```json { "name": "myapp", "scripts": { "start": "serve", "build": "cppjs build -p WebAssembly", }, "devDependencies": { "serve": "^14.2.3", "cpp.js": "^1.0.0" } } ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-mobile-reactnative-expo/README.md Installs all necessary project dependencies using the npm package manager. This is a prerequisite for running the sample application. ```bash npm install ``` -------------------------------- ### Minimal Cpp.js Configuration Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/nodejs.md Sets up the basic configuration file (cppjs.config.mjs) for cpp.js, specifying output paths and configuration file location. ```javascript export default { paths: { config: import.meta.url, output: 'dist', }, }; ``` -------------------------------- ### Using Prebuilt C++ Packages with Cpp.js Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/introduction.md Shows how to utilize prebuilt packages with Cpp.js to enhance application build performance by avoiding recompilation. This example imports a specific package, '@cpp.js/package-gdal/gdal.h', and initializes the Cpp.js runtime. ```jsx import { initCppJs, Gdal } from '@cpp.js/package-gdal/gdal.h'; await initCppJs(); ``` -------------------------------- ### Importing Cpp.js Initialization Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/features/plugins.md Example of importing the Cpp.js initialization function from a dependency. ```javascript import { initCppJs } from 'gdal3.js/Gdal.h'; ``` -------------------------------- ### Install Cpp.js React Native Plugin (BUN) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-react-native/README.md Installs the @cpp.js/plugin-react-native package as a development dependency using bun. ```sh bun add @cpp.js/plugin-react-native --dev ``` -------------------------------- ### Install Cpp.js React Native iOS Helper (bun) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-react-native-ios-helper/README.md Installs the @cpp.js/plugin-react-native-ios-helper package as a development dependency using bun. ```shell bun add @cpp.js/plugin-react-native-ios-helper --dev ``` -------------------------------- ### Install @cpp.js/package-tiff Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-tiff/README.md Install the TIFF package using npm. This is the first step to integrating the library into your project. ```sh npm install @cpp.js/package-tiff ``` -------------------------------- ### Install @cpp.js/package-expat with npm Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-expat/README.md This command installs the @cpp.js/package-expat package using npm. It is the initial step for integrating the expat library into your project. ```sh npm install @cpp.js/package-expat ``` -------------------------------- ### Install @cpp.js/package-geos Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-geos/README.md Installs the @cpp.js/package-geos package using npm. This is the initial step for integrating the GEOS library into your project. ```sh npm install @cpp.js/package-geos ``` -------------------------------- ### Install Cpp.js Vite Plugin Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-vite/README.md Installs the @cpp.js/plugin-vite package as a development dependency using npm. ```shell npm install @cpp.js/plugin-vite --save-dev ``` -------------------------------- ### Run Node.js Script Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/nodejs.md Executes the Node.js script that consumes the WebAssembly module. ```shell node ./src/index.js ``` -------------------------------- ### Install @cpp.js/package-zlib via npm Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-zlib/README.md This command installs the @cpp.js/package-zlib package using npm. It's the first step to integrating the zlib library into your project. ```sh npm install @cpp.js/package-zlib ``` -------------------------------- ### Install Cpp.js React Native Plugin (NPM) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-react-native/README.md Installs the @cpp.js/plugin-react-native package as a development dependency using npm. ```sh npm install @cpp.js/plugin-react-native --save-dev ``` -------------------------------- ### Install Cpp.js React Native iOS Helper (npm) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-react-native-ios-helper/README.md Installs the @cpp.js/plugin-react-native-ios-helper package as a development dependency using npm. ```shell npm install @cpp.js/plugin-react-native-ios-helper --save-dev ``` -------------------------------- ### Install Cpp.js React Native Plugin (PNPM) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-react-native/README.md Installs the @cpp.js/plugin-react-native package as a development dependency using pnpm. ```sh pnpm add @cpp.js/plugin-react-native --save-dev ``` -------------------------------- ### Start Development Server Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-cloud-cloudflare-worker/Readme.md Launches a local development server for testing the Cloudflare Worker. This allows for rapid iteration and debugging during the development process. ```bash pnpm run dev ``` -------------------------------- ### Check Cocoapods Version Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/prerequisites.md Command to check the installed Cocoapods version. This is required for iOS development and is typically installed via Homebrew. ```shell pod --version ``` -------------------------------- ### Install Cpp.js React Native iOS Helper (pnpm) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-react-native-ios-helper/README.md Installs the @cpp.js/plugin-react-native-ios-helper package as a development dependency using pnpm. ```shell pnpm add @cpp.js/plugin-react-native-ios-helper --save-dev ``` -------------------------------- ### Install Cpp.js React Native Plugin (YARN) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-react-native/README.md Installs the @cpp.js/plugin-react-native package as a development dependency using yarn. ```sh yarn add @cpp.js/plugin-react-native --dev ``` -------------------------------- ### Create a new Cpp.js project using npm Source: https://github.com/bugra9/cpp.js/blob/main/README.md This command initializes a new Cpp.js project using npm. It scaffolds a minimal project structure, setting up the necessary files and configurations to start developing with Cpp.js. ```bash npm create cpp.js@latest ``` -------------------------------- ### Install React Native Packages Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/react-native.md Installs the necessary cpp.js packages for React Native integration using npm or yarn. ```npm npm install @cpp.js/plugin-react-native @cpp.js/plugin-react-native-ios-helper ``` ```yarn yarn add @cpp.js/plugin-react-native @cpp.js/plugin-react-native-ios-helper ``` -------------------------------- ### Install Cpp.js React Native iOS Helper (yarn) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-react-native-ios-helper/README.md Installs the @cpp.js/plugin-react-native-ios-helper package as a development dependency using yarn. ```shell yarn add @cpp.js/plugin-react-native-ios-helper --dev ``` -------------------------------- ### Install Webpack Plugins for Cpp.js Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/webpack.md Installs the necessary Webpack plugins and loaders for integrating cpp.js into your project. These are added as development dependencies. ```shell npm install @cpp.js/plugin-webpack @cpp.js/plugin-webpack-loader --save-dev ``` ```shell yarn add @cpp.js/plugin-webpack @cpp.js/plugin-webpack-loader --dev ``` -------------------------------- ### Install Cocoapods Packages for iOS Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/react-native.md Installs the necessary Cocoapods dependencies for the iOS version of the React Native application. ```shell cd ios pod install ``` -------------------------------- ### Matrix Multiplication in JavaScript (Node.js) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-prebuilt-matrix/README.md Provides an example of matrix multiplication in Node.js environments. It imports the Node.js specific build, initializes the library, and then executes the matrix multiplication. ```js import 'node_modules/@cpp.js/sample-lib-prebuilt-matrix/dist/cppjs-sample-lib-prebuilt-matrix.node.js'; initCppJs().then(({ Matrix }) => { const a = new Matrix(1210000, 1); const b = new Matrix(1210000, 2); const result = a.multiple(b); console.log(result.get(0)); }); ``` -------------------------------- ### C++ and JavaScript Class and Constructor Example Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cpp-bindings/classes.md Demonstrates the creation of a C++ class 'MyClass' with a constructor and member functions, and its usage in JavaScript. It shows how to initialize C++ classes and call static and instance member functions from JavaScript. ```cpp class MyClass { public: MyClass(int x) : x(x) {} int getX() { return x; } static int getVersion() { return 1; } private: int x; } ``` ```javascript import { initCppJs, MyClass } from './native/MyClass.h'; await initCppJs(); const version = MyClass.getVersion(); // static member function const myObject = new MyClass(9); // constructor const x = myObject.getX(); // member function console.log(`version: ${version}, x: ${x}`); // version: 1, x: 9 ``` -------------------------------- ### Install Cocoapods using Homebrew Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/prerequisites.md Command to install Cocoapods using Homebrew. Cocoapods is a dependency manager for Swift and Objective-C Cocoa projects, necessary for iOS development with Cpp.js. ```shell brew install cocoapods ``` -------------------------------- ### Run Node.js Script with ES Modules Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/nodejs.md Executes the Node.js script using ES Modules that consumes the WebAssembly module. ```shell node ./src/index.mjs ``` -------------------------------- ### Configure package.json for Cpp.js Build Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/nodejs.md Adds the build script and cpp.js dependency to your project's package.json for WebAssembly compilation. ```json { "name": "myapp", "scripts": { "build": "cppjs build -p WebAssembly" }, "devDependencies": { "cpp.js": "^1.0.0" } } ``` -------------------------------- ### Install @cpp.js/package-gdal using npm Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-gdal/README.md Install the GDAL package for your project using npm. This is the initial step for integrating the precompiled GDAL library. ```sh npm install @cpp.js/package-gdal ``` -------------------------------- ### C++ Header File Example Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/rollup.md An example of a C++ header file defining a class with a static method. This code will be compiled and made accessible via cpp.js. ```cpp #pragma once #include class MySampleClass { public: static std::string sample() { return "Hello World!"; } }; ``` -------------------------------- ### Cpp.js Minimal Paths Configuration (JavaScript) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/configuration/paths.md A basic example of how to define the Paths object in Cpp.js, including general settings and path configurations like config and base paths. This configuration is essential for setting up the project structure. ```javascript export default { general: { name: 'sampleName', }, paths: { config: import.meta.url, base: '../..', }, }; ``` -------------------------------- ### Install Cpp.js Webpack Dependencies Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-webpack/README.md Installs the necessary packages for integrating C++ code into a project using Webpack. This includes the main plugin and its loader. ```sh npm install @cpp.js/plugin-webpack @cpp.js/plugin-webpack-loader --save-dev ``` -------------------------------- ### Check Node.js Version Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/prerequisites.md Command to check the currently installed Node.js version. Node.js v18 or higher is required for Cpp.js development. ```shell node --version ``` -------------------------------- ### Install Cpp.js CRACO Packages Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/create-react-app.md Installs the necessary packages for integrating Cpp.js with Create React App using CRACO. This includes the core CRACO package and specific webpack plugins and loaders for Cpp.js. ```shell npm install @craco/craco @cpp.js/webpack-plugin @cpp.js/webpack-plugin-loader ``` -------------------------------- ### Check CMake Version Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/prerequisites.md Command to verify the installed CMake version. A minimum version of CMake 3.28 is required for mobile development with Cpp.js. ```shell cmake --version ``` -------------------------------- ### CMake Project Setup and Platform Configuration Source: https://github.com/bugra9/cpp.js/blob/main/packages/cpp.js/src/assets/CMakeLists.txt This snippet initializes a CMake project, sets the C++ standard, and configures the build environment based on the target system, particularly for iOS to determine the host architecture. It also includes options for building specific components like 'Bridge' and 'Source'. ```cmake cmake_minimum_required(VERSION 3.25) set(CMAKE_CXX_STANDARD 17) project("${PROJECT_NAME}") if (CMAKE_SYSTEM_NAME STREQUAL "iOS") if (CMAKE_OSX_SYSROOT MATCHES "/iPhoneOS.platform/") set(PACKAGE_HOST "iOS-iphoneos") elseif(CMAKE_OSX_SYSROOT MATCHES "/iPhoneSimulator.platform/") set(PACKAGE_HOST "iOS-iphonesimulator") else() set(PACKAGE_HOST "iOS-unknown") endif() else() set(PACKAGE_HOST "${CMAKE_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}") endif() option(BUILD_BRIDGE "Build Bridge" OFF) option(BUILD_SOURCE "Build Source" OFF) ``` -------------------------------- ### Get File List Information (JavaScript) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/javascript/filesystem.md Shows how to retrieve a list of files and their information (path and size) from a specified path within the virtual file system using Cpp.js's `getFileList` function. The output is then iterated to log details. ```javascript const files = Module.getFileList(); files.forEach((fileInfo) => { console.log(`file path: ${fileInfo.path}, file size: ${fileInfo.size}`); }); ``` -------------------------------- ### Monorepo Base Path Configuration (JavaScript) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/features/monorepo.md This JavaScript configuration example demonstrates how to set the 'base' path in a monorepo structure for Docker to correctly access files relative to the monorepo's root directory. ```javascript export default { paths: { config: import.meta.url, base: '../..', }, }; ``` -------------------------------- ### Import CMake Cpp.js Package (JavaScript) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/features/packages.md Provides an example of importing and initializing a Cpp.js package that includes a CMakeLists.txt file. This is beneficial for projects using CMake for build management. ```javascript import { initCppJs, SampleBasicCmake } from '@cpp.js/sample-lib-cmake/samplebasiccmake.h'; await initCppJs(); ``` -------------------------------- ### Install Cpp.js Rollup Plugin Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-rollup/README.md Installs the @cpp.js/plugin-rollup package as a development dependency using npm. This package is required for integrating C++ code with Rollup. ```sh npm install @cpp.js/plugin-rollup --save-dev ``` -------------------------------- ### Consume WebAssembly Module (ES Modules) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/nodejs.md Imports and initializes the compiled WebAssembly module in a Node.js script using ES Modules, then calls a C++ function. ```javascript import initCppJs from '../dist/myapp.node.js'; initCppJs().then(({ MySampleClass }) => { console.log(`Matrix multiplier with c++ => ${MySampleClass.sample()}`); }); ``` -------------------------------- ### Consume WebAssembly Module (CommonJS) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/nodejs.md Imports and initializes the compiled WebAssembly module in a Node.js script using CommonJS modules, then calls a C++ function. ```javascript const initCppJs = require('../dist/myapp.node.js'); initCppJs().then(({ MySampleClass }) => { console.log(`Response from c++ : ${MySampleClass.sample()}`); }); ``` -------------------------------- ### Install cpp.js React Native Packages Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/expo.md Installs the core cpp.js React Native plugin and the iOS helper package using npm or yarn. These packages are essential for enabling cpp.js functionality in a React Native environment. ```bash npm install @cpp.js/plugin-react-native @cpp.js/plugin-react-native-ios-helper ``` -------------------------------- ### Get WebP Decoder Version in C++ Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-webp/README.md Includes the webp/decode.h header and uses WebPGetDecoderVersion() to retrieve the webp decoder version in C++ code. This demonstrates basic integration with the webp library. ```cpp #include std::string Native::sample() { return std::to_string(WebPGetDecoderVersion()); } ``` -------------------------------- ### Use Sample Library in JavaScript Code Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-source/README.md Shows how to initialize and use the `SampleBasic.sample()` function from the sample library in JavaScript code. Requires importing the necessary components and awaiting initialization. ```javascript import { initCppJs, SampleBasic } from '@cpp.js/sample-lib-source/cppjs-lib-samplebasic/samplebasic.h'; await initCppJs(); console.log(SampleBasic.sample()); ``` -------------------------------- ### Build Cpp.js App for Production Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/create-a-project.md Generates a production-ready build of the Cpp.js application. The output is placed in the `./dist` directory, optimized for deployment. ```shell npm run build ``` -------------------------------- ### Use zlib version in C++ code Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-zlib/README.md This C++ code demonstrates how to include the zlib header and use the `zlibVersion()` function to get the zlib library version. This is useful for verifying the integration. ```diff +#include std::string Native::sample() { + return std::string(zlibVersion()); } ``` -------------------------------- ### Get WebP Decoder Version in C++ Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/package/package/cppjs-package-webp.md Include the webp/decode.h header and use WebPGetDecoderVersion() to retrieve the version of the WebP decoder library. This is useful for compatibility checks. ```cpp #include std::string Native::sample() { + return std::to_string(WebPGetDecoderVersion()); } ``` -------------------------------- ### Cpp.js Configuration with Dependencies Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/features/plugins.md A minimal Cpp.js configuration file demonstrating how to import dependencies and specify configuration paths. ```javascript import gdal3js from 'gdal3.js/cppjs.config.js'; export default { dependencies: [ gdal3js, ], paths: { config: import.meta.url, }, }; ``` -------------------------------- ### JavaScript Equivalents for C++ Primitive Types Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cpp-bindings/data-types.md Demonstrates the JavaScript representations for C++ primitive data types when using Cpp.js. These examples show how to call functions with different C++ types from JavaScript. ```javascript sample() sample(true) sample(9) sample(9) sample(9) sample(9) sample(9) sample(9) sample(9) sample(9n) sample(9n) sample(9.9) sample(9.9) sample(9n) sample(9n) sample('s') sample('s') ``` -------------------------------- ### C++ and JavaScript Inheritance Example Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cpp-bindings/classes.md Illustrates inheritance in C++ using a 'Shape' base class and a 'Rectangle' derived class, and how this structure is utilized in JavaScript to calculate the area. ```cpp class Shape { public: void setWidth(int w) { width = w; } void setHeight(int h) { height = h; } protected: int width; int height; }; // Derived class class Rectangle: public Shape { public: int getArea() { return (width * height); } }; ``` ```javascript const rectangle = new Rectangle(); rectangle.setWidth(5); rectangle.setHeight(7); console.log(`Total area: ${rectangle.getArea()}`); // Print the area of the object. ``` -------------------------------- ### Enable CRACO in package.json Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/integrate-into-existing-project/create-react-app.md Modifies the scripts section of the `package.json` file to use `craco` instead of `react-scripts` for starting, building, and testing the React application. This enables CRACO to manage the Webpack configuration. ```diff { "scripts": { - "start": "react-scripts start" + "start": "craco start" - "build": "react-scripts build" + "build": "craco build" - "test": "react-scripts test" + "test": "craco test" } } ``` -------------------------------- ### Custom C++ Vector Embind Bindings Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cpp-bindings/data-types.md Provides an example of how to register custom vector types in C++ using Embind for use with Cpp.js, necessary for unsupported types. ```cpp #pragma once %module mycustom %{ EMSCRIPTEN_BINDINGS(mycustom) { emscripten::register_vector("VectorAbc"); } %} %feature("shared_ptr"); %feature("polymorphic_shared_ptr"); ``` -------------------------------- ### Get sqlite3 library version in C++ Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-sqlite3/README.md Include the sqlite3 header and use the sqlite3_libversion() function to retrieve the version of the linked sqlite3 library. This demonstrates basic usage within C++ code. ```cpp #include std::string Native::sample() { return std::string(sqlite3_libversion()); } ``` -------------------------------- ### Run Docker Command with CMake Version Check Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cli/docker.md Executes a command within the Cpp.js Docker container to check the CMake version. This demonstrates how to run external commands after starting a Docker application. ```shell cppjs docker run -- cmake --version ``` ```bash cmake version 3.28.3 CMake suite maintained and supported by Kitware (kitware.com/cmake). ``` -------------------------------- ### C++ and JavaScript Interface (Abstract Class) Example Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cpp-bindings/classes.md Shows how to define an abstract class (interface) in C++ with a pure virtual function and implement it in JavaScript. This allows for defining a contract that derived classes must adhere to. ```cpp class Rectangle { public: // pure virtual function providing interface framework. virtual int getArea() = 0; void setWidth(int w) { width = w; } void setHeight(int h) { height = h; } int getWidth() { return width; } int getHeight() { return height; } protected: int width; int height; }; ``` ```javascript Rectangle.implement({ getArea: function() { return this.getWidth() * this.getHeight(); } }); const rectangle = new Rectangle(); rectangle.setWidth(5); rectangle.setHeight(7); console.log(`Total area: ${rectangle.getArea()}`); // Total area: 35 ``` -------------------------------- ### C++ and JavaScript Polymorphism Example Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cpp-bindings/classes.md Demonstrates polymorphism with a C++ 'Shape' base class and a 'Triangle' derived class, showcasing how a function can operate on different derived types. The JavaScript code then utilizes these classes. ```cpp class Shape { protected: int width, height; public: Shape( int a = 0, int b = 0){ width = a; height = b; } int area() { return width * height; } }; class Triangle: public Shape { public: Triangle( int a = 0, int b = 0) : Shape(a, b) { } int area () { return (width * height / 2); } }; int getShapeArea(std::shared_ptr shape) { return shape->area(); } ``` ```javascript const triangle = new Triangle(10, 5); const triangleArea = triangle.area(); const shapeArea = getShapeArea(triangle); console.log(`triangle area: ${triangleArea}`); // triangle area: 25 console.log(`shape area: ${shapeArea}`); // shape area: 50 ``` -------------------------------- ### Cpp.js CLI Usage and Commands Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cli/overview.md This snippet displays the general usage of the Cpp.js command-line interface, including available options and commands such as build, docker, config, and help. It outlines the primary functions of the tool for compiling C++ to WebAssembly and native platforms. ```bash Usage: cppjs [options] [command] Compile C++ files to WebAssembly and native platforms. Options: -V, --version output the version number -h, --help display help for command Commands: build [options] compile the project that was set up using Cpp.js docker manage docker config manage the Cpp.js configuration files help [command] display help for command ``` -------------------------------- ### Configure Cpp.js with Sample Library Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-source/README.md Adds the sample library to the Cpp.js configuration file (`cppjs.config.js`). This step enables the library's features for use within the Cpp.js project. ```javascript import sourceSample from '@cpp.js/sample-lib-source/cppjs.config.js'; export default { dependencies: [ sourceSample ] paths: { config: import.meta.url, }, }; ``` -------------------------------- ### Get File Bytes (JavaScript) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/javascript/filesystem.md Illustrates retrieving the byte content of a file from a specified path within the virtual file system using Cpp.js's `getFileBytes` function. The function returns the file content as a Uint8Array. ```javascript const filePath = '/virtual/test.json'; const fileBytes = Module.getFileBytes(filePath); ``` -------------------------------- ### Configure Craco for Cpp.js Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-plugin-webpack/README.md Sets up the Cpp.js Webpack plugin within a Craco configuration file (craco.config.js). It includes dynamic import for the plugin, loader configuration for .h files, and dev server middleware setup for serving C++ assets. ```javascript const fs = require('fs'); module.exports = async function () { const { default: CppjsWebpackPlugin } = await import('@cpp.js/plugin-webpack'); const cppjsWebpackPlugin = new CppjsWebpackPlugin(); const compiler = cppjsWebpackPlugin.getCompiler(); return { webpack: { plugins: { add: [cppjsWebpackPlugin], }, configure: (config) => { config.module.rules[1].oneOf = [ { test: /\.h$/, loader: '@cpp.js/plugin-webpack-loader', options: { compiler }, }, ...config.module.rules[1].oneOf, ]; return config; }, }, devServer: (devServerConfig) => { devServerConfig.watchFiles = compiler.config.paths.native; devServerConfig.onBeforeSetupMiddleware = (devServer) => { if (!devServer) { throw new Error('webpack-dev-server is not defined'); } devServer.app.get('/cpp.js', function (req, res) { res.sendFile(`${compiler.config.paths.temp}/${compiler.config.general.name}.browser.js`); }); devServer.app.get('/cpp.wasm', function (req, res) { res.send(fs.readFileSync(`${compiler.config.paths.temp}/${compiler.config.general.name}.wasm`)); }); }; return devServerConfig; }, }; }; ``` -------------------------------- ### Use Sample Library in C++ Code Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-source/README.md Demonstrates how to include and use the `SampleBasic::sample()` function from the sample library within C++ code. Requires including the appropriate header file. ```cpp #include std::string Native::sample() { return SampleBasic::sample(); } ``` -------------------------------- ### Minimal C++ to JavaScript Integration Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/introduction.md Demonstrates a basic integration of C++ code into a JavaScript application using Cpp.js. It involves initializing the Cpp.js runtime and calling a C++ function to retrieve a message. Requires importing a C++ header file. ```jsx import { initCppJs, getHelloWorldMessage } from './native/helloWorld.h'; await initCppJs(); console.log(getHelloWorldMessage()); ``` ```cpp std::string getHelloWorldMessage() { return 'Hello World!'; } ``` -------------------------------- ### Deploy Website (with SSH) Source: https://github.com/bugra9/cpp.js/blob/main/website/README.md Deploys the built website using SSH. This command is particularly useful for hosting on GitHub Pages, pushing to the 'gh-pages' branch. ```shell $ USE_SSH=true yarn deploy ``` -------------------------------- ### Deploy to Cloudflare Workers Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-cloud-cloudflare-worker/Readme.md Deploys the compiled WebAssembly code and worker logic to the Cloudflare Workers platform. This command handles the necessary steps for publishing the application. ```bash pnpm run deploy ``` -------------------------------- ### Download Cpp.js Docker Image Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/getting-started/prerequisites.md Command to pull the official Cpp.js Docker image. This image contains all necessary tools for Web and Android development. The image will also be downloaded automatically during the first build if not pulled manually. ```shell docker pull bugra9/cpp.js ``` -------------------------------- ### Cpp.js Build Command Usage (Bash) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cli/build.md This snippet shows the command-line usage for the 'cppjs build' command. It details the available options, such as specifying the target platform, and provides a brief description of the command's purpose. This command is used to compile C++ projects set up with Cpp.js. ```bash Usage: cppjs build [options] compile the project that was set up using Cpp.js Options: -p, --platform target platform (choices: "All", "WebAssembly", "Android", "iOS", default: "All") -h, --help display help for command ``` -------------------------------- ### Cpp.js CLI: View Configuration Keys (Shell) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cli/config.md Displays all available system configuration keys for Cpp.js, along with their descriptions, default values, and valid options. This command helps users understand what settings can be managed. ```shell cppjs config keys ``` ```bash Available system keys: ┌────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────────┬──────────────────────────────────────────────┐ │ (index) │ description │ default │ options │ ├────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────┼──────────────────────────────────────────────┤ │ XCODE_DEVELOPMENT_TEAM │ 'The unique identifier of the development team used for code signing and app distribution in Xcode.' │ '' │ │ │ RUNNER │ 'The execution environment for running the application.' │ 'DOCKER_RUN' │ [ 'DOCKER_RUN', 'DOCKER_EXEC', 'LOCAL' ] │ │ LOG_LEVEL │ 'The verbosity of log output.' │ 'INFO' │ [ 'DEBUG', 'INFO', 'WARN', 'ERROR' ] │ └────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────┴──────────────────────────────────────────────┘ ``` -------------------------------- ### Matrix Multiplication in JavaScript (Web with Plugin) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-prebuilt-matrix/README.md Shows how to perform matrix multiplication in JavaScript for web environments when using a plugin. It initializes the library, creates matrices, multiplies them, and logs the result. ```js import { initCppJs, Matrix } from '@cpp.js/sample-lib-prebuilt-matrix/Matrix.h'; await initCppJs(); const a = new Matrix(1210000, 1); const b = new Matrix(1210000, 2); const result = a.multiple(b); console.log(result.get(0)); ``` -------------------------------- ### Auto Mount Files from Input/Network (JavaScript) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/javascript/filesystem.md Demonstrates how to automatically mount files from HTML file inputs or directly from network requests using Cpp.js's `autoMountFiles` function. It handles single or multiple files and files obtained via the Fetch API. ```javascript function onFileChange({ target }) { const files = Module.autoMountFiles([target.file]); } ``` ```javascript function onFileChange({ target }) { const result = Module.autoMountFiles(target.files); } ``` ```javascript const fileData = await fetch('test/polygon.geojson'); const file = new File([await fileData.blob()], "polygon.geojson"); const result = Module.autoMountFiles([file]); ``` -------------------------------- ### Build Static Website Content Source: https://github.com/bugra9/cpp.js/blob/main/website/README.md Generates the static website files into the 'build' directory. These files can then be deployed to any static hosting service. ```shell $ yarn build ``` -------------------------------- ### Import Prebuilt Cpp.js Package (JavaScript) Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/guide/features/packages.md Demonstrates how to import and initialize a prebuilt Cpp.js package, such as the GDAL library. This package type allows for quick integration without compilation. ```javascript import { initCppJs, Gdal } from '@cpp.js/package-gdal/gdal.h'; await initCppJs(); ``` -------------------------------- ### Get GeoTIFF Version in C++ Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-geotiff/README.md Demonstrates how to include the GeoTIFF header and retrieve the libgeotiff version in C++ code. This allows checking the integrated library version. ```cpp #include std::string Native::sample() { return to_string(LIBGEOTIFF_VERSION); } ``` -------------------------------- ### Build Native Code to WebAssembly Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-backend-nodejs-wasm/README.md Compiles native C++ code into a WebAssembly module using the project's build scripts. This step is crucial for enabling C++ functionality within the Node.js environment through Cpp.js. ```bash pnpm run build ``` -------------------------------- ### Matrix Multiplication in JavaScript (Web without Plugin) Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-sample-lib-prebuilt-matrix/README.md Illustrates matrix multiplication in JavaScript for web browsers without a plugin. It imports the necessary file, initializes the library with a path, and then performs the multiplication. ```js import 'node_modules/@cpp.js/sample-lib-prebuilt-matrix/dist/cppjs-sample-lib-prebuilt-matrix.browser.js'; initCppJs({ path: 'node_modules/@cpp.js/sample-lib-prebuilt-matrix/dist' }).then(({ Matrix }) => { const a = new Matrix(1210000, 1); const b = new Matrix(1210000, 2); const result = a.multiple(b); console.log(result.get(0)); }); ``` -------------------------------- ### C++ Vector Declaration and Usage Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cpp-bindings/data-types.md Shows how to declare C++ std::vector types and define JavaScript functions to get and set these vectors. This requires Cpp.js bindings. ```cpp std::vector getMyVector(); void setMyVector(std::vector); ``` -------------------------------- ### Cpp.js Docker CLI Usage Source: https://github.com/bugra9/cpp.js/blob/main/website/docs/api/cli/docker.md Displays the overall usage and available commands for the Cpp.js Docker management CLI. This includes options for displaying help and various subcommands for managing Docker containers. ```bash Usage: cppjs docker [options] [command] manage docker Options: -h, --help display help for command Commands: run run docker application create create docker container start start docker container stop stop docker container delete delete docker container help [command] display help for command ``` -------------------------------- ### Get GEOS Version in C++ Source: https://github.com/bugra9/cpp.js/blob/main/packages/cppjs-package-geos/README.md Demonstrates how to retrieve the GEOS library version within C++ code using the GEOSversion() function. This requires including the geos_c.h header. ```cpp #include std::string Native::sample() { return std::string(GEOSversion()); } ```