Skip to content

Linker error when using vcpkg with exceptions disabled #285

@jonathanharg

Description

@jonathanharg

Environment

toml++ version and/or commit hash:
3.4.0

Compiler:
Apple clang 17

C++ standard mode:
20

Target arch:
arm64

Library configuration overrides:
TOML_EXCEPTIONS=0

Describe the bug

When compiling with the latest vcpkg version (v3.4.0#1) of the library, I get a linker error defining TOML_EXCEPTIONS=0. The missing symbol is toml::v3::noex::parse_file(std::__1::basic_string_view<char, std::__1::char_traits<char>>). The CMake setup I included bellow works correctly when using FetchContent and also when downgrading to the v3.1.0 vcpgk port. I can link against versions of the library that include exceptions without issue with the latest vcpkg version.

Steps to reproduce (or a small repro code sample)

Minimum reproduction steps

cmake_minimum_required(VERSION 3.31)
project(tpp-repro)

add_executable(tpp-repro main.cpp)
target_compile_definitions(tpp-repro PUBLIC TOML_EXCEPTIONS=0)
find_package(tomlplusplus CONFIG REQUIRED)
target_link_libraries(tpp-repro PRIVATE tomlplusplus::tomlplusplus)
#include <toml++/toml.h>

int main() {
	const toml::parse_result fileRead = toml::parse_file("config.toml");
	return fileRead.failed();
}
[2/2] Linking CXX executable tpp-repro
FAILED: [code=1] tpp-repro 
: && /usr/bin/c++ -arch arm64 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/tpp-repro.dir/main.cpp.o -o tpp-repro  vcpkg_installed/arm64-osx/debug/lib/libtomlplusplus.a && :
Undefined symbols for architecture arm64:
  "toml::v3::noex::parse_file(std::__1::basic_string_view<char, std::__1::char_traits<char>>)", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Additional information

Regression since v3.1.0. Downgrading is a temporary workaround.

{
  "dependencies": [
    "tomlplusplus"
  ],
  "overrides": [
    {
      "name": "tomlplusplus",
      "version": "3.1.0",
      "port-version": 0
    }
  ]
}

I hope this is the correct place to log this bug, if not let me know and I'll leave something in microsoft/vcpkg

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions