Skip to content

Commit e2ca949

Browse files
author
Hendrik Mennen
committed
Fix C++ linking: use builder extra-libs instead of configure string replacement
The previous approach tried to patch the configure script string which was fragile and didn't work on all platforms. Now uses the proper builder option mechanism (same pattern as iconv extension). Uses -lc++ on macOS (Clang) and -lstdc++ on Linux (GCC/musl).
1 parent 481319f commit e2ca949

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/SPC/builder/extension/glfw.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ public function patchBeforeBuildconf(): bool
2323
public function patchBeforeConfigure(): bool
2424
{
2525
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lglfw ', '-lglfw3 ');
26-
if (PHP_OS_FAMILY === 'Darwin') {
27-
// C++ standard library needed for ogt_vox_c_wrapper.cpp
28-
FileSystem::replaceFileStr(
29-
SOURCE_PATH . '/php-src/configure',
30-
'-framework IOKit',
31-
'-framework IOKit -lc++'
32-
);
33-
}
26+
27+
// ogt_vox_c_wrapper.cpp requires the C++ standard library
28+
$cxxLib = PHP_OS_FAMILY === 'Darwin' ? '-lc++' : '-lstdc++';
29+
$extraLibs = trim($this->builder->getOption('extra-libs', '') . ' ' . $cxxLib);
30+
$this->builder->setOption('extra-libs', $extraLibs);
31+
3432
return true;
3533
}
3634

0 commit comments

Comments
 (0)