I am using the library dynareadout in a project and when linking the final executable a lot of unresolved references pop up:
/home/johnny/.xmake/packages/d/dynareadout/0.3/58f01c40deca4fe98f318f76a4a49452/lib/libd3plot_cpp.a(d3plot.cpp.o): in function `dro::D3plot::D3plot(std::filesystem::__cxx11::path const&)':
d3plot.cpp:(.text+0xee): undefined reference to `d3plot_open'
/usr/bin/ld: d3plot.cpp:(.text+0x1db): undefined reference to `d3plot_close'
/usr/bin/ld: /home/johnny/.xmake/packages/d/dynareadout/0.3/58f01c40deca4fe98f318f76a4a49452/lib/libd3plot_cpp.a(d3plot.cpp.o): in function `dro::D3plot::~D3plot()':
d3plot.cpp:(.text+0x245): undefined reference to `d3plot_close'
/usr/bin/ld: /home/johnny/.xmake/packages/d/dynareadout/0.3/58f01c40deca4fe98f318f76a4a49452/lib/libd3plot_cpp.a(d3plot.cpp.o): in function `dro::D3plot::read_node_ids()':
d3plot.cpp:(.text+0x273): undefined reference to `d3plot_read_node_ids'
/usr/bin/ld: /home/johnny/.xmake/packages/d/dynareadout/0.3/58f01c40deca4fe98f318f76a4a49452/lib/libd3plot_cpp.a(d3plot.cpp.o): in function `dro::D3plot::read_solid_element_ids()':
d3plot.cpp:(.text+0x2e3): undefined reference to `d3plot_read_solid_element_ids'
...
This is because the order of the links is wrong:
-lbinout -ld3plot -ld3plot_cpp -lbinout_cpp
It should be:
-ld3plot_cpp -lbinout_cpp -lbinout -ld3plot
The cpp libraries should be before the other ones because they depend on them. If I build dynareadout directly you can see, when building the tests, that the order is correct:
You can also see that the order of the links is wrong when installing the library with xrepo install -v dynareadout during the test:
> checking for c++ links(d3plot, binout, binout_cpp, d3plot_cpp)
Expected Behavior
When a library gets installed using import("package.tools.xmake").install(package, configs) xmake should correctly determine which target depends on which and therefor correctly order the links.
Xmake Version
2.6.8
Operating System Version and Architecture
Garuda Linux
Describe Bug
I am using the library
dynareadout
in a project and when linking the final executable a lot of unresolved references pop up:This is because the order of the links is wrong:
It should be:
The
cpp
libraries should be before the other ones because they depend on them. If I builddynareadout
directly you can see, when building the tests, that the order is correct:You can also see that the order of the links is wrong when installing the library with
xrepo install -v dynareadout
during the test:Expected Behavior
When a library gets installed using
import("package.tools.xmake").install(package, configs)
xmake should correctly determine which target depends on which and therefor correctly order the links.Project Configuration
xmake.lua
:link_order.cpp
:Additional Information and Error Logs
No response