-
-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
g++ module .o: No such file or directory #5261
Comments
try use add_rules("mode.release", "mode.debug")
set_languages("c++23")
-- Without the static library target, no errors occur
target("x-lib")
set_kind("moduleonly")
add_files("cpp/Math/**.mpp")
target("x-app")
set_kind("binary")
add_files("cpp/*.cpp")
add_deps("x-lib") |
Ok, for this minimal example project, it works. But for a bigger project that adds dependencies (libsdl, opengl, etc), everything compiles, but I got a lot of linker errors
And a lot of undefined references to SDL The target in the project:
Can C++20 modules be used to make a static library? I hope so
|
when only module files exsit, please use moduleonly. when both module/cpp or only cpp files exsit, please use static. https://github.com/xmake-io/xmake/blob/master/tests/projects/c%2B%2B/static_library/xmake.lua And I did not find |
I've tried to make a minimal version of my project file, here it is the complete code xmake.lua
Output is
And a lot more of link errors
cpp/apps/App1/app1.cpp
cpp/apps/App2/app2.cpp
cpp/my_lib/Math/Vector.mpp
Directory tree
|
please provide a whole project. and try disable lto. |
All the files should be listed in my previous post. And I have disabled LTO
Now the only thing the linker does not find is SDL functions
|
I need full projects and I don't have time to create them one by one. |
Sorry. What do you mean by full project? a zip file? a public repo? |
I think either would be fine, the idea is to be able to reproduce the bug in less than two minutes |
a zip file with your all project files, you can upload it as issue attachment |
I see, thank you. Here is the project |
It works for me on my fedora/gcc. $ xmake -rv
checking for flags (gcc_deps_format) ... ok
checking for flags (gcc_deps_file) ... ok
checking for flags (gcc_deps_output) ... ok
[ 0%]: <app1> generating.module.deps cpp/apps/App1/app1.cpp
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O2) ... ok
checking for flags (-std=c++23) ... ok
checking for flags (-D_GLIBCXX_USE_CXX11_ABI=0) ... ok
checking for flags (-DNDEBUG) ... ok
/usr/bin/gcc -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -E -x c++ cpp/apps/App1/app1.cpp -MT build/.gens/app1/linux/x86_64/release/rules/bmi/cache/modules/32ea7a34/app1.cpp.json -MD -MF build/.gens/app1/linux/x86_64/release/rules/bmi/cache/modules/32ea7a34/app1.cpp.d -fdeps-format=p1689r5 -fdeps-file=build/.gens/app1/linux/x86_64/release/rules/bmi/cache/modules/32ea7a34/app1.cpp.json -fdeps-target=build/.objs/app1/linux/x86_64/release/cpp/apps/App1/app1.cpp.o -o build/.gens/app1/linux/x86_64/release/rules/bmi/cache/modules/32ea7a34/app1.cpp.i
[ 0%]: <app1> generating.module.deps cpp/my_lib/Math/Vector.mpp
/usr/bin/gcc -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -E -x c++ cpp/my_lib/Math/Vector.mpp -MT build/.gens/app1/linux/x86_64/release/rules/bmi/cache/modules/69159ac3/Vector.mpp.json -MD -MF build/.gens/app1/linux/x86_64/release/rules/bmi/cache/modules/69159ac3/Vector.mpp.d -fdeps-format=p1689r5 -fdeps-file=build/.gens/app1/linux/x86_64/release/rules/bmi/cache/modules/69159ac3/Vector.mpp.json -fdeps-target=build/.objs/app1/linux/x86_64/release/cpp/my_lib/Math/Vector.mpp.o -o build/.gens/app1/linux/x86_64/release/rules/bmi/cache/modules/69159ac3/Vector.mpp.i
checking for flags (gcc_module_mapper) ... ok
[ 0%]: <my_lib> generating.module.deps cpp/my_lib/Math/Vector.mpp
/usr/bin/gcc -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -E -x c++ cpp/my_lib/Math/Vector.mpp -MT build/.gens/my_lib/linux/x86_64/release/rules/bmi/cache/modules/62063509/Vector.mpp.json -MD -MF build/.gens/my_lib/linux/x86_64/release/rules/bmi/cache/modules/62063509/Vector.mpp.d -fdeps-format=p1689r5 -fdeps-file=build/.gens/my_lib/linux/x86_64/release/rules/bmi/cache/modules/62063509/Vector.mpp.json -fdeps-target=build/.objs/my_lib/linux/x86_64/release/cpp/my_lib/Math/Vector.mpp.o -o build/.gens/my_lib/linux/x86_64/release/rules/bmi/cache/modules/62063509/Vector.mpp.i
[ 0%]: <app2> generating.module.deps cpp/apps/App2/app2.cpp
/usr/bin/gcc -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -E -x c++ cpp/apps/App2/app2.cpp -MT build/.gens/app2/linux/x86_64/release/rules/bmi/cache/modules/a2e5a9c2/app2.cpp.json -MD -MF build/.gens/app2/linux/x86_64/release/rules/bmi/cache/modules/a2e5a9c2/app2.cpp.d -fdeps-format=p1689r5 -fdeps-file=build/.gens/app2/linux/x86_64/release/rules/bmi/cache/modules/a2e5a9c2/app2.cpp.json -fdeps-target=build/.objs/app2/linux/x86_64/release/cpp/apps/App2/app2.cpp.o -o build/.gens/app2/linux/x86_64/release/rules/bmi/cache/modules/a2e5a9c2/app2.cpp.i
[ 0%]: <app2> generating.module.deps cpp/my_lib/Math/Vector.mpp
/usr/bin/gcc -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -E -x c++ cpp/my_lib/Math/Vector.mpp -MT build/.gens/app2/linux/x86_64/release/rules/bmi/cache/modules/b8076ef4/Vector.mpp.json -MD -MF build/.gens/app2/linux/x86_64/release/rules/bmi/cache/modules/b8076ef4/Vector.mpp.d -fdeps-format=p1689r5 -fdeps-file=build/.gens/app2/linux/x86_64/release/rules/bmi/cache/modules/b8076ef4/Vector.mpp.json -fdeps-target=build/.objs/app2/linux/x86_64/release/cpp/my_lib/Math/Vector.mpp.o -o build/.gens/app2/linux/x86_64/release/rules/bmi/cache/modules/b8076ef4/Vector.mpp.i
checking for the c compiler (cc) ... gcc
checking for flags (-O2) ... ok
checking for flags (-DNDEBUG) ... ok
[ 15%]: cache compiling.release cpp/third_party/glad/glad.c
/usr/bin/gcc -c -m64 -fvisibility=hidden -Wall -Wextra -O2 -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -DNDEBUG -o build/.objs/glad/linux/x86_64/release/cpp/third_party/glad/glad.c.o cpp/third_party/glad/glad.c
checking for flags (-MMD -MF) ... ok
checking for ar ... /usr/bin/ar
checking for the static library archiver (ar) ... ar
[ 20%]: archiving.release libglad.a
/usr/bin/ar -cr build/linux/x86_64/release/libglad.a build/.objs/glad/linux/x86_64/release/cpp/third_party/glad/glad.c.o
checking for the c++ compiler (cxx) ... gcc
[ 55%]: <app1> compiling.module.release Vector
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -fmodule-mapper=/tmp/.xmake995/240702/app1/cpp/my_lib/Math/Vector.mpp -x c++ -o build/.objs/app1/linux/x86_64/release/cpp/my_lib/Math/Vector.mpp.o cpp/my_lib/Math/Vector.mpp
[ 60%]: <app2> compiling.module.release Vector
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -fmodule-mapper=/tmp/.xmake995/240702/app2/cpp/my_lib/Math/Vector.mpp -x c++ -o build/.objs/app2/linux/x86_64/release/cpp/my_lib/Math/Vector.mpp.o cpp/my_lib/Math/Vector.mpp
checking for flags (-fdiagnostics-color=always) ... ok
[ 70%]: compiling.release cpp/apps/App1/app1.cpp
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -fmodule-mapper=/tmp/.xmake995/240702/app1/cpp/apps/App1/app1.cpp -o build/.objs/app1/linux/x86_64/release/cpp/apps/App1/app1.cpp.o cpp/apps/App1/app1.cpp
checking for flags (-MMD -MF) ... ok
[ 80%]: compiling.release cpp/apps/App2/app2.cpp
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O2 -std=c++23 -I/mnt/template_module_not_found/cpp -Icpp/third_party/glad -fexceptions -finput-charset=UTF-8 -fexec-charset=UTF-8 -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include -isystem /home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/include/SDL2 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -fmodule-mapper=/tmp/.xmake995/240702/app2/cpp/apps/App2/app2.cpp -o build/.objs/app2/linux/x86_64/release/cpp/apps/App2/app2.cpp.o cpp/apps/App2/app2.cpp
checking for the linker (ld) ... g++
[ 85%]: linking.release app2_linux_x86_64-release
/usr/bin/g++ -o build/linux/x86_64/release/app2_linux_x86_64-release build/.objs/app2/linux/x86_64/release/cpp/apps/App2/app2.cpp.o build/.objs/app2/linux/x86_64/release/cpp/my_lib/Math/Vector.mpp.o -m64 -L/home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/lib -Lbuild/linux/x86_64/release -s -lSDL2main -lSDL2 -lglad -lpthread -ldl
[ 95%]: linking.release app1_linux_x86_64-release
/usr/bin/g++ -o build/linux/x86_64/release/app1_linux_x86_64-release build/.objs/app1/linux/x86_64/release/cpp/apps/App1/app1.cpp.o build/.objs/app1/linux/x86_64/release/cpp/my_lib/Math/Vector.mpp.o -m64 -L/home/ruki/.xmake/packages/l/libsdl/2.30.4/4d6ee6e79e2743728490251a70ca0e42/lib -Lbuild/linux/x86_64/release -s -lSDL2main -lSDL2 -lglad -lpthread -ldl
[100%]: build ok, spent 24.113s |
try add_packages("libsdl", {public = true}) and add_requires("libsdl", {system = false})
|
It doesn't work either way
Using
|
my link logs:
your link logs:
libsdl link is missing. I'm not sure if you're setting |
Ok. I had the
But now xmake doesn' t run my apps. I can see the binaries are generated in the correct folders. File sizes look correct. Am I doing something wrong?
|
you can use lldb/gdb to debug it. xmake f -m debug
xmake
xmake run -d app1 |
Thank you. In my original project, everything is working now |
Xmake Version
xmake v2.9.2+20240525
Operating System Version and Architecture
Fedora 40 KDE x86_64
Describe Bug
If I just compile everything together, without making static library, it works fine. As soon as I put the C++20 module file into a static library target, I get the error
Expected Behavior
To compile?
Project Configuration
cpp/main.cpp
cpp/Math/Vector.mpp
Additional Information and Error Logs
The text was updated successfully, but these errors were encountered: