macchina-io / macchina.io

macchina.io EDGE is a powerful C++ and JavaScript SDK for edge devices, multi-service IoT gateways and connected embedded systems.
https://macchina.io
GNU General Public License v3.0
512 stars 152 forks source link

Problem with cross compiling macchina v2020.1 #102

Closed zaleksa closed 3 years ago

zaleksa commented 3 years ago

Hi,

I've successfully cross compiled macchina v0.11.0 for Armadeus Opos6ul module based on i.mx6ull processor.

Buildroot toolchain requires Ubuntu 14.06/16.06 for building target linux kernel, so I have to stick to one of these Ubuntu versions.

These are gcc and python versions that I have on the host:

$ gcc --version gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ python --version Python 2.7.12

Problem arises when I want to cross compile macchina v2020.1. First problem was with compiling hosttools because it must compile as C++11/14, so I added CXX flags for C++ 2011/2014 support:

$ git clone https://github.com/macchina-io/macchina.io.git $ cd macchina.io $ git checkout master $ sudo apt-get install build-essential libssl-dev python

build-essential is already the newest version (12.1ubuntu2). libssl-dev is already the newest version (1.0.2g-1ubuntu4.17). python is already the newest version (2.7.12-1~16.04).

$ make CXXFLAGS='-std=c++11 -std=c++14' -s -j2 hosttools

This passed successfully.

Then I copied following openssl-1.0.2o libraries from Buildroot build output folder to macchina.io/platform/lib/Linux/armv7a:

Then I invoke cross compiling with:

$ export CROSS_COMPILE=arm-linux-gnueabihf $ export PATH=~/Opossom/armadeus-7.0/buildroot/output/host/opt/ext-toolchain/bin/:$PATH $ export OPENSSL=~/Opossom/armadeus-7.0/buildroot/output/build/openssl-1.0.2o/include/ $ POCO_CONFIG=opos6ul LINKMODE=SHARED make CXXFLAGS='-std=c++11 -std=c++14 -I${OPENSSL}' -s -j2 DEFAULT_TARGET=shared_release

NOTE: Config file opos6ul is copy of ~/macchina.io/platform/build/config/ARM-Linux config file with changed TOOL ?= arm-linux-gnueabihf and POCO_TARGET_OSARCH ?= armv7a

This ended with following error:

Building dynamic library (release, shared) /home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so /home/user/macchina.io/platform/build/rules/dylib:59: recipe for target '/home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so' failed make[3]: ** [/home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so] Aborted (core dumped) make[3]: Deleting file '/home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so' Makefile:10: recipe for target 'bundle' failed make[2]: [bundle] Error 2 Makefile:355: recipe for target 'OSP/Web-libexec' failed make[1]: [OSP/Web-libexec] Error 2

I found that error arises when make execute postbuild command from Makefile-Bundle file:

postbuild = $(SET_LD_LIBRARY_PATH) $(BUNDLE_TOOL) -n$(OSNAME) -a$(OSARCH) -o../bundles WebBundle.bndlspec

Parameters from postbuild command are:

LD_LIBRARY_PATH=/home/user/macchina.io/platform/lib/Linux/x86_64 BUNDLE_TOOL=/home/user/macchina.io/platform/OSP/BundleCreator/bin/Linux/x86_64/bundle OSNAME=Linux OSARCH= armv7a

If I change postbuild command with postbuild = echo "The build is done." then it passes building dynamic library:

** Building dynamic library (release, shared) /home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so The build is done.

NOTE: Problem is with building dynamic library for any bundle, not only for osp web bundle.

Is it possible to cross compile macchina v2020.1 under Ubuntu 16.04 and if it is so, what could be the cause of the problem that I have?

Do I need to add some extra CXXFLAGS or LINKFLAGS or something else to ~/macchina.io/platform/build/config/opos6ul file?

Thank you in advance,

Aleksandar

obiltschnig commented 3 years ago

Try adding the macchina.io/platform/lib/Linux/x86_64 directory to the PATH environment variable. Look like the required shared libraries are not found when running the bundle tool.

zaleksa commented 3 years ago

Thanks for reply.

I tried adding export PATH=~/macchina.io/platform/lib/Linux/x86_64/:$PATH before invoking make, but the result is the same:

Building dynamic library (release, shared) /home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so /home/user/macchina.io/platform/build/rules/dylib:60: recipe for target '/home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so' failed make[3]: ** [/home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so] Aborted (core dumped) make[3]: Deleting file '/home/user/macchina.io/platform/OSP/Web/bin/Linux/armv7a/osp.web.so' Makefile:10: recipe for target 'bundle' failed make[2]: [bundle] Error 2 Makefile:365: recipe for target 'OSP/Web-libexec' failed make[1]: [OSP/Web-libexec] Error 2

Is there anything else that I could try?

Aleksandar

zaleksa commented 3 years ago

One more thing, I tried to compile hosttools with C++11/14 support for macchina v0.11.0, which was successful, and then invoke cross compiling in the same way as I did with hosttools without C++11/14 support, and got the same error as with compiling macchina v2020.1.

So, the problem is when I compile hosttools with C++11/14 support:

$ make CXXFLAGS='-std=c++11 -std=c++14' -s -j2 hosttools

which is successful, and then invoke cross compiling. Probably, shared libraries are not build in the same way with and without C++11/14 support.

Do you get some idea what could be wrong?

p.s. For every attempt of compiling hosttools and cross compiling, I delete whole macchina directory, reboot host computer and do it everything from clean start.

Aleksandar

zaleksa commented 3 years ago

Regarding my first comment about compiling macchina v2020.1, I tried to run Bundle Tool manually for OSP Web bundle:

$ cd ~/macchina.io/platform/OSP/Web $ export LD_LIBRARY_PATH=/home/aleksa/macchina.io/platform/lib/Linux/x86_64 $ ~/macchina.io/platform/OSP/BundleCreator/bin/Linux/x86_64/bundle -nLinux -aarmv7a -o../bundles WebBundle.bndlspec

and got the same error as above - "Aborted (core dumped)"

So I run Bundle Tool using valgrind with -v option and find the following error:

$ valgrind -v ~/macchina.io/platform/OSP/BundleCreator/bin/Linux/x86_64/bundle -nLinux -aarmv7a -o../bundles WebBundle.bndlspec

==13743== HEAP SUMMARY: ==13743== in use at exit: 167,847 bytes in 180 blocks ==13743== total heap usage: 553 allocs, 373 frees, 215,106 bytes allocated ==13743== ==13743== Searching for pointers to 180 not-freed blocks ==13743== Checked 253,872 bytes ==13743== ==13743== LEAK SUMMARY: ==13743== definitely lost: 0 bytes in 0 blocks ==13743== indirectly lost: 0 bytes in 0 blocks ==13743== possibly lost: 0 bytes in 0 blocks ==13743== still reachable: 167,847 bytes in 180 blocks ==13743== of which reachable via heuristic: ==13743== newarray : 52,944 bytes in 1 blocks ==13743== multipleinheritance: 440 bytes in 1 blocks ==13743== suppressed: 0 bytes in 0 blocks ==13743== Rerun with --leak-check=full to see details of leaked memory ==13743== ==13743== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==13743== ==13743== 1 errors in context 1 of 1: ==13743== Jump to the invalid address stated on the next line ==13743== at 0x100000000: ??? ==13743== by 0x6CA36D2: XML_Parse (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoXML.so.71) ==13743== by 0x6C86CF9: Poco::XML::ParserEngine::parseByteInputStream(std::istream&) (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoXML.so.71) ==13743== by 0x6C878A8: Poco::XML::ParserEngine::parse(Poco::XML::InputSource) (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoXML.so.71) ==13743== by 0x6C8B542: Poco::XML::SAXParser::parse(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoXML.so.71) ==13743== by 0x6C78356: Poco::XML::DOMBuilder::parse(Poco::XML::InputSource) (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoXML.so.71) ==13743== by 0x6C7930E: Poco::XML::DOMParser::parse(Poco::XML::InputSource) (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoXML.so.71) ==13743== by 0x529C131: Poco::Util::XMLConfiguration::load(Poco::XML::InputSource, unsigned long) (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoUtil.so.71) ==13743== by 0x529C281: Poco::Util::XMLConfiguration::load(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoUtil.so.71) ==13743== by 0x529C506: Poco::Util::XMLConfiguration::XMLConfiguration(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoUtil.so.71) ==13743== by 0x405E07: ??? (in /home/user/macchina.io/platform/OSP/BundleCreator/bin/Linux/x86_64/bundle) ==13743== by 0x5282DFE: Poco::Util::Application::run() (in /home/user/macchina.io/platform/lib/Linux/x86_64/libPocoUtil.so.71) ==13743== Address 0x100000000 is not stack'd, malloc'd or (recently) free'd ==13743== ==13743== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) Aborted (core dumped)

So, I suppose that there is some problem or incompatibility with compiled libPocoXML shared library with C++11/14 support.

Do you have some idea?

Best regards,

Aleksandar

zaleksa commented 3 years ago

So I have installed Ubuntu 18.04 LTS, compiled hosttools without C++11/14 flags and it compiled ok. After that I successfully cross compiled macchina.io using the same cross-gcc from Buildroot which I have used in first post.

These are tools versions on Ubuntu 16.04 LTS:

$ gcc --version gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ python --version Python 2.7.12

$ sudo apt-get install build-essential libssl-dev python

build-essential is already the newest version (12.1ubuntu2). libssl-dev is already the newest version (1.0.2g-1ubuntu4.17). python is already the newest version (2.7.12-1~16.04).

These are tools versions on Ubuntu 18.04 LTS:

$ gcc --version gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ python --version Python 2.7.17

$ sudo apt-get install build-essential libssl-dev python

build-essential is already the newest version (12.4ubuntu1). libssl-dev is already the newest version (1.1.1-1ubuntu2.1~18.04.6). python is already the newest version (2.7.15~rc1-1).

What could be the reason why I can't compile tools and then cross compile macchina in Ubuntu 16.04 LTS? Is it maybe because of old version gcc, python, libssl or something else?

Aleksandar

zaleksa commented 3 years ago

Finally I have found that the problem was with old version of GCC.

I have installed gcc 7.5.0 (on Ubuntu 16.04) and successfully compiled hosttools without additional C++11/14 flags. After that, cross compilation of macchina.io v2020.1 was also successful.

Thanks anyway.

Aleksandar