#Error `symbol multiply defined`

4 messages · Page 1 of 1 (latest)

hexed jolt
#

I have two contracts A and B, where B depends on A, and both of them have a function called initialize. When I run soroban contract build, I get the following error saying:

warning: Linking globals named 'initialize': symbol multiply defined!

error: failed to load bitcode of module "huma_config.huma_config.aa1236b3409665e3-cgu.0.rcgu.o":

If I rename one of the initialize function to something else then the error goes away. I'm not sure that's the right solution since the Token contract, which B depends on, also has a function called initialize and it works just fine. What's the cause of this error and what's the proper fix?

Thanks!

amber prism
#

it seems like both are being linked into the same library. you should only be building a single contractimpl normally, but here it seems like you're building two contractcs into one Wasm

hexed jolt
#

Got it. It's because I put the A's interface declaration into the same package as the implementation and imported both into B. Separating the interface out into its own package solved the problem. Thanks!

sharp talon
#

Yup separating the implementation and interface is the way to go with this one.