c++ - GCC Cross compile to a i586 architecture (Vortex86DX)


I have Ubuntu 12.01 with gcc 4.8.2 and would like to cross compile for the Vortex86DX CPU running an old 2.6.23 kernel.

I´m trying the following testing code:

#include <iostream>

int main()
   std::cout << "Hello world" << std::endl;

That is compiled using the following command line:

g++ -static-libgcc -static-libstdc++ -march=i586 test.cpp -otest586

When I run the test586 on the target architecture I´m getting this error:

$ ./test586
./teste586: symbol lookup error: ./test586: undefined symbol: _ZMSbIwSt11char_traitsIwESaIwEE4_Rep20_S_empty_rep_storageE

Any ideas of what is going on here ? This is just a small code - the real code has around 10 different libraries all written in C++ 11.

In fact the comment from Marco was right. The code still need some dynamics libraries:

$ ldd ./test586
linux-gate.so.1 =>  (0xb776b000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75a4000)
/lib/ld-linux.so.2 (0xb776e000)

I have to avoid all dynamic library as the target system either does not have them or will have in a very old version.

Help appreciated to accomplish that.

1 Answer: 

I think the problem is the order of the command switches, i.e. the linker first discovers the dependencies (libgcc, libstdc++) and only then resolves them. If you give it -static-libgcc before it found the dependency then it will simply ignore it.

the following works for me:

$ g++ -m32 -march=i586 test.cpp -o test586 -static -static-libgcc -static-libstdc++
$ ./test586 
Hello world
$ ldd test586 
not a dynamic executable

More Articles

java - Location mocking - google map detects the movement but my own application not triggering location change

I am facing a strange issue. I modified official mock provider source code provided by google to mock some route for my application.Using this code. mockLocation.setElapsedRealtimeNanos(elapsedTimeNanos); mockLocation.setTime(currentTime); // Set the loc

python - Heap that supports modification of its elements?

Here is my scenario. I want to implement A* (in Python) without having to resort to linear-time min or in operations. I need a heap to be able to efficiently get the lowest weight item. My immediate response was 'Easy! I'll use heapq!' Then I discovered that life is rarely as simple as we would like

java - gRPC: Generate certificateChainFile and privateKeyFile to make TLS/SSL work

I want to make tls/ssl connection between client and server(Not mutual, one way). This is my setup:Server: Server server = ServerBuilder.forPort(8443) // Enable TLS .useTransportSecurity(certChainFile, privateKeyFile) .addService(new GreetingServiceImpl()) .build();Cli

r - split string at every character

I want to split every character in a string and output it as comma or tab separated characters:I need to use file_in and file_out since I have very many lines.inputTTTGGCTTTGTGCAATGG........outputT,T,T,G,G,CT,T,T,GT,G,C,A,A,T,G,GI have used this, but it prints every character vertically: /usr/bin/p

libgit2sharp: how to set multiple values with same key

how do I set multiple values for a config-key? Some sections supports multiple values:[remote "origin"] url = git@github.com:schacon/simplegit-progit.git fetch = +refs/heads/master:refs/remotes/origin/master fetch = +refs/heads/qa/*:refs/remotes/origin/qa/*Something like this is not working in

Using gstreamer plugins bad in android

I am trying to show h264 encodes streams inside an android application using the GStreamer SDK and Android NDK. My Android.mk looks like:LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE := AppLOCAL_SRC_FILES := App.cppLOCAL_SHARED_LIBRARIES := gstreamer_androidLOCAL_LDLIBS := -llog -

c++ - How To Return Elapsed Time From steady_clock as a Primitive Data Type (double)

First and foremost, let me say that I just starting using this library yesterday, so my understanding of it is still fairly basic. I'm trying to capture the FPS of a vision processing program I'm creating and output it to a screen using the chrono library. In my case, I need to cast the elapsed time

hashtable - Powershell 2 and .NET: Optimize for extremely large hash tables?

I am dabbling in Powershell and completely new to .NET.I am running a PS script that starts with an empty hash table. The hash table will grow to at least 15,000 to 20,000 entries. Keys of the hash table will be email addresses in string form, and values will be booleans. (I simply need to track whe

Missing plugin for GStreamer for Android SDK

I changed the stream url in the included Tutorial 5 (a basic media player) to a h.264/mp3 media stream (from its original ogv stream) and it started complaining about some missing plugins.After doing some googling I found Prajnashi's gst-ffmpeg plugin for Android https://github.com/prajnashi/gst-ffm

powershell - How to add key/value pair at the end of hash table?

I am trying to calculate code count using PowerShell script.I found a script on the Internet and am trying to add the total line at the end.I have added the column$CountHash.Add("Total", $Total)at the end.Param( [string]$path, [string]$outputFile, [string]$include = "*.*", [string]