I have some problems following the Kaleidoscope JIT chapter tutorial.
I compile with: (just like the tutorial page advises)
clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native` -rdynamic -O3 -o toy
/tmp/toy-ce525d.o: In function `llvm::orc::LegacyIRCompileLayer<llvm::orc::LegacyRTDyldObjectLinkingLayer, llvm::orc::SimpleCompiler>::addModule(unsigned long, std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >)':
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h:93: undefined reference to `llvm::orc::SimpleCompiler::operator()(llvm::Module&)'
/tmp/toy-ce525d.o: In function `llvm::orc::LegacyRTDyldObjectLinkingLayer::ConcreteLinkedObject<std::shared_ptr<llvm::RuntimeDyld::MemoryManager> >::finalize()':
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h:237: undefined reference to `llvm::orc::JITSymbolResolverAdapter::JITSymbolResolverAdapter(llvm::orc::ExecutionSession&, llvm::orc::SymbolResolver&, llvm::orc::MaterializationResponsibility*)'
/tmp/toy-ce525d.o: In function `llvm::orc::JITSymbolResolverAdapter::~JITSymbolResolverAdapter()':
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:93: undefined reference to `vtable for llvm::orc::JITSymbolResolverAdapter'
/tmp/toy-ce525d.o: In function `KaleidoscopeJIT':
/home/user/Desktop/llvm/kaleidoscope/other/././KaleidoscopeJIT.h:45: undefined reference to `llvm::orc::ExecutionSession::ExecutionSession(std::shared_ptr<llvm::orc::SymbolStringPool>)'
/tmp/toy-ce525d.o: In function `llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::DenseSet> > llvm::orc::lookupWithLegacyFn<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}>(llvm::orc::ExecutionSession&, llvm::orc::AsynchronousSymbolQuery&, llvm::DenseMapInfo<llvm::DenseSet> const&, llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1})':
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:159: undefined reference to `llvm::orc::ExecutionSession::legacyFailQuery(llvm::orc::AsynchronousSymbolQuery&, llvm::Error)'
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:151: undefined reference to `llvm::orc::AsynchronousSymbolQuery::notifySymbolMetRequiredState(llvm::orc::SymbolStringPtr const&, llvm::JITEvaluatedSymbol)'
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:155: undefined reference to `llvm::orc::ExecutionSession::legacyFailQuery(llvm::orc::AsynchronousSymbolQuery&, llvm::Error)'
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:166: undefined reference to `llvm::orc::AsynchronousSymbolQuery::handleComplete()'
/tmp/toy-ce525d.o:(.rodata._ZTVN4llvm3orc22LegacyLookupFnResolverIZNS0_15KaleidoscopeJITC1EvEUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_EE[_ZTVN4llvm3orc22LegacyLookupFnResolverIZNS0_15KaleidoscopeJITC1EvEUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_EE]+0x30): undefined reference to `llvm::orc::SymbolResolver::anchor()'
LLVM project in version 10, clang++ in version 6.
$ uname -srmpo
Linux 4.15.0-72-generic x86_64 x86_64 GNU/Linux
$ clang++ --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ llvm-config --version
10.0.0git
PradeepKumar fixed the issue in the comment.
This command compiles the code:
clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native orcjit` -rdynamic -O3 -o toy
For those who are using the cmake build instructions I just had to add orcjit to llvm_map_components_to_libnames:
llvm_map_components_to_libnames(llvm_libs orcjit support core irreader)
Related
When try to the 2nd example https://octave.org/doc/v5.1.0/Standalone-Programs.html#Standalone-Programs I got the following error :
embedded.cc:(.text+0x132): undefined reference to `octave::feval(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, octave_value_list const&, int)'
The -d option of the mkoctfile provides the following two g++ commands, where the 1st one works fine.
g++ -std=gnu++11 -c -fPIC -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include/octave-5.1.0/octave/.. -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include/octave-5.1.0/octave -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include -pthread -fopenmp -fPIC embedded.cc -o /tmp/oct-EYDDih.o
and
g++ -std=gnu++11 -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include/octave-5.1.0/octave/.. -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include/octave-5.1.0/octave -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include -pthread -fopenmp -fPIC -rdynamic -fPIC -o embedded /tmp/oct-EYDDih.o -L/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/lib -L/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/lib/octave/5.1.0 -loctinterp -loctave
Any idea how to solve this ?
I found in the the root cause for this issue, there was an EDA tool (Cadence Xcelium) module loaded which let g++ point to its private version, when I replace g++ with /bin/g++ it works in my environment.
As mentioned in the cppkafka official GitHub in usage section.
If you want to use cppkafka, you'll need to link your application with:
cppkafka
rdkafka
I tried to compile example program mentioned in the README.md of the GitHub with
gcc -O3 -Wall test.cpp -std=c++11 -lrdkafka -lpthread -lz -lstdc++ -D_GLIBCXX_USE_CXX11_ABI=0 -lcppkafka
It is throwing with following error
test.cpp:(.text.startup+0x46): undefined reference to `cppkafka::ConfigurationOption::ConfigurationOption(std::string const&, char const*)'
test.cpp:(.text.startup+0xd9): undefined reference to `cppkafka::Buffer::Buffer(std::string const&)'
collect2: error: ld returned 1 exit status
No need of -D_GLIBCXX_USE_CXX11_ABI=0 option while compiling.
you can simply compile this as following
gcc -O3 -Wall test.cpp -std=c++11 -lrdkafka -lpthread -lz -lstdc++ -lcppkafka
I am trying to compile a simple program using clang++ under Eclipse CDT Kepler under Fedora. Below is a clang++ compilation log run within Eclipse.
If I enter at the command prompt 'clang++ ../src/Hello\ LLVM\ and\ Clang.cc' I get no errors. If I enter the Eclipse commands I do duplicate the linkage error messages.
Various SOs and the clang mailing list said that undefined references to std::??? are caused by using clang instead of clang++ as well as use libc++ instead of libstdc++. In the 3rd and 4th line, clang++ is used. In the 4th line, stdc++.
I am using the LLVM with Clang (Linux) Eclipse defined Tool Chain.
Interesting behavior is when I select Properties->C/C++ Build->Tool Chain Editor, I see LLVM with Clang (Linux) as the tool chain. If I select Linux GCC. When I go back to select from the list of Tool Chains, the LLMV with Clang (Linux) is gone! It would seem that the tool is not 'supported' but it seems to be supported. Curious.
What do I do to get clang++ to build under Eclipse CDT Kepler? The path to the libraries seems to be the key to the problem.
21:43:42 **** Rebuild of configuration Debug for project Hello LLVM and Clang ****
Info: Internal Builder is used for build
clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o "src/Hello LLVM and Clang.bc" "../src/Hello LLVM and Clang.cc"
clang++ -v -L/usr/lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib/ -o "Hello LLVM and Clang" "src/Hello LLVM and Clang.bc" -lstdc++
clang version 3.3 (tags/RELEASE_33/final)
Target: i386-redhat-linux-gnu
Thread model: posix
"/usr/bin/clang" -cc1 -triple i386-redhat-linux-gnu -emit-obj -mrelax-all -disable-free - disable-llvm-verifier -main-file-name "Hello LLVM and Clang.bc" -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu pentium4 -target-linker-version 2.23.2 -v -resource-dir /usr/bin/../lib/clang/3.3 -fdebug-compilation-dir "/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug" -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fdiagnostics-show-option -backend-option -vectorize-loops -o "/tmp/Hello LLVM and Clang-mT5CWp.o" -x ir "src/Hello LLVM and Clang.bc"
clang -cc1 version 3.3 based upon LLVM 3.3 default target i386-redhat-linux-gnu
"/usr/bin/ld" --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o "Hello LLVM and Clang" /usr/lib/gcc/i686-redhat-linux/4.8.2/../../../crt1.o /usr/lib/gcc/i686-redhat-linux/4.8.2/../../../crti.o /usr/lib/gcc/i686-redhat-linux/4.8.2/crtbegin.o -L/usr/lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib/ -L/usr/lib/gcc/i686-redhat-linux/4.8.2 -L/usr/lib/gcc/i686-redhat-linux/4.8.2/../../.. -L/lib -L/usr/lib "/tmp/Hello LLVM and Clang-mT5CWp.o" -lstdc++ -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i686-redhat-linux/4.8.2/crtend.o /usr/lib/gcc/i686-redhat-linux/4.8.2/../../../crtn.o
/tmp/Hello LLVM and Clang-mT5CWp.o: In function `main':
/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug/../src/Hello LLVM and Clang.cc:12: undefined reference to `std::cout'
/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug/../src/Hello LLVM and Clang.cc:13: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug/../src/Hello LLVM and Clang.cc:13: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug/../src/Hello LLVM and Clang.cc:13: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/tmp/Hello LLVM and Clang-mT5CWp.o: In function `__cxx_global_var_init':
/usr/lib/gcc/i686-redhat-linux/4.8.2/../../../../include/c++/4.8.2/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/lib/gcc/i686-redhat-linux/4.8.2/../../../../include/c++/4.8.2/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
21:43:44 Build Finished (took 1s.982ms)
I have a problem with compiling the example form LenMuse - this is the example.
I used flags from the provided tutorial and I added a few more to get rid of some other problems, but I can't solve all of them. This is my output from gcc:
/usr/lib/liblomse.so: undefined reference to `boost::thread::start_thread()'
/usr/lib/liblomse.so: undefined reference to `boost::thread::timed_join(boost::posix_time::ptime const&)'
/usr/lib/liblomse.so: undefined reference to `boost::this_thread::sleep(boost::posix_time::ptime const&)'
/usr/lib/liblomse.so: undefined reference to `boost::thread::~thread()'
This is the command I used:
gcc interface.cpp -o interface `pkg-config --cflags x11` `pkg-config --cflags liblomse` `pkg-config --libs liblomse` `pkg-config --libs x11` -lstdc++ -lboost_system -I/usr/include/boost/ -lboost_filesystem -lboost_thread
I tried to compile with the flag -lboost_thread-mt but gcc cannot find this flag.
I have boost 1.53.0, on the page author says that is required boost 1.43 or higher. My system is ArchLinux.
I solved this problem by downgrade boost library to version 1.49.0.
I tried to compile my c++/opengl-project with the g++ command.
(I need this since I want to recompile it on every target system with a second self-written program.)
But when I execute:
g++ -Iinclude -Isrc $(pkg-config --cflags freetype2) -L/usr/X11R6/lib -L/usr/lib $(pkg-config --libs glew) -lglut $(pkg-config --libs glu) $(pkg-config --libs freetype2) main.cpp (some more source files) src/Vec4.cpp
I get lots of 'undefined references' for gl/glu/glut/glew-functions, so I guess something fails with the libs:
/tmp/ccUm2dEl.o: In function `Box::render()':
Box.cpp:(.text+0x6e8): undefined reference to `glEnable'
Box.cpp:(.text+0x72c): undefined reference to `glBindTexture'
Box.cpp:(.text+0x736): undefined reference to `glBegin'
...
TextureManager.cpp:(.text+0x23b): undefined reference to `glTexParameteri'
TextureManager.cpp:(.text+0x295): undefined reference to `glTexImage2D'
collect2: ld gab 1 als Ende-Status zurück
I did some research, but according to what I found out the above command should be correct.
I checked the pkg-config-calls as well and they seem to work.
Before I tried the g++ command I used the Codeblocks IDE to compile it and it worked. Here are my settings:
In Compiler settings|Other options:
`pkg-config --cflags freetype2`
In Linker settings|Link libraries:
glut
In Linker settings|Other linker options:
`pkg-config --libs glu`
`pkg-config --libs glew`
`pkg-config --libs freetype2`
In Search directories|Compiler:
include
src
My system (Ubuntu Precise):
$ uname -a
Linux andromeda 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ g++ -dumpversion
4.6
glxinfo
GLX version: 1.4
OpenGL version string: 4.2.0 NVIDIA 304.43
Codeblocks-version: 10.04
Thanks in advice
The problem is most likely that you link in the wrong order. The GNU linker wants its libraries in kind of reverse order, so if you place the linker libraries last on the command line it should go better.