How do I correctly build GCC on an ARM based device - c++

I got my self an ARM based development board (NVIDIA Jetson K1).
The thing is already equipped with Ubuntu system. I was able to use gcc 4.8 directly on the device, but it doesn't contain g++. Installing g++ with apt-get as usual wouldn't work because nobody ever bothered to maintain a complete ppa supporting ARM architecture.
Now I tried to compile the latest GCC manually. Everything went smooth when I compile and installed the requirements (MPC, MPFR, GMP). But I failed building GCC itself, and found out that the mad error in config.log telling me that a working C++ compiler can not be found.
I believe there must be a way to get a working g++ compiler working on the device itself rather than having to cross compile. Does anyone have a clue on how this can be done?

The message is right. GCC 4.8 is written in C++ so it needs to be compiled with a C++ (cross) compiler.

Related

SFML Undefined symbols for architecture arm64 [duplicate]

I have MacBook Air with m1 chip and tried to install SFML according to the instructions on the official website however I can not compile the project for example
enter image description here
EDIT: I moved the Xcode app act via rosetta 2 and now it works I would love to know if there is a solution that will activate it natively
The error you are receiving is telling you that the version being linked is for MacOS on x32_64, while trying to compile for arm64. This is incompatible, given they're two different platforms.
Are you compiling SFML from source? It doesn't look like SFML has precompiled binaries for MacOS-arm64, but the source code does have arm compatibility. Compiling from source would be operating system agnostic as long as everything is there (and supports arm64.) SFML has an article on how to compile from source with CMake: https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php
While I can't guarantee this will fix your issue, it's definitely worth a try if you haven't yet.
The reason using Rosetta made this work is because Rosetta emulates some parts of x32_64. Running these apps in Rosetta would essentially be the same as compiling your project on an Intel based Mac.
I found the solution if it can help some, just make your pc believe that you have an intel chip, by adding /usr/bin/arch -x86_64 before your order.
example:
/usr/bin/arch -x86_64 clang main.c -lcsfml-graphics -lcsfml-system

On Linux, what's the use of installing clang++ if it uses g++ libs only?

For C++ development on Linux, if I install clang and use it; it actually uses libstdc++(the g++ lib). What's the use of installing the frontend compiler clang on linux then?
I should be good with gcc/g++ only on a linux machine as that's a complete toolchain!
Note: I'm not an expert in C++.
libstdc++ is a default runtime on your Linux. libc++ is not installed by default. If you link your app to libc++, you have to add it as a runtime dependency.
You are right, gcc/g++ is good for Linux, moreover its diagnostic messages are more clear, thus the compiler is better for beginners. By using clang++, you need to know the C++ standard deeper, otherwise it's difficult to get an error reason.

Ubuntu to RHEL C++ cross-compilation (64bits)

Not exactly sure where this question belongs, let me know if I should move it.
Here is the issue; over the past years I have a put together a relatively large personal codebase in C++11 that I'm using for work, but my workplace runs supposedly the latest version of RHEL on their cluster, which runs gcc 4.4.7, which supports C++11 only partially.
I have battled to get a decent compiler installed, but apparently there is no easy way of making this happen, so instead I am wondering whether it would be possible to cross-compile C++11 sources on my own desktop, and export the executable on the cluster at my workplace. I just don't know where to start in order to do that:
Is it possible (and how) to cross-compile C++11 sources from Ubuntu to RHEL?
Since I am at it, is it possible to rebuild gcc 4.8 or a suitable libstdc++ (or libc++) entirely from Ubuntu to an rpm package compatible with RHEL?
(Note: I would preferably use clang (3.4) to compile on my desktop, but gcc (4.8) would be fine too.)

RedHat devtoolset - implications for distributing compiled code

I'm running CentOS 6.4 and need a later version of the C++ compiler to build my development tools (Qt Creator in this case).
I'm unclear on the implications of using devtools and I'm hoping someone can explain.
If I compile programs using devtools, does that means the executable will run on other Centos 6.4 installations without change?
Or..do I know have to ship libraries or other files with my compiled programs?
If so...do I have to modify my C++ code to reference the later libraries? or is this something done by the person installing my compiled program
I hope this somewhat late answer can still help you. What I found is that compiling my project with devtoolset (1.1 in my case, but that should not matter too much) on RHEL 6.4 produces binaries which can almost run on a standard RedHat EL 6.4 (should be similar for Centos 6.4).
The only trouble I ran into was compiling my project with -std=c++11, which produced some problems due to incompatible symbols. The reason is that the GCC folks considered these parts of the standard library to be experimental in GCC 4.4, so they broke ABI compatibility in some places.
Turns out, there's an easy fix: Link your programs with the additional command-line-argument -static-libstdc++. That way, the binary becomes a bit larger but is runs on an unmodified RHEL 6.4 without installing additional libraries/updates for the devtoolset.
To answer your questions explicitly:
Yes, almost.
No.
Don't change the code, just add -static-libstdc++ when linking.

./configure make make install on Windows with icc

I recently switched back to Windows7 (x64) because of perfomance issues with my graphics card on linux but i miss the abilty to easily compile open source software on Windows. I have a copy of the intel c compiler which is somewhat better than the gnu c compiler and i would like to use it to compile software written for linux.
I've already installed cygwin and managed to compile something. The 'make-install' didn't work though but that's another issue. Now my question is, how can i tell 'make' to use the windows intel compiler?
Most of the configure scripts you'll find in OSS have probably been created by the Autotools. Those should, basically, support the icc. To use it, although you may have GCC installed side-by-side, it would be necessary to set the environment variable CC to the (cygwin) path to Intel's C compiler and CXX to Intel's C++ compiler prior to running configure.
You may run into trouble with software packages that unconditionally set compiler flags that only GCC understands. I have heard, though, that, by now, icc actually implements most of these.
Update
Something similar has been asked before.