GCC Toolchain Broken with undefined reference to xxx

I found that I was unable to compile anything significant with the default GCC toolchain on the Jetson TX2 with Jetpack 3.2.

I always got errors like

<artificial>:(.text+0x61c): undefined reference to `Network::Connection::Socket::~Socket()'

If your experiencing the same issue, it can be fixed with the following environment variables

export AR="gcc-ar"
export NM="gcc-nm"
export RANLIB="gcc-ranlib"

Thanks.

That would be a missing user space library unrelated to the GCC toolchain. You’ve compiled some object files, and now it is trying to find libraries to link against to satisfy external dependencies. The library with the dependency is not found.

You seem to be cross compiling, so your host PC won’t have cross (foreign) architecture user space in place. Typically cross compiling tools are divided up into three groups: Toolchain, sysroot, and runtime. Toolchain would be the binary executables, e.g., the compiler or linker. Runtime libraries are files a running application will need, e.g., libc for anything C or C++. Sysroot are the development version of files, including headers for anything linking against runtime.

Your PC lacks the runtime for your case. Cross tools rarely include anything except minimal libraries. Your project is using something with “Network::Connection::Socket”…this isn’t part of libc. You’ll need to install that somewhere in the runtime for aarch64/arm64. The toolchain is able to bring components together, but the component is missing.

For whatever you are compiling, if you were running natively on the Jetson, then you’d need some library package for the software to run. Before it compiled you’d need the “dev” or “devel” version of that package to provide the header files. On the host PC you need the same thing…except it needs to be marked as a foreign architecture instead of a native architecture so that your tools can find the files and so that your PC won’t try to use those for itself. Can you tell which library or package normally provides “Network::Connection::Socket”? One of the “#include” statements provides a prototype (for converting from ordinary source code to a “.o” object file), the library provides the actual code (for the linker to link against).