Last active
July 13, 2021 16:54
-
-
Save eliemichel/54be942fec905611fc6840389496fd8e to your computer and use it in GitHub Desktop.
Linking issue with OpenVDB - Windows 10, Visual Studio 16 2019, static linking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set VCPKG_ROOT=G:\Libraries\vcpkg | |
set OPENVDB_ROOT=G:\SourceCode\openvdb | |
set MYTEST_ROOT=G:\SourceCode\MyTest | |
cd %VCPKG_ROOT% | |
vcpkg install zlib:x64-windows-static | |
vcpkg install blosc:x64-windows-static | |
vcpkg install tbb:x64-windows-static | |
vcpkg install boost-iostreams:x64-windows-static | |
vcpkg install boost-system:x64-windows-static | |
vcpkg install boost-any:x64-windows-static | |
vcpkg install boost-algorithm:x64-windows-static | |
vcpkg install boost-uuid:x64-windows-static | |
vcpkg install boost-interprocess:x64-windows-static | |
cd %OPENVDB_ROOT% | |
mkdir build | |
cd build | |
cmake .. ^ | |
-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake ^ | |
-DVCPKG_TARGET_TRIPLET=x64-windows-static ^ | |
-DOPENVDB_CORE_STATIC=ON ^ | |
-DOPENVDB_CORE_SHARED=OFF ^ | |
-DUSE_PKGCONFIG=OFF ^ | |
-DOPENVDB_BUILD_BINARIES=OFF ^ | |
-DCMAKE_INSTALL_PREFIX=install ^ | |
-A x64 | |
cmake --build . --parallel 4 --config Release --target install | |
cd %MYTEST_ROOT% | |
mkdir build | |
cd build | |
cmake .. ^ | |
-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake ^ | |
-DVCPKG_TARGET_TRIPLET=x64-windows-static ^ | |
-DOpenVDB_INSTALL_DIR=%OPENVDB_ROOT%\build\install ^ | |
-A x64 | |
cmake --build . --config Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.7..3.20) | |
project(MyTest LANGUAGES CXX) | |
set(OpenVDB_INSTALL_DIR "" CACHE STRING "Directory specified as CMAKE_INSTALL_PREFIX when building OpenVDB") | |
list(APPEND CMAKE_MODULE_PATH "${OpenVDB_INSTALL_DIR}/lib/cmake/OpenVDB") | |
set(OPENVDB_USE_STATIC_LIBS ON) | |
find_package(OpenVDB COMPONENTS openvdb REQUIRED) | |
add_executable(MyTest main.cpp) | |
target_link_libraries(MyTest LINK_PRIVATE OpenVDB::openvdb) | |
# Define OPENVDB_OPENEXR_STATICLIB as suggested by @ldclip | |
target_compile_definitions(MyTest PRIVATE OPENVDB_OPENEXR_STATICLIB) | |
# Make sure /MT is used to match the runtime library used by vcpkg builds. | |
if(MSVC) | |
target_compile_options( | |
MyTest PRIVATE | |
$<$<CONFIG:>:/MT> | |
$<$<CONFIG:Debug>:/MTd> | |
$<$<CONFIG:Release>:/MT> | |
) | |
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The "hello openvdb" from https://academysoftwarefoundation.github.io/openvdb/codeExamples.html#sHelloWorld | |
#include <openvdb/openvdb.h> | |
#include <iostream> | |
int main(int, char**) | |
{ | |
// Initialize the OpenVDB library. This must be called at least | |
// once per program and may safely be called multiple times. | |
openvdb::initialize(); | |
// Create an empty floating-point grid with background value 0. | |
openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create(); | |
std::cout << "Testing random access:" << std::endl; | |
// Get an accessor for coordinate-based access to voxels. | |
openvdb::FloatGrid::Accessor accessor = grid->getAccessor(); | |
// Define a coordinate with large signed indices. | |
openvdb::Coord xyz(1000, -200000000, 30000000); | |
// Set the voxel value at (1000, -200000000, 30000000) to 1. | |
accessor.setValue(xyz, 1.0); | |
// Verify that the voxel value at (1000, -200000000, 30000000) is 1. | |
std::cout << "Grid" << xyz << " = " << accessor.getValue(xyz) << std::endl; | |
// Reset the coordinates to those of a different voxel. | |
xyz.reset(1000, 200000000, -30000000); | |
// Verify that the voxel value at (1000, 200000000, -30000000) is | |
// the background value, 0. | |
std::cout << "Grid" << xyz << " = " << accessor.getValue(xyz) << std::endl; | |
// Set the voxel value at (1000, 200000000, -30000000) to 2. | |
accessor.setValue(xyz, 2.0); | |
// Set the voxels at the two extremes of the available coordinate space. | |
// For 32-bit signed coordinates these are (-2147483648, -2147483648, -2147483648) | |
// and (2147483647, 2147483647, 2147483647). | |
accessor.setValue(openvdb::Coord::min(), 3.0f); | |
accessor.setValue(openvdb::Coord::max(), 4.0f); | |
std::cout << "Testing sequential access:" << std::endl; | |
// Print all active ("on") voxels by means of an iterator. | |
for (openvdb::FloatGrid::ValueOnCIter iter = grid->cbeginValueOn(); iter; ++iter) { | |
std::cout << "Grid" << iter.getCoord() << " = " << *iter << std::endl; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework | |
Copyright (C) Microsoft Corporation. All rights reserved. | |
main.cpp | |
main.obj : error LNK2019: unresolved external symbol "private: static union openvdb::v8_1::math::internal::half::uif const * const openvdb::v8_1::math::internal::half::_toFloat" (?_toFloat@half@internal@math@v8_ | |
1@openvdb@@0QBTuif@12345@B) referenced in function "float __cdecl openvdb::v8_1::io::truncateRealToHalf<float>(float const &)" (??$truncateRealToHalf@M@io@v8_1@openvdb@@YAMAEBM@Z) [G:\SourceCode\MyTest\build\ | |
MyTest.vcxproj] | |
main.obj : error LNK2019: unresolved external symbol "private: static unsigned short const * const openvdb::v8_1::math::internal::half::_eLut" (?_eLut@half@internal@math@v8_1@openvdb@@0QBGB) referenced in functi | |
on "float __cdecl openvdb::v8_1::io::truncateRealToHalf<float>(float const &)" (??$truncateRealToHalf@M@io@v8_1@openvdb@@YAMAEBM@Z) [G:\SourceCode\MyTest\build\MyTest.vcxproj] | |
LIBCMT.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ) [G:\SourceCode\MyTest\build\MyTest. | |
vcxproj] | |
G:\SourceCode\MyTest\build\Release\MyTest.exe : fatal error LNK1120: 3 unresolved externals [G:\PhD\src\openvdb_test\build\MyTest.vcxproj] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment