[SOLVED] Multiple defined symbol form an obj file lazarus / 62-General ---------------------------------------------------------------------- Okoba · 2021-08-16 06:25 Is there a way to find out a symbol is already defined, so I can prevent redefining it so the compiler don't give error like this? QuoteError: Multiple defined symbol "XXXXX" ---------------------------------------------------------------------- PascalDragon · 2021-08-16 06:55 Would you please describe your problem more clearly? From the cut of title of the thread and the error message I assume that you're trying to link some object file and you get errors when linking it, but that's not really clear. So please, provide more information. ---------------------------------------------------------------------- Okoba · 2021-08-16 07:04 Sure. I have an object file that I like to use in two units in two separate packages, Pkg1Unit and Pkg2Unit, both like to have that object and link it. The problem is that if I use both of these packages in a project, FPC gives the error that I am trying too link a symbol multiple times. I can make a third package that use this object and those two packages use this, but it complicated things and I have no control on one of the packages to change the code. So I am looking for a way to find out if this symbol is defined or this object is linked, the I can prevent linking again or redefining it in my code. I can change the source of pakcages but as I said, I have not much control on their source and I like to know if there is way for this particular problem without change in the dependency package. I renamed the topic but it only renames the first post. ---------------------------------------------------------------------- PascalDragon · 2021-08-16 07:16 Is your object file in the same location relative to the two packages or does each package have its own copy? If the later then that simply won't work and your only solution is what you had suggested with a third unit/package. If the former I think the linker should catch that both files are the same and thus not complain, but I can't say that for sure. ---------------------------------------------------------------------- Okoba · 2021-08-16 07:20 You guessed right. They are in different location. Two packages with no knowledge of each other and usage of the same obj as dependency. So it is a linker issue. There is no check or thing like Declared() that can know about if a function or object is declared somewhere else already? I know if the unit uses that unit, it is known, but I like to know about the whole project. ---------------------------------------------------------------------- PascalDragon · 2021-08-16 11:28 Quote from: Okoba on August 16, 2021, 09:20:48 amYou guessed right. They are in different location. Two packages with no knowledge of each other and usage of the same obj as dependency. Then that simply does not work. Quote from: Okoba on August 16, 2021, 09:20:48 amSo it is a linker issue. There is no check or thing like Declared() that can know about if a function or object is declared somewhere else already? I know if the unit uses that unit, it is known, but I like to know about the whole project. No. A unit has no way of knowing what another unit that it doesn't use itself might use. And there is especially no way of knowing for the pre-linking parts of the compiler what symbols an object file might provide. ---------------------------------------------------------------------- Okoba · 2021-08-16 12:35 Thank you very much for the clarification.