"gnu/stubs-o32_hard.h: No such file or directory" golang cgo mipsel embedded chip system fatal error: - linux

1. bg: i got a project to develop the embedded camera system, the system is using mips 32bit, i got the toolchain in ubuntu. go version: 1.17.7
2. my question:
2.1) pure golang cross compile into mipsle platform is good and working.the command it use is :
GOOS=linux GOARCH=mipsle CGO_ENABLED=0 go build main.go
2.2) but i got some third-party lib which they offer as xxx.so and xxx.h to me. when i finish coding it into my go project using cgo. i want to cross complie into mips system which i found fail.
3. what i had try:
3.1) i know go is not support cross complie cgo, so i try the normal way which is like this:
GOOS=linux GOARCH=mipsle CGO_ENABLED=1 CC=/opt/mips-gcc720-glibc226/bin/mips-linux-gnu-gcc go build main.go
result:
# runtime/cgo
In file included from /opt/mips-gcc720-glibc226/mips-linux-gnu/libc/usr/include/features.h:447:0,
from /opt/mips-gcc720-glibc226/mips-linux-gnu/libc/usr/include/bits/libc-header-start.h:33,
from /opt/mips-gcc720-glibc226/mips-linux-gnu/libc/usr/include/stdlib.h:25,
from _cgo_export.c:3:
/opt/mips-gcc720-glibc226/mips-linux-gnu/libc/usr/include/gnu/stubs.h:11:11: fatal error: gnu/stubs-o32_hard.h: No such file or directory
# include <gnu/stubs-o32_hard.h>
^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
3.2) i also try gccgo, in ubuntu, i try:
go build -compiler=mipsel-linux-gnu-gccgo main.go
result:
invalid value "mipsel-linux-gnu-gccgo" for flag -compiler: unknown compiler "mipsel-linux-gnu-gccgo"
usage: go build [-o output] [build flags] [packages]
Run 'go help build' for details.
3.3) i had try xgo project to compile, which is can output a result, but when i move to the mipsle system it still can not working.
so , can any body help? if need the toolchain to test, i can send you
cantact me: justforjobonly#126.com
thanks!

Related

ESP32: gn.py: Could not find checkout in any parent of the current path. This must be run inside a checkout

complying an ESP32 project using the MATTER protocol from the github project: Connectedhomeip (https://github.com/project-chip/connectedhomeip/tree/master/examples/all-clusters-app/esp32)
im using ubuntu 20.02, tried using python 3.8 and 3.9 no difference to error.
i followed the following instructions from the above link, the instruction as pasted below
Building the Example Application
Building the example application requires the use of the Espressif ESP32 IoT Development Framework and the xtensa-esp32-elf toolchain for ESP32 modules or the riscv-esp32-elf toolchain for ESP32C3 modules.
The VSCode devcontainer has these components pre-installed, so you can skip this step. To install these components manually, follow these steps:
Clone the Espressif ESP-IDF and checkout v4.4 release
$ mkdir ${HOME}/tools
$ cd ${HOME}/tools
$ git clone https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ git checkout v4.4
$ git submodule update --init
$ ./install.sh
Install ninja-build
$ sudo apt-get install ninja-build
Currently building in VSCode and deploying from native is not supported, so make sure the IDF_PATH has been exported(See the manual setup steps above).
Setting up the environment
$ cd ${HOME}/tools/esp-idf
$ ./install.sh
$ . ./export.sh
$ cd {path-to-connectedhomeip}
To download and install packages.
$ source ./scripts/bootstrap.sh
$ source ./scripts/activate.sh
If packages are already installed then simply activate them.
$ source ./scripts/activate.sh
Target Set
To set IDF target, run set-target with one of the commands.
$ idf.py set-target esp32
$ idf.py set-target esp32c3
Configuration Options
To build the default configuration (sdkconfig.defaults) skip to building the demo application.
To build a specific configuration (as an example m5stack):
$ rm sdkconfig
$ idf.py -D 'SDKCONFIG_DEFAULTS=sdkconfig_m5stack.defaults' build
Note: If using a specific device configuration, it is highly recommended to
start off with one of the defaults and customize on top of that. Certain
configurations have different constraints that are customized within the
device specific configuration (eg: main app stack size).
To customize the configuration, run menuconfig.
$ idf.py menuconfig
Select ESP32 based Device Type through Demo->Device Type. The device types that are currently supported include ESP32-DevKitC (default), ESP32-WROVER-KIT_V4.1, M5Stack and ESP32C3-DevKitM.
To build the demo application.
$ idf.py build
After building the application, to flash it outside of VSCode, connect your device via USB. Then run the following command to flash the demo application onto the device and then monitor its output. If necessary, replace /dev/tty.SLAB_USBtoUART(MacOS) with the correct USB device name for your system(like /dev/ttyUSB0 on Linux). Note that sometimes you might have to press and hold the boot button on the device while it's trying to connect before flashing. For ESP32-DevKitC devices this is labeled in the functional description diagram.
$ idf.py -p /dev/tty.SLAB_USBtoUART flash monitor
When use >>idf.py to build the project i get the follow error
>>idf.py build
Executing action: all (aliases: build)
Running ninja in directory /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build
Executing "ninja all"...
ninja: warning: bad deps log signature or version; starting over
[0/1] Re-running CMake...
-- Building ESP-IDF components for target esp32
-- Found Python3: /home/csir/.espressif/python_env/idf5.0_py3.8_env/bin/python3.8 (found version "3.8.10") found components: Interpreter
-- Project sdkconfig file /home/csir/connectedhomeip/examples/all-clusters-app/esp32/sdkconfig
Loading defaults file /home/csir/connectedhomeip/examples/all-clusters-app/esp32/sdkconfig.defaults...
-- App "chip-all-clusters-app" version: TE8/rc2-7-gf32685f35-dirty
-- Adding linker script /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build/esp-idf/esp_system/ld/memory.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_system/ld/esp32/sections.ld.in
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-time.ld
-- Adding linker script /home/csir/esp/esp-idf/components/soc/esp32/ld/esp32.peripherals.ld
-- Components: QRCode app_trace app_update asio bootloader bootloader_support bt chip cmock coap console cxx driver efuse esp-tls esp32 esp32_mbedtls esp_adc_cal esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_lcd esp_local_ctrl esp_netif esp_phy esp_pm esp_ringbuf esp_rom esp_serial_slave_link esp_system esp_timer esp_websocket_client esp_wifi espcoredump esptool_py fatfs freemodbus freertos hal heap http_parser idf_test ieee802154 iperf json led_strip log lwip main mbedtls mdns mqtt newlib nvs_flash openssl openthread partition_table pcap perfmon pid_ctrl protobuf-c protocol_examples_common protocomm pthread qrcode screen-framework sdmmc soc spi_flash spidriver spiffs tcp_transport tcpip_adapter tft tinyusb ulp unity usb vfs wear_levelling wifi_provisioning wpa_supplicant xtensa
-- Component paths: /home/csir/connectedhomeip/examples/common/QRCode /home/csir/esp/esp-idf/components/app_trace /home/csir/esp/esp-idf/components/app_update /home/csir/esp/esp-idf/components/asio /home/csir/esp/esp-idf/components/bootloader /home/csir/esp/esp-idf/components/bootloader_support /home/csir/esp/esp-idf/components/bt /home/csir/connectedhomeip/examples/all-clusters-app/esp32/third_party/connectedhomeip/config/esp32/components/chip /home/csir/esp/esp-idf/components/cmock /home/csir/esp/esp-idf/components/coap /home/csir/esp/esp-idf/components/console /home/csir/esp/esp-idf/components/cxx /home/csir/esp/esp-idf/components/driver /home/csir/esp/esp-idf/components/efuse /home/csir/esp/esp-idf/components/esp-tls /home/csir/esp/esp-idf/components/esp32 /home/csir/connectedhomeip/examples/all-clusters-app/esp32/third_party/connectedhomeip/config/esp32/components/esp32_mbedtls /home/csir/esp/esp-idf/components/esp_adc_cal /home/csir/esp/esp-idf/components/esp_common /home/csir/esp/esp-idf/components/esp_eth /home/csir/esp/esp-idf/components/esp_event /home/csir/esp/esp-idf/components/esp_gdbstub /home/csir/esp/esp-idf/components/esp_hid /home/csir/esp/esp-idf/components/esp_http_client /home/csir/esp/esp-idf/components/esp_http_server /home/csir/esp/esp-idf/components/esp_https_ota /home/csir/esp/esp-idf/components/esp_https_server /home/csir/esp/esp-idf/components/esp_hw_support /home/csir/esp/esp-idf/components/esp_lcd /home/csir/esp/esp-idf/components/esp_local_ctrl /home/csir/esp/esp-idf/components/esp_netif /home/csir/esp/esp-idf/components/esp_phy /home/csir/esp/esp-idf/components/esp_pm /home/csir/esp/esp-idf/components/esp_ringbuf /home/csir/esp/esp-idf/components/esp_rom /home/csir/esp/esp-idf/components/esp_serial_slave_link /home/csir/esp/esp-idf/components/esp_system /home/csir/esp/esp-idf/components/esp_timer /home/csir/esp/esp-idf/components/esp_websocket_client /home/csir/esp/esp-idf/components/esp_wifi /home/csir/esp/esp-idf/components/espcoredump /home/csir/esp/esp-idf/components/esptool_py /home/csir/esp/esp-idf/components/fatfs /home/csir/esp/esp-idf/components/freemodbus /home/csir/esp/esp-idf/components/freertos /home/csir/esp/esp-idf/components/hal /home/csir/esp/esp-idf/components/heap /home/csir/esp/esp-idf/components/http_parser /home/csir/esp/esp-idf/components/idf_test /home/csir/esp/esp-idf/components/ieee802154 /home/csir/esp/esp-idf/examples/common_components/iperf /home/csir/esp/esp-idf/components/json /home/csir/esp/esp-idf/examples/common_components/led_strip /home/csir/esp/esp-idf/components/log /home/csir/esp/esp-idf/components/lwip /home/csir/connectedhomeip/examples/all-clusters-app/esp32/main /home/csir/esp/esp-idf/components/mbedtls /home/csir/esp/esp-idf/components/mdns /home/csir/esp/esp-idf/components/mqtt /home/csir/esp/esp-idf/components/newlib /home/csir/esp/esp-idf/components/nvs_flash /home/csir/esp/esp-idf/components/openssl /home/csir/esp/esp-idf/components/openthread /home/csir/esp/esp-idf/components/partition_table /home/csir/esp/esp-idf/examples/common_components/pcap /home/csir/esp/esp-idf/components/perfmon /home/csir/esp/esp-idf/examples/common_components/pid_ctrl /home/csir/esp/esp-idf/components/protobuf-c /home/csir/esp/esp-idf/examples/common_components/protocol_examples_common /home/csir/esp/esp-idf/components/protocomm /home/csir/esp/esp-idf/components/pthread /home/csir/esp/esp-idf/examples/common_components/qrcode /home/csir/connectedhomeip/examples/common/screen-framework /home/csir/esp/esp-idf/components/sdmmc /home/csir/esp/esp-idf/components/soc /home/csir/esp/esp-idf/components/spi_flash /home/csir/connectedhomeip/examples/common/m5stack-tft/repo/components/spidriver /home/csir/esp/esp-idf/components/spiffs /home/csir/esp/esp-idf/components/tcp_transport /home/csir/esp/esp-idf/components/tcpip_adapter /home/csir/connectedhomeip/examples/common/m5stack-tft/repo/components/tft /home/csir/esp/esp-idf/components/tinyusb /home/csir/esp/esp-idf/components/ulp /home/csir/esp/esp-idf/components/unity /home/csir/esp/esp-idf/components/usb /home/csir/esp/esp-idf/components/vfs /home/csir/esp/esp-idf/components/wear_levelling /home/csir/esp/esp-idf/components/wifi_provisioning /home/csir/esp/esp-idf/components/wpa_supplicant /home/csir/esp/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build
[7/1126] Generating ../../partition_table/partition-table.bin
Partition table binary generated. Contents:
*******************************************************************************
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
otadata,data,ota,0xf000,8K,
phy_init,data,phy,0x11000,4K,
ota_0,app,ota_0,0x20000,1500K,
ota_1,app,ota_1,0x1a0000,1500K,
ot_storage,data,58,0x317000,8K,
*******************************************************************************
[261/1126] Performing configure step for 'bootloader'
-- Building ESP-IDF components for target esp32
-- Project sdkconfig file /home/csir/connectedhomeip/examples/all-clusters-app/esp32/sdkconfig
-- Adding linker script /home/csir/esp/esp-idf/components/soc/esp32/ld/esp32.peripherals.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script /home/csir/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script /home/csir/esp/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.ld
-- Adding linker script /home/csir/esp/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.rom.ld
-- Components: bootloader bootloader_support efuse esp32 esp_common esp_hw_support esp_rom esp_system esptool_py freertos hal log main micro-ecc newlib partition_table soc spi_flash xtensa
-- Component paths: /home/csir/esp/esp-idf/components/bootloader /home/csir/esp/esp-idf/components/bootloader_support /home/csir/esp/esp-idf/components/efuse /home/csir/esp/esp-idf/components/esp32 /home/csir/esp/esp-idf/components/esp_common /home/csir/esp/esp-idf/components/esp_hw_support /home/csir/esp/esp-idf/components/esp_rom /home/csir/esp/esp-idf/components/esp_system /home/csir/esp/esp-idf/components/esptool_py /home/csir/esp/esp-idf/components/freertos /home/csir/esp/esp-idf/components/hal /home/csir/esp/esp-idf/components/log /home/csir/esp/esp-idf/components/bootloader/subproject/main /home/csir/esp/esp-idf/components/bootloader/subproject/components/micro-ecc /home/csir/esp/esp-idf/components/newlib /home/csir/esp/esp-idf/components/partition_table /home/csir/esp/esp-idf/components/soc /home/csir/esp/esp-idf/components/spi_flash /home/csir/esp/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build/bootloader
[270/1126] Performing build step for 'bootloader'
[1/1] cd /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build/bootloader/esp-idf/esptool_py && /home/csir/.espressif/python_env/idf5.0_py3.8_env/bin/python /home/csir/esp/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build/bootloader/bootloader.bin
Bootloader binary size 0x6360 bytes. 0xca0 bytes (11%) free.
[585/1125] Performing configure step for 'chip_gn'
FAILED: esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-configure
cd /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build/esp-idf/chip && /home/csir/depot_tools/gn --root=/home/csir/connectedhomeip/config/esp32 gen --check --fail-on-unused-args /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build/esp-idf/chip && /usr/bin/cmake -E touch /home/csir/connectedhomeip/examples/all-clusters-app/esp32/build/esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-configure
gn.py: Could not find checkout in any parent of the current path.
This must be run inside a checkout.
[586/1125] Building C object esp-idf/esp_serial_slave_link/CMakeFiles/__idf_esp_serial_slave_link.dir/essl_spi.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
I can see that the problem is in the file ~/depot_tools/gn.py
with the line 50: bin_path = gclient_paths.GetBuildtoolsPlatformBinaryPath()
gclient_paths.GetBuildtoolsPlatformBinaryPath() returns "none"
what should the value be?
Some hours ago I had exactly the same problem.
In my case, I didn't run $ source ./scripts/bootstrap.sh because I didn't worked, but I clone the whole git again in my home folder, lauched the command and (after almost an hour) run idf.py set-target esp32 and idf.py build and it finally worked.
I followed more or less the following steps from this issue in Matter repo and it helped a lot:
https://github.com/project-chip/connectedhomeip/issues/15562#issuecomment-1057750597
Hope this works for you!

How do I fix "ld: error: unable to find library -lgcc" when cross-compiling rust to android?

I'm trying to get rust working on android. However, when I try to cross-compile to android I get the following linking error:
$ cargo build --target=arm-linux-androideabi
Compiling <project> v0.1.0 (<project>)
error: linking with `/opt/android-sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi31-clang` failed: exit status: 1
(very long toolchain command from cargo)
ld: error: unable to find library -lgcc
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
I have installed the ndk and changed the linker in .cargo/config to the android clang linker. I also tried the standalone toolchains with the same result. The guide I used was the following: https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html
Cross-compilation does work when using crate-type = ["rlib"] instead of crate-type = ["cdylib"], but I need an .so file not an .rlib file.
In case it's relevant, i'm using Manjaro Linux.
UPDATE:
I found the following pull request: https://github.com/rust-lang/rust/pull/85806 After switching to ndk22 it worked. I havn't tried if the pull request fixes the issue (probably does).
Without switching to an older NDK version, I found using the workaround provided by ssrlive to work for me. Here's their comment:
Fixing build error for NDK 23 and above
find out all the 4 folders containing file libunwind.a, in my PC,
it's
C:\Users\Administrator\AppData\Local\Android\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\12.0.8\lib\linux\x86_64\
and more. create 4 text files named libgcc.a in the same folders
with this contents
INPUT(-lunwind)
reference
link
In macOS, the paths are
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/i386/libunwind.a
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/arm/libunwind.a
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/aarch64/libunwind.a
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/x86_64/libunwind.a
In Linux, the paths are
~/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/i386/libunwind.a
~/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/aarch64/libunwind.a
~/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/x86_64/libunwind.a
~/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/arm/libunwind.a
In Windows, the paths are
~/AppData/Local/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/14.0.1/lib/linux/aarch64/libunwind.a
~/AppData/Local/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/14.0.1/lib/linux/arm/libunwind.a
~/AppData/Local/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/14.0.1/lib/linux/i386/libunwind.a
~/AppData/Local/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/14.0.1/lib/linux/x86_64/libunwind.a
create file command in Linux/macOS
cat << EOF > libgcc.a
INPUT(-lunwind)
EOF
This is of course extremely brittle and not the "right" solution, but the workaround works fine as of 2022-10-12 with ndk version 25.1.8937393.

Error: "linker 'cc' not found" when cross compiling a rust project from windows to linux using cargo

I have a basic rust/cargo project with a single main file and some basic dependencies. The cargo build command works fine when the target is not specified (I am using windows so it builds to windows), but when I try to cross compile the program to linux using cargo build --target=x86_64-unknown-linux-gnu or cargo build --target=x86_64-unknown-linux-musl, the process fails with the following error: linker 'cc' not found.
Does anyone have an idea how to get around this? Is there a specific linker I need to install?
Thanks.
I've just figured it out.
It turns out you need to tell cargo to use the LLVM linker instead. You do this by creating a new directory called .cargo in your base directory, and then a new file called config.toml in this directory. Here you can add the lines:
[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "linker-flavor=ld.lld"]
Then building with the command cargo build --target=x86_64-unknown-linux-musl should work!

Error building go compiler from source

I am trying to build the latest version (tip of the master branch) of Go from source.
The official Go documentation (https://golang.org/doc/install/source) states that you should download Go 1.4 binaries to build a more recent version. However it should be possible to build all from source.
To do this, I set variables in .bashrc :
PATH="$HOME/go/bin:$PATH"
export GOPATH=$HOME
then to build go 1.4 from source :
source ~/.bashrc
git clone https://go.googlesource.com/go
mkdir ~/go1.4
cd ~/go
git archive --format=tar go1.4.3 |tar -xv -C ~/go1.4
cd ~/go1.4/src
./make.bash
and finally build the latest version :
cd ~/go/src/
GOROOT_BOOTSTRAP=$HOME/go1.4 ./make.bash
I remember doing this months ago without problems, but today I get these errors building go 1.4 make.bash:
# cmd/pprof
.../go1.4/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
.../go1.4/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
runtime/cgo(.text): unexpected relocation type 298
runtime/cgo(.text): unexpected relocation type 298
...
Is there something wrong in my method ?
The error messages point to CGO, and environment variables that control make.bash are explained at the beginning of the file :
CGO_ENABLED: Controls cgo usage during the build. Set it to 1
to include all cgo related files, .c and .go file with "cgo"
build directive, in the build. Set it to 0 to ignore them.
so if you disable CGO while building GO 1.4 :
cd ~/go1.4/src
CGO_ENABLED=0 ./make.bash
everything works and pass the tests.

Problem in Cross-Compiling libSDL for MIPS Platform

I was trying to compile libSDL-1.2.14 for my mips platform.
But it was not successful.
These were the steps that I tried out :
export PATH=/opt/mips-4.3/bin:$PATH
Went inside the libSDL-1.2.14 source folder.
Gave a "./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu"
Executed the "make" command
This was the error received :
cc1: warning: include location
"/usr/include" is unsafe for
cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In
function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167:
error: can't find a register in class
'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167:
error: 'asm' operand has impossible
constraints make: *
[build/SDL_dmaaudio.lo] Error 1
But then i reconfigured the make file by giving the following commands :
make clean
./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu CPPFLAGS=-I/opt/mips-4.3/mips-linux-gnu/libc/usr/include/
make
NOTE : /opt/mips-4.3/mips-linux-gnu/libc/usr/include/ - This is the path where you can locate the select.h file for the mips Platform.
It contains the definitions of the macros FD_ZERO and FD_SET.
Still I am getting the same error.
cc1: warning: include location
"/usr/include" is unsafe for
cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In
function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167:
error: can't find a register in class
'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167:
error: 'asm' operand has impossible
constraints make: *
[build/SDL_dmaaudio.lo] Error 1
Please help me with some valuable pointers.
Thanks,
Sen
First, don't set the path to the cross-compiler as the first part of your PATH, set it as last:
export PATH=$PATH:<path to cross-compiler>
It's safer this way. Second, run ./configure --help to get all the options. What that error message would say if it was smarter is the following:
You're trying to cross-compile since you're setting the --host flag
But you're not changing any of the other options for where to find includes and libs for the target environment
I'm going to use /usr/include by default
But that's for the host system which will not work when cross-compiling
Check what other configure options you need to set to tell the configure script where to find the .h files (includes) and the libraries for your target. These usually come with the cross-compiler that you download. Also, you should probably set the CROSS_COMPILE environment variable to the cross-compiler prefix before running configure. The prefix is the part before gcc in a cross-compiler, assuming you're using GCC as your cross-compiler.

Resources