OpenUSD Build Error at 65%

Hello all! I am trying to build OpenUSD inside a docker container on a linux machine, and I have been getting many errors. I’m pretty sure I shouldn’t have had to fix anything so I probably did something wrong in setup, but I managed to fix most errors up until this one.

collect2: error: ld returned 1 exit status
gmake[2]: *** [pxr/usd/bin/sdffilter/CMakeFiles/sdffilter.dir/build.make:115: pxr/usd/bin/sdffilter/sdffilter] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:8444: pxr/usd/bin/sdffilter/CMakeFiles/sdffilter.dir/all] Error 2
[ 64%] Built target _ndr
[ 64%] Linking CXX shared library libusd_pcp.so
[ 65%] Built target pcp
[ 65%] Linking CXX shared library _sdf.so
[ 65%] Built target _sdf
gmake: *** [Makefile:136: all] Error 2

ERROR: Failed to run 'cmake --build . --config Release --target install -- -j32' in /usr/local/OpenUSD/build/build/OpenUSD.

I honestly have no idea what to do here. Regarding those gmake errors, in pxr/usd/bin/sdffilter/, there is no CMakeFiles directory. There are only CmakeLists.txt and sdfilter.cpp.

I’m pretty sure the build should work without my intervention, right? Any ideas why it’s giving me so many problems?

Yes, the build is intended to work without intervention. It’s hard to say what the problem is without seeing the error the linker encountered.

It might be worthwhile comparing your docker configuration to this one which is known to work:

Okay. I’ll try using that container and comparing.

Help me understand though, I thought the build_script first installs MaterialX and OpenSubdiv and any other dependencies OpenUSD has. Did I need to preinstall them, as I’m seeing in this repo, or is it supposed to work even without it all preinstalled.

And how do I use ci-usd to build usd? Do I need to clone the OpenUSD repo inside the running container from that image, and will that automatically make OpenUSD detect the preinstalled packages?

Yes, the build script installs any dependencies required, however, I’m not aware that people have tried to use it within a docker container, so it’s possible that additional configuration or corrections might be needed to allow build_usd.py to function in a docker container.

The container script I pointed to is the equivalent of build_usd.py but instead of using that build script, it explictly maps out the requirements. If you want to use that script directly, I suggest asking the authors of it on the ASWF slack, in the wg-ci channel, there’s a lot of expertise there. This invite link will get you in, if you are not already a member: Slack

Do you have more to your error higher up in the log? When you build, with the Python script, add the -vvv flag to be more verbose.

There’ll be a line higher up that will likely say “error” and an actual code line that is failing.

Do you know what compiler version is being used in your docker?

I have

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
cmake version 3.31.5
Python 3.9.21

log is attached.

log.txt (270.8 KB)

The log refers to line 115 in pxr/usd/bin/sdffilter/CMakeFiles/sdffilter.dir/build.make.

These are lines 113-115 in that file:

pxr/usd/bin/sdffilter/sdffilter: pxr/usd/bin/sdffilter/CMakeFiles/sdffilter.dir/link.txt
	@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --bold --progress-dir=/usr/local/OpenUSD/build/build/OpenUSD/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking CXX executable sdffilter"
	cd /usr/local/OpenUSD/build/build/OpenUSD/pxr/usd/bin/sdffilter && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/sdffilter.dir/link.txt --verbose=$(VERBOSE)

The link.txt file it refers to only contains this one line:

/usr/bin/c++  -Wall -Wformat-security -pthread -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-maybe-uninitialized  -O3 -DNDEBUG CMakeFiles/sdffilter.dir/sdffilter.cpp.o -o sdffilter   -L/usr/local/OpenUSD/build/lib  -Wl,-rpath,/usr/local/OpenUSD/build/build/OpenUSD/pxr/usd/sdf:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/pegtl:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/ts:/usr/local/OpenUSD/build/build/OpenUSD/pxr/usd/ar:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/vt:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/gf:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/plug:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/work:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/trace:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/js:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/tf:/usr/local/OpenUSD/build/build/OpenUSD/pxr/base/arch:/usr/local/OpenUSD/build/build/OpenUSD/pxr/external/boost/python:/usr/local/OpenUSD/build/build/OpenUSD/pxr/external/boost:/usr/local/OpenUSD/build/lib: ../../sdf/libusd_sdf.so ../../../base/pegtl/libusd_pegtl.so ../../../base/ts/libusd_ts.so ../../ar/libusd_ar.so ../../../base/vt/libusd_vt.so ../../../base/gf/libusd_gf.so ../../../base/plug/libusd_plug.so ../../../base/work/libusd_work.so ../../../base/trace/libusd_trace.so ../../../base/js/libusd_js.so ../../../base/tf/libusd_tf.so ../../../base/arch/libusd_arch.so -ldl -lm ../../../external/boost/python/libusd_python.so ../../../external/boost/libusd_boost.so -ltbb

I’m not an expert on linking, but it seems that the sdf package is not getting linked to the libusd library?

A search for any libusd files in my repo returns no results.

Thanks for that extra info.
I wonder if its because its compiling as PIE?
warning: creating DT_TEXTREL in a PIE

I’m not super familiar with GCC these days on Linux to comment. @asluk I wonder if anyone on your end has more familiarity here?

Looking at this SO assembly - Understanding a DT_TEXTREL warning - Stack Overflow it seems like one suggestion is adding --no-pie to the compiler flags, but I can’t imagine that would be required either since your Ubuntu version is ~3years old, so would have been caught by now as well.