eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.36k stars 613 forks source link

linking fails on Dragonboard 410c with multiple definitions #1053

Open jpelletier opened 3 years ago

jpelletier commented 3 years ago

version.c.o multiple definition of `gVERSION' mraa.c.o first defined here

jpelletier commented 3 years ago

The file version.c is generated automatically and is conflicting with the existing definition in mraa.c. Anybody knows how to fix this?

When the code is cloned on a raspberrypi, it works fine.

With these modifications, it linked successfully. In include/version.h, I commented these lines

const char gVERSION; const char gVERSION_SHORT;

and copied these lines in src/mraa.c

Propanu commented 3 years ago

Hi @jpelletier, Have you tried disabling the tests (BUILDTESTS option)? This might be caused by trying to build with missing dependencies: Take a look at the CMakeLists.txt file.

RajithShetty619 commented 3 years ago

did u find any fix @jpelletier?

jpelletier commented 2 years ago

did u find any fix @jpelletier?

See Propanu's comments. When disabling the tests, it works.

rei-vilo commented 2 years ago

@jpelletier Thank you for the hint.

I solved the issue by specifying the two constants as extern, as the version.h header file only sets their declaration. The version.c source file provides their values.

extern const char* gVERSION;
extern const char* gVERSION_SHORT;

For an unknown reason, git clone https://github.com/nrcrast/mraa.git provides the version.h header file without extern while the code on repository does include extern.

https://github.com/eclipse/mraa/blob/d7ae17171bd733291aca70f910a0c2618fa4fe1a/include/version.h#L14-L15

Petross404 commented 2 years ago

Can we backport this fix to the latest release?