Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD] link error : undefined reference to `llvm::sys::getDefaultTargetTriple()' #1713

Open
nyue opened this issue Nov 27, 2023 · 18 comments
Open

Comments

@nyue
Copy link
Contributor

nyue commented Nov 27, 2023

Environment

Operating System: (e.g. Windows 2019, macOS-10.15, Linux CentOS 7.4)

Ubuntu 18.04

Version / Commit SHA: (e.g VDB 7.2, SHA: 1a2b3c4d5e...)

VDB 11.0.0
6c044e6

CMake Version: (e.g. 3.18)

cmake version 3.25.0

Compiler: (e.g. gcc 10, msvc 2019)

gcc (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0

Describe the problem

Link error
openvdb_ax/openvdb_ax/libopenvdb_ax.so.11.0.0: undefined reference to `llvm::sys::getDefaultTargetTriple()'

To Reproduce

#!/bin/sh                                                                                                                                                                                                                                  
rm -f CMakeCache.txt
export TBB_ROOT=$HOME/systems/TBB/2020.3.0
export BLOSC_ROOT=$HOME/systems/c-blosc/1.21.0
cmake \
    -D LLVM_DIR=$HOME/systems/llvm/10.0.1/lib/cmake \
    -D Boost_DIR=$HOME/systems/boost/1.81.0-py3.9/lib/cmake/Boost-1.81.0 \
    -D USE_AX=ON \
    -D OPENVDB_BUILD_AX=ON \
    -D OPENVDB_BUILD_VDB_AX=ON \
    -D OPENVDB_USE_DEPRECATED_ABI_9=ON \
    -D OPENVDB_BUILD_HOUDINI_PLUGIN=ON \
    -D CMAKE_INSTALL_PREFIX=$HOME/systems/openvdb/11.0.0 \
    -D CMAKE_BUILD_TYPE=Release \
    -G "Ninja" \
    ../openvdb-11.0.0

BTW I have tried with newer version of LLVM, same link errors

Cheers

@Idclip
Copy link
Contributor

Idclip commented Nov 27, 2023

Hey @nyue, can you try modifying the following in openvdb_ax/openvdb_ax/CMakeLists.txt:

if(found_LLVM)
set(LLVM_LIBS "LLVM")
else()
llvm_map_components_to_libnames(_llvm_libs
native core executionengine support mcjit passes)
set(LLVM_LIBS "${_llvm_libs}")
endif()

and simply remove the first branch to become:

llvm_map_components_to_libnames(_llvm_libs
    native core executionengine support mcjit passes)
set(LLVM_LIBS "${_llvm_libs}")

@nyue
Copy link
Contributor Author

nyue commented Nov 27, 2023

Still not working

image

nyue@head0:~/projects/OpenVDB/11.0.0/build$ ninja
[232/328] Linking CXX executable openvdb_cmd/vdb_ax/vdb_ax
FAILED: openvdb_cmd/vdb_ax/vdb_ax 
: && /usr/bin/c++ -O3 -DNDEBUG  openvdb_cmd/vdb_ax/CMakeFiles/vdb_ax.dir/main.cc.o -o openvdb_cmd/vdb_ax/vdb_ax -L/home/nyue/systems/TBB/2020.3.0/lib -Wl,-rpath,/home/nyue/systems/TBB/2020.3.0/lib:/home/nyue/projects/OpenVDB/11.0.0/build/openvdb_ax/openvdb_ax:/opt/sesi/hfs19.5.773/dsolib:/home/nyue/projects/OpenVDB/11.0.0/build/openvdb/openvdb:/home/nyue/systems/boost/1.81.0-py3.9/lib:  openvdb_ax/openvdb_ax/libopenvdb_ax.so.11.0.0  /opt/sesi/hfs19.5.773/dsolib/libjemalloc.so  openvdb/openvdb/libopenvdb.so.11.0.0  /home/nyue/systems/TBB/2020.3.0/lib/libtbb.so.2  /opt/sesi/hfs19.5.773/dsolib/libblosc.so  /usr/lib/x86_64-linux-gnu/libz.so  -pthread  /home/nyue/systems/boost/1.81.0-py3.9/lib/libboost_iostreams.so.1.81.0  /home/nyue/systems/llvm/10.0.1/lib/libLLVMMCJIT.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMExecutionEngine.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMRuntimeDyld.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMPasses.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMipo.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMInstrumentation.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMVectorize.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMIRReader.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMAsmParser.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMLinker.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMX86CodeGen.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMAsmPrinter.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMDebugInfoDWARF.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMCFGuard.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMGlobalISel.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMSelectionDAG.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMCodeGen.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMTarget.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMScalarOpts.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMAggressiveInstCombine.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMInstCombine.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMBitWriter.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMTransformUtils.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMAnalysis.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMProfileData.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMX86AsmParser.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMX86Desc.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMObject.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMMCParser.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMBitReader.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMCore.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMRemarks.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMBitstreamReader.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMTextAPI.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMX86Disassembler.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMMCDisassembler.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMMC.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMBinaryFormat.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMDebugInfoCodeView.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMDebugInfoMSF.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMX86Info.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMX86Utils.a  /home/nyue/systems/llvm/10.0.1/lib/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  /home/nyue/systems/llvm/10.0.1/lib/libLLVMDemangle.a && :
openvdb_ax/openvdb_ax/libopenvdb_ax.so.11.0.0: undefined reference to `llvm::sys::getDefaultTargetTriple()'
collect2: error: ld returned 1 exit status
[237/328] Building CXX object openvdb_houdini/openvdb_houdini/CMakeFiles/SOP_OpenVDB_Combine.dir/SOP_OpenVDB_Combine.cc.o
ninja: build stopped: subcommand failed.

@Idclip
Copy link
Contributor

Idclip commented Nov 28, 2023

Hey @nyue, thanks for trying that - I'm at a bit of a loss, the right libraries seem to be there. How did you install llvm? Could you also provide the full cmake configure and all ninja build output and I'll see if I can investigate.

@CeeGee
Copy link

CeeGee commented Dec 2, 2023

Hi, i had same error like @nyue , but its all working now, but i have sop_openvdb_ax error when i am staring houdini.
Houdini DSO error on '/root/houdini19.5/dso/SOP_OpenVDB_AX.so'
/root/houdini19.5/dso/SOP_OpenVDB_AX.so: undefined symbol: _ZTIN7openvdb9v9_1_sesi2ax7codegen8FunctionE

Building openvdb11 with ABI9, for houdini 19.5.773
Compile for openvdb, openvdb_ax, openvdb_cmd, and openvdb_houdini was fine.
I attached 2 txt file with compile output first openvdb core, openvdb_ax, and openvdb_cmd, and second houdini

openvdb-vdb_ax_compile_part01.txt
openvdb-vdb_ax_compile_part02.txt

@nyue
Copy link
Contributor Author

nyue commented Dec 2, 2023

@Idclip for the runtime link error that @CeeGee describe, would it help if OpenVDB build static libraries in addition to shared library and when building the Houdini plugin, it links with the static version.

This may alleviate the Houdini plugin from loading SESI's build of OpenVDB

@Idclip
Copy link
Contributor

Idclip commented Dec 3, 2023

Hi @CeeGee:

Hi, i had same error like @nyue , but its all working now

Good to hear, what was the problem in the end?

but i have sop_openvdb_ax error when i am staring houdini.
Houdini DSO error on '/root/houdini19.5/dso/SOP_OpenVDB_AX.so'
/root/houdini19.5/dso/SOP_OpenVDB_AX.so: undefined symbol: _ZTIN7openvdb9v9_1_sesi2ax7codegen8FunctionE

Houdini's version of OpenVDB does not include AX symbols or headers. So the fact that it's trying to find openvdb::v9_1_sesi::ax::codegen::Function at runtime to me means that when you compiled SOP_OpenVDB_AX, your build picked up the Houdini headers first instead of your local headers. The Houdini openvdb headers will export their openvdb namespace v9_1_sesi - if this is found first on the include path, it will cause SOP_OpenVDB_AX to look for v9_1_sesi symbols at runtime, which won't exist. For example, on MacOS H19.5.773:

 cat /Applications/Houdini/Current/Frameworks/Houdini.framework/Versions/19.5/Resources/toolkit/include/openvdb/version.h | grep OPENVDB_VERSION_NAME
    #define OPENVDB_VERSION_NAME v9_1_sesi
    #define OPENVDB_VERSION_NAME v9_1_sesi_abi9

@CeeGee - instead of doing two builds, could you try a single install of OpenVDB Core/Ax/Cmd/Houdini? And if that fails, could you send your CMakecommand and output and verbose make output (build with make VERBOSE=1).

@Idclip for the runtime link error that @CeeGee describe, would it help if OpenVDB build static libraries in addition to shared library and when building the Houdini plugin, it links with the static version.

@nyue - there actually shouldn't be any runtime clashing of libopenvdb and libopenvdb_sesi AFAIK. As mentioned above, both libraries export entirely different symbols; ours will export openvdb::vXX and Houdini's will export openvdb::vXX_sesi. So you can have both loaded at runtime without any problems. The important thing is to use the matching ABI and correct namespace at build time when building your plugins against OpenVDB and Houdini. Our CMake should be doing this but there may be a bug there

@CeeGee
Copy link

CeeGee commented Dec 3, 2023

Hi @Idclip
I think on my side was due some LLVM library, that i install on Ubuntu 22.04, at the end i reinstall system and used proper LLVM
I am new in compile world, i am more FX artist, but wanted to go more into vdbPoints, not just for caching heavy flip and wwater sim, but also to be able to use them in other section, that why i wanted to first test openVDB points for mantra
some examples you can find here, 1bil points render, raasterize 2.6bil voxels using vdbPoints and vdbrasterize
https://www.dropbox.com/scl/fo/a7gjdvy870bznyrfex1xw/h?rlkey=dftr1nzyl9ehxv91oscm40hys&dl=0

and then to explore VDB AX, and see how it can help and boost my current setups, and also to do some free tutorials on this topic, to show other artist how powerfull this can be, personaly think it bit under radar for most artists.
Here is single build and install:
01 - cmake command and also ouput from cmake with all -D options
02 - make and install, everything goes fine till 99%, then SOP_OpenVDB_AX.so some error and vdb_ax tool errors
after i copy all compiled files and when i start houdini i get for example
SOP_OpenVDB_From_Particles.so: undefined symbol: _ZN7openvdb9v11_0abi98GridBase15vecTypeToStringENS0_7VecTypeE
wich i dont get any of this if i compile separate

Hope this help, and sorry if i missed something.
Thanks a lot for help.

compile01.txt
compile02.txt

@Idclip
Copy link
Contributor

Idclip commented Dec 3, 2023

Thanks @CeeGee - I think I know whats going on. @nyue I also have a suspicion with regards to the undefined symbol issue with llvm::sys::getDefaultTargetTriple() from all the above info - see below.


@CeeGee - your main issue is that there are some conflicting installations of some libraries on your system (tbb, blosc, libz). We should be able to get around this by telling CMake to use the libraries from Houdini. Try adding the following to your CMake command:

-D Tbb_INCLUDE_DIR=/opt/hfs19.5.773/toolkit/include
-D TBB_LIBRARYDIR=/opt/hfs19.5.773/dsolib
-D DISABLE_CMAKE_SEARCH_PATHS=ON

You may need to manually provide the location of boost if CMake complains about that too:

 -DBoost_DIR=/usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/

I've also spotted the llvm::sys::getDefaultTargetTriple issue in your log too. See below to solve this one.


@nyue - I believe the the llvm::sys::getDefaultTargetTriple symbol issue is to do with GCC's dual ABI. This is a bit complex, but essentially there's an ABI difference with the version of std::string and std::list provided by your system and what Houdini 19.5 expects. OpenVDB uses the same ABI as Houdini, but a default build of LLVM will have used the systems ABI. llvm::sys::getDefaultTargetTriple returns a std::string, so the symbol differs between the OpenVDB build vs the system LLVM version.

We only use this in one place in libopenvdb_ax:

// This handles MARCH (i.e. we don't need to set it on the EngineBuilder)
M->setTargetTriple(llvm::sys::getDefaultTargetTriple());
llvm::Module* module = M.get();

Can you please try and replace llvm::sys::getDefaultTargetTriple() with LLVMGetDefaultTargetTriple() (the C variant). If it can't find the function, you may also need to include #include <llvm-c/TargetMachine.h> (but my tests worked without this).

@nyue
Copy link
Contributor Author

nyue commented Dec 4, 2023

@Idclip The use of LLVMGetDefaultTargetTriple() resolved my issues. I can build everything cleanly without errors on Ubuntu 18.04 + Houdini 19.5, thank you.

@Idclip Idclip linked a pull request Dec 4, 2023 that will close this issue
@CeeGee
Copy link

CeeGee commented Dec 4, 2023

Hi @Idclip
After your suggestion, everything compile without anyproblem, only one part of AX give me some warning
warning: type qualifiers ignored on cast result type [-Wignored-qualifiers] , you can see in txt file
compile03.txt

But after when i want to use openVDB sop plugins in houdini i get this error
/opt/hfs19.5.773/bin/houdini-bin: symbol lookup error: /home/user/houdini19.5/dso/SOP_OpenVDB_Create.so: undefined symbol: _ZN15openvdb_houdini18createVdbPrimitiveER9GU_DetailSt10shared_ptrIN7openvdb9v11_0abi98GridBaseEEPKc

Maybe i should reinstall my ubuntu 22.04, and tried install all librarys again.

@Idclip
Copy link
Contributor

Idclip commented Dec 4, 2023

@CeeGee you probably need to make sure libopenvdb_houdini.so is added to your runtime path, I don't think our CMake does that automatically. libopenvdb_houdini.so is installed into your Houdini lib folder. To check, in your log, you should see something like this:

-- Installing: /root/houdini19.5/lib/libopenvdb_houdini.so.11.0.0
-- Installing: /root/houdini19.5/lib/libopenvdb_houdini.so.11.0
-- Installing: /root/houdini19.5/lib/libopenvdb_houdini.so

So in this example, you should append /root/houdini19.5/lib to your LD_LIBRARY_PATH before launching Houdini. In a bash terminal, that would look like this:

> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/houdini19.5/lib/
> houdini

@CeeGee
Copy link

CeeGee commented Dec 4, 2023

@Idclip aaa yes i forgot about that part, to much compile, delete tests
Its all working now, but only VDB AX is crashing houdini, you add node, its all good, if you want to type some simple expresion, or use houdini_example scene from openvdb page, instant crash, you can see in txt file
compile04.txt

@Idclip
Copy link
Contributor

Idclip commented Dec 5, 2023

Hey @CeeGee, it looks like this issue with the dual ABI is more involved than I thought. I need to investigate this a bit more. There are two things you could try, but I haven't had a chance to test either yet, I'm hoping to this week:

  1. Install LLVM from source and build it with the old ABI using -D_GLIBCXX_USE_CXX11_ABI=0. For you, it would look something like this:
> git clone https://github.com/llvm/llvm-project.git llvm-project
> cd llvm-project/llvm
> git checkout llvmorg-13.0.0  # Chosen to build LLVM 13
> mkdir .build
> cd .build
# CMAKE_INSTALL_PREFIX will install it into a local `llvm-project/install` folder, as you probably don't want to install it to your system
# -D_GLIBCXX_USE_CXX11_ABI=0 is the important one - this builds with the compatible C++ ABI
> cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/../install -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" ..
> make install -j4

And then, when building VDB, add the path to your new compatible build:

cmake -DLLVM_DIR=<path/to/llvm>/install <rest of your commands>
  1. OR, try with Houdini 20! From Houdini 20 SideFX has support for both the old and new C++ ABI. For linux you'll see two install options for Houdini 20, one with GCC9.3, the other with GCC11.2. The ones with GCC11.2 will use the newer ABI, for example see the outlined ones below:
Screenshot 2023-12-05 at 21 59 26

I should note that we don't even have any tests with Houdini 20 yet so you may run into other issues with this approach.

@CeeGee
Copy link

CeeGee commented Dec 5, 2023

@Idclip Thanks a lot for all tips and guide informations, i will try and let you know.

@CeeGee
Copy link

CeeGee commented Dec 21, 2023

@Idclip and @nyue
Everything is working now, thanks a lot for all help.

@CeeGee
Copy link

CeeGee commented Dec 21, 2023

@Idclip One small question,
Where is good place to ask question about some houdini_openvdb_ax examples, google group or here on discussion tab.
For example i am trying to create flip preview with vdb ax. with color. Here is my vex vs vdb ax, i only miss color ramp, i tried but no luck for now
Thanks

vdb_ax_02

@Idclip
Copy link
Contributor

Idclip commented Dec 21, 2023

Hey @CeeGee, the discussion tab on github is the best place for these types of questions, or you can email the public OpenVDB email group too: openvdb-dev@lists.aswf.io

Interesting, I took a look and have it working for me, see below:

image

Although AX doesn't natively support ch and chramp expressions, the OpenVDB AX SOP in Houdini does support them! You won't be able to use those functions outside of Houdini, but I took a look at your VEX code and you should be able to use the identical VEX and parameter interface (including the ramp) on an AX SOP.

Let me know if you still can't get it to work

@CeeGee
Copy link

CeeGee commented Dec 21, 2023

@Idclip aaa yes its working now, maybe some type error on my side was problem.
I was just making preview setup for flip and wwater caches, and some simple solution how you can use vdb_ax to help
with vdbrasterize, to tweak data that you have in wwater caches and create new att based on age, faomdensity, speed...
so far works great. Thanks for helping.

vdb_ax_03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants