xmake-repo
xmake-repo copied to clipboard
Google filament, undefined reference to...
Xmake Version
v2.6.5+dev.34a0c28
Operating System Version and Architecture
Ubuntu 22.04 LTS
Describe Bug
Attempting to compile xmake project with google filament produce produces many undefined reference to...
Expected Behavior
Expect xmake to build the google filament package
Project Configuration
xmake.lua :
add_rules("mode.debug", "mode.release")
add_requires("filament")
target("test")
set_kind("binary")
add_files("main.cpp")
add_packages("filament")
add_links("filament")
main.cpp
#include <filament/Engine.h>
#include <filament/Camera.h>
#include <filament/Engine.h>
int main()
{
using namespace filament;
Engine* engine = Engine::create();
SwapChain* swapChain = engine->createSwapChain(nullptr); // I set nullptr just for the example
Renderer* renderer = engine->createRenderer();
}
Additional Information and Error Logs
https://github.com/google/filament/issues/2580
please make sure you are using clang instead of gcc. xmake f --toolchain=clang
I have rm .xmake and build then, xmake -f --toolchain=clang, and finally xmake, but I got the same errors xmake -vD
Could you please update your xmake version to 2.6.6 and try it again? I'm wondering where did the flag -lstdc++ come from. @waruqi It should be -lc++ and -lc++abi for clang
For -lstdc++ I have forgot to remove it from xmake.lua, I re-run xmake and I have the same output.
I have update xmake to 2.2.6, and I have the same output xmake -vD
Ok, I have fix some errors, in my xmake.lua I've added add_syslinks("c++")
But I've some error related to the math library I think ? https://github.com/google/filament/issues/2146
My clang version is 14, I tried with clang 11 but it gives me same errors.
Try to add add_syslinks("m")
add_cxflags("-ffast-math") or add_cxflags("-fno-builtin") may help
I have tried your solutions, it throw me the same errors.
xmake.lua
add_rules("mode.debug", "mode.release")
add_requires("filament")
target("test")
set_kind("binary")
add_syslinks("c++")
add_syslinks("m")
add_cxflags("-fno-builtin")
-- add_cxflags("-ffast-math")
set_languages("cxx17")
add_files("main.cpp")
add_packages("filament")
add_links("filament")
For add_cxflags("-ffast-math") and add_cxflags("-fno-builtin")
I tried both, then one, then the other, it throw me the same errors.
I also tried on a fresh docker container (ubuntu:22.04), then I ran these commands :
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
ln -s /bin/clang-14 /bin/clang
ln -s /bin/clang++-14 /bin/clang++
apt install libc++-14-dev
apt install libc++abi-14-dev
xmake
It throw me the same errors.
Why is here "-s" flag for the linker? Does it work without this flag? Currently I can't find any differences between the command line args and that recommended by filament except this flag.
The -s came from the add_rules("mode.release")`, I remove it and I got the same output. xmake -rvD
try add_syslinks("m") in your xmake.lua
I've already done that https://github.com/xmake-io/xmake-repo/issues/1239#issuecomment-1138340188
try add_requires("filament", {configs = {cxflags = "-fno-builtin"}}) ?
It doesn't work, same output :|
or you can try shared lib first?
add_requires("filament", {configs = {shared = true}})
Same output again.. xmake -rvD
I think the filament package should be improved and installed using source compilation. the linux precompiled packages use clang, so the user has to be required to use clang and libc++, and there are many compiler related compatibility issues.
I think the filament package should be improved and installed using source compilation. the linux precompiled packages use clang, so the user has to be required to use clang and libc++, and there are many compiler related compatibility issues.
oh, source tar.gz is too large.
I think the filament package should be improved and installed using source compilation. the linux precompiled packages use clang, so the user has to be required to use clang and libc++, and there are many compiler related compatibility issues.
filament itself depends on clang and libc++, it doesn't support gcc
Now google has updated filament ci to build the precompiled package on Ubuntu 22.04 https://github.com/google/filament/pull/6559, so the math function issue due to glibc compatibility is gone. On the other hand, although filament need to be built with clang, the filament package only depends on libc++, which means it is also feasible to use filament with gcc now. I think this issue can finally be resolved.
So, Can I close this issue now?