Go - Cross compiling with CGO using xgo library - macos

I'm trying to compile a GO application, which uses the gokiri library.
I installed docker and compiled locally the xgo cross compiler for go.
When trying to execute the following command:
./xgo mydomain.com/test/test-app
I get the following error:
In file included from /usr/include/libxml2/libxml/parser.h:810:0,
from /usr/include/libxml2/libxml/globals.h:18,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1307,
from ../../github.com/moovweb/gokogiri/help/help.go:6:
/usr/include/libxml2/libxml/encoding.h:28:19: fatal error: iconv.h: No such file or directory
I've installed xcode-tools which helped me compile it for my machine (mac ox El Capitan). BUT, I cannot get it compiled to other environment.
Any help will be appreciated. Thanks.
Update 1:
I've tried to add the dependency, but got the same result:
./xgo --deps /usr/local/Cellar/libiconv/1.14/ mydomain.com/test/test-app
It was even mentioned in the logs of the xgo that this library was already cached:
Dependency already cached: /Users/macuser/.xgo-cache/1.14.

from the documentation:
It is assumed that the dependent C/C++ library is configure/make
based, was properly prepared for cross compilation and is available as
a tarball download (.tar, .tar.gz or .tar.bz2). Further plans include
extending this to cmake based projects, if need arises (please open an
issue if it's important to you).
Such dependencies can be added via the --deps argument. They will be
retrieved prior to starting the cross compilation and the packages
cached to save bandwidth on subsequent calls.
So in this example, it would be:
./xgo --deps https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz mydomain.com/test/test-app

Related

gtsam is not able to find Eigen

I use version 4.1.1 of GTSAM. I have version 3.3.4 of Eigen installed.
The error is:
/usr/local/include/gtsam/base/OptionalJacobian.h:22:10: fatal error: Eigen/Dense: No such file or directory
#include <Eigen/Dense>
I tried building GTSAM with the flag -DGTSAM_USE_SYSTEM_EIGEN set to both on and off.
The same error message appears in both cases.
For reference this is a ROS project built with catkin.
Have you seen this PR: https://github.com/borglab/gtsam/pull/1304
If you can upgrade GTSAM to 4.2a8, it uses Eigen's find script's rather than custom ones and should properly find Eigen3, if you have it installed if you require to build from source.
Since you are using ROS, why not go the standard route... Have you declared a dependency on it in your package.xml and installed it with rosdep?
https://github.com/ros/rosdistro/pull/23198/files
Add to your package.xml:
<depend>gtsam</depend>
And, your CMakeLists, you just call
find_package(gtsam REQUIRED)
It is unclear to me, if gtsam is available through binaries, why you would be building it from source.
I was able to get it working by cloning version 4.0.3 of GTSAM into the src folder of my workspace, then building it with the following arguments:
-DGTSAM_USE_SYSTEM_EIGEN=ON -DGTSAM_POSE3_EXPMAP=ON -DGTSAM_ROT3_EXPMAP=ON

Which build of gcc should I use to correctly build rustlearn crate?

I'm trying to use rustlearn crate in my project. Added the dependency in Cargo.toml.
Since rustlearn requires gcc, I downloaded and installed MinGW64.
I tried the following gcc builds:
x86_64-8.1.0-posix-seh-rt_v6-rev0
x86_64-8.1.0-posix-sjlj-rt_v6-rev0
i686-8.1.0-posix-sjlj-rt_v6-rev0
each time setting a PATH environment variable to the appropriate g++.exe and restarting VSCode.
But everytime I tried to build my Rust package I got a such error:
= note: C:\Rust\PF\machinelearning\target\debug\deps\librustlearn-4ae611e3fd449ac0.rlib(svm.o): In function `ZN6KernelC2EiPKP8svm_nodeRK13svm_parameter':
C:\Git-local-repos\rustlearn/dependencies/libsvm/svm.cpp:256: undefined reference to `__gxx_personality_sj0'
C:\Git-local-repos\rustlearn/dependencies/libsvm/svm.cpp:256: undefined reference to `_Unwind_SjLj_Register'
C:\Git-local-repos\rustlearn/dependencies/libsvm/svm.cpp:258: undefined reference to `_Unwind_SjLj_Resume'
C:\Git-local-repos\rustlearn/dependencies/libsvm/svm.cpp:289: undefined reference to `_Unwind_SjLj_Unregister'
repeated many times.
I realize that the problem is somehow related to exception handling (seh/sjlj).
My system is Windows 7 x86-64, rust toolchain is stable-i686-pc-windows-gnu.
What am I doing wrong?
I found that the right build of MinGW is i686-7.1.0-posix-dwarf-rt_v5-rev2.
I did not run into these errors when I created a MWE.
To me, this looks like you are trying to use gcc to link a *.o that was compiled with g++.
I was unable to replicate your problem. Here's what I did--which resulted in a successfully built project:
I created a new project with cargo new and added the following to Cargo.toml:
rustlearn = "0.5.0"
I ran cargo check to download all the required dependencies.
I edited src/main.rs to include the logistic regression example from here, modified so that it was called in a main() function.
I ran cargo build, which successfully compiled crossbeam, libc, serde, rand, rustlearn, and rustlearn-test--the name of my test package. Several linting warnings were outputted; they were ignored.
I ran cargo run, which successfully ran the program.
FWIW, I'm using the WSL on Windows 10.

Library not found OpenCV

I'm on mac 10.7.5, using xcode 4.6.2 and working with the OpenCV 2.4.3 library. I went through the process of making the build directory with the cmake files in terminal and did the download.
I added the .dylib files in Xcode and changed the header path, changed C++ Library to libstdc++, but when I compiled I got this error :
ld: library not found for -lopencv_calib3d.2.4.3
clang: error: linker command failed with exit code 1
I have libopencv_calib3d.2.4.3.dylib added in the project so I have no idea what else it needs.Any ideas?
If your "make back-end" is Cmake you should stick to using it. Local config changes in Xcode can "secretly" be overwritten when the cmake is rerun (which for example happens after you make changes to it) creating weird build errors and forcing you to remember all the manual changes you made.
Your problem seems to be that the generated project doesn't seem to know where to look for opencv.
Assuming you installed opencv using macports you should add a line saying
link_directories(/opt/local/lib)
to your CMakeLists.txt. (if you installed it using brew, or compiled it manually just replace /opt/local/lib for /usr/local/lib or the path to your compiled libraries)
Also make sure to link against opencv_calib3d instead of opencv_calib3d.2.4.3 (unless you have a very particular reason for bypassing this, but that usually means that something else is weird in the setup :) )
Final pointer that you might already know of: As you are already using Cmake you should add the libraries to link against using TARGET_LINK_LIBRARIES(...) in Cmake rather than manually adding them in Xcode (referring to my previous argument).

MQX 4.0.1 program Not Compiled with GCC

I am using TWR-K20D72M and I opened a Sample program which is given in the MQX 4.0.1 Demo examples. When I choose Build tool option as Freescale
the program compiles OK but When I choose Build tool option as GCC It gives me error.The Error is below
error
Description
mingw32-make: *** No rule to make target `C:/Freescale/Freescale_MQX_4_0/lib/twrk20d72m.cw10gcc/debug/bsp/intflash.ld', needed by `explicit-dependencies'.
I read somewhere that The GCC can only work with MQX 4.0.1 and above so I am using MQX 4.0.1 .
Can some suggest me the reason for this error.How I can I remove this error.......
Thanks
You are missing the linker script file for your project intflash.ld.
Normally this file is located on
{mqx_install_dir}\mqx\source\bsp\{your_bsp_name}\gcc_cw
and is copied to
{mqx_install_dir}\lib\{your_bsp_name}.cw10gcc\debug\bsp
and
{mqx_install_dir}\lib\{your_bsp_name}.cw10gcc\release\bsp
after the build process by the scripts for your bsp, located on
{mqx_install_dir}\mqx\build\bat.
Take a look inside your bsp script and verify that intflash.ld is being copied correctly.
My guess is that you compiled your MQX application before compiling the BSP and PSP. With the release of CodeWarrior 4.6, the solution has gotten a bit easier through the use of .wsd files.
If you look at the FSL_MQX_getting_started.pdf, section 2.4 describes how to find a .wsd file which needs to be dragged into your CodeWarrior Project Explorer. Once this is done new projects will be added to your workspace. Compile the bsp_... and psp_... and any other libs that you require (usb, ethernet etc) which will generate binaries and the intflash.ld file in the correct location.
http://cache.freescale.com/files/soft_dev_tools/doc/support_info/FSL_MQX_Getting_Started.pdf

Why can I not build a lower version compiler

I am currently trying to build a gcc 4.4 on a newly updated ubuntu 11.10. However building the compiler always fails with some problems, when trying to bootstrap.
First crti.o and crtn.o could not be found. I symlinked them into another directory within the search path, and so I could get a bootstrap compiler. However now it fails with the message:
configure: error: C compiler cannot create executables
I tried out to use the intermediate compiler on a simple test program, and I get the message:
$ ./host-x86_64-unknown-linux-gnu/prev-gcc/xgcc test.c
xgcc: error trying to exec 'cc1': execvp: File or directory not found
So something is seriously messed up with the paths of my intermediate compiler it seems. When I did the same thing on ubuntu 11.04 everything just worked fine.
I used the following command line to configure:
./configure --prefix=/opt --program-suffix=44
I also tried both a VPATH-built, as well as an in source build, but both have the same problem. I still have the gcc44 from before the update lying around within /opt, but it has become unusable since the update.
Is there any easy way to get gcc 4.4 working under Ubuntu 11.10? I does not have to be a self build compiler, if I can just download a package and install that, it would be fine as well.
This is caused by Ubuntu's switch to multi-arch. Basically all the "standard" paths have been changed so you can install libraries for multiple architectures on the same machine without any clashes.
Ubuntu GCC has been patched to fix the problem, of course, but the upstream compiler still wasn't fixed last time I checked.
See here: https://askubuntu.com/questions/69365/cant-build-gcc-anymore-since-upgrade-to-11-10

Resources