adding linker to command line - opencv

I am trying to compile a project and you can find the makefile at this link here https://dl.dropbox.com/u/95042389/Makefile
I have installed ANN and OpenCV 2.3.1.
When I type make, it is returning the errors given below.
sai#sai-HP-EliteBook-8460w:~/workspace/4pcs$ make
g++ -L/home/sai/workspace/OpenCV-2.4.1/lib -L/home/sai/workspace/ann_1.1.2/lib -L/usr/lib 4pcs.o 4pcs_test.o -o 4pcs -lopencv_highgui -lANN -o 4pcs
/usr/bin/ld: 4pcs.o: undefined reference to symbol 'cv::operator*(cv::Mat const&, cv::Mat const&)'
/usr/bin/ld: note: 'cv::operator*(cv::Mat const&, cv::Mat const&)' is defined in DSO /usr/lib/libopencv_core.so.2.3 so try adding it to the linker command line
/usr/lib/libopencv_core.so.2.3: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: * [4pcs] Error 1
Then I tried this
sai#sai-HP-EliteBook-8460w:~/workspace/4pcs$ echo $LD_LIBRARY_PATH
/usr/lib:/opt/ros/fuerte/lib:/opt/ros/fuerte/lib:/usr/lib/libopencv_core.2.3
Still the same errors..
Any suggestions?

It was solved by adding
-lopencv_core and then it worked with no errors.

Related

Linking LLVM-16 with Clang++ 16 when Compiling the Kaleidoscope examples with C++14 on Ubuntu 20.04 WSL2 Windows 10

I've tried with many versions of llvm, installed, uninstalled, the original tutorial code and the one with folders and a make file from: https://github.com/ghaiklor/llvm-kaleidoscope
(with adjustments).
The latest iteration and the best solution so far is with the original code and latest llvm:
https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.html
clang++ -g -O3 3.cpp -I /lib/llvm-16/include/ `llvm-config -std=c++14 --cxxflags --ldflags --system-libs --libs all --version` -v -o 3.exe
It seems it compiles, but the linker complains for "undefined references" to probably all llvm files.
llvm-config reports a location of the libraries, in /usr/lib/... as shown below; I found the libs also in root /lib/llvm-16/lib if that could cause some conflict, but I doubt that.
clang++ --version
Ubuntu clang version 16.0.0 (++20230109052936+64f06dda87cf-1~exp1~20230109173029.503)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
llvm-config --libdir
/usr/lib/llvm-16/lib
ls /usr/lib/llvm-16/lib
LLVMPolly.so libLLVMDlltoolDriver.a libLLVMPowerPCCodeGen.a
LLVMgold.so libLLVMExecutionEngine.a libLLVMPowerPCDesc.a
clang libLLVMExegesis.a libLLVMPowerPCDisassembler.a
cmake libLLVMExegesisAArch64.a libLLVMPowerPCInfo.a
libLLVM-16.0.0.so libLLVMExegesisMips.a libLLVMProfileData.a
libLLVM-16.0.0.so.1 libLLVMExegesisPowerPC.a libLLVMRISCVAsmParser.a
libLLVM-16.so libLLVMExegesisX86.a libLLVMRISCVCodeGen.a
libLLVM-16.so.1 libLLVMExtensions.a libLLVMRISCVDesc.a
libLLVM.so libLLVMFileCheck.a libLLVMRISCVDisassembler.a
libLLVMAArch64AsmParser.a libLLVMFrontendHLSL.a libLLVMRISCVInfo.a
libLLVMAArch64CodeGen.a libLLVMFrontendOpenACC.a libLLVMRISCVTargetMCA.a
libLLVMAArch64Desc.a libLLVMFrontendOpenMP.a libLLVMRemarks.a
libLLVMAArch64Disassembler.a libLLVMFuzzMutate.a libLLVMRuntimeDyld.a
libLLVMAArch64Info.a libLLVMFuzzerCLI.a libLLVMScalarOpts.a
libLLVMAArch64Utils.a libLLVMGlobalISel.a libLLVMSelectionDAG.a
libLLVMAMDGPUAsmParser.a libLLVMHexagonAsmParser.a libLLVMSparcAsmParser.a
libLLVMAMDGPUCodeGen.a libLLVMHexagonCodeGen.a libLLVMSparcCodeGen.a
libLLVMAMDGPUDesc.a libLLVMHexagonDesc.a libLLVMSparcDesc.a
libLLVMAMDGPUDisassembler.a libLLVMHexagonDisassembler.a libLLVMSparcDisassembler.a
libLLVMAMDGPUInfo.a libLLVMHexagonInfo.a libLLVMSparcInfo.a
libLLVMAMDGPUTargetMCA.a libLLVMIRPrinter.a libLLVMSupport.a
libLLVMAMDGPUUtils.a libLLVMIRReader.a libLLVMSymbolize.a
libLLVMARMAsmParser.a libLLVMInstCombine.a libLLVMSystemZAsmParser.a
libLLVMARMCodeGen.a libLLVMInstrumentation.a libLLVMSystemZCodeGen.a
libLLVMARMDesc.a libLLVMInterfaceStub.a libLLVMSystemZDesc.a
libLLVMARMDisassembler.a libLLVMInterpreter.a libLLVMSystemZDisassembler.a
libLLVMARMInfo.a libLLVMJITLink.a libLLVMSystemZInfo.a
libLLVMARMUtils.a libLLVMLTO.a libLLVMTableGen.a
libLLVMAVRAsmParser.a libLLVMLanaiAsmParser.a libLLVMTableGenGlobalISel.a
libLLVMAVRCodeGen.a libLLVMLanaiCodeGen.a libLLVMTarget.a
libLLVMAVRDesc.a libLLVMLanaiDesc.a libLLVMTargetParser.a
libLLVMAVRDisassembler.a libLLVMLanaiDisassembler.a libLLVMTextAPI.a
libLLVMAVRInfo.a libLLVMLanaiInfo.a libLLVMTransformUtils.a
libLLVMAggressiveInstCombine.a libLLVMLibDriver.a libLLVMVEAsmParser.a
libLLVMAnalysis.a libLLVMLineEditor.a libLLVMVECodeGen.a
libLLVMAsmParser.a libLLVMLinker.a libLLVMVEDesc.a
libLLVMAsmPrinter.a libLLVMM68kAsmParser.a libLLVMVEDisassembler.a
libLLVMBOLTCore.a libLLVMM68kCodeGen.a libLLVMVEInfo.a
libLLVMBOLTPasses.a libLLVMM68kDesc.a libLLVMVectorize.a
libLLVMBOLTProfile.a libLLVMM68kDisassembler.a libLLVMWebAssemblyAsmParser.a
libLLVMBOLTRewrite.a libLLVMM68kInfo.a libLLVMWebAssemblyCodeGen.a
libLLVMBOLTRuntimeLibs.a libLLVMMC.a libLLVMWebAssemblyDesc.a
libLLVMBOLTTargetAArch64.a libLLVMMCA.a libLLVMWebAssemblyDisassembler.a
libLLVMBOLTTargetX86.a libLLVMMCDisassembler.a libLLVMWebAssemblyInfo.a
libLLVMBOLTUtils.a libLLVMMCJIT.a libLLVMWebAssemblyUtils.a
libLLVMBPFAsmParser.a libLLVMMCParser.a libLLVMWindowsDriver.a
libLLVMBPFCodeGen.a libLLVMMIRParser.a libLLVMWindowsManifest.a
libLLVMBPFDesc.a libLLVMMSP430AsmParser.a libLLVMX86AsmParser.a
libLLVMBPFDisassembler.a libLLVMMSP430CodeGen.a libLLVMX86CodeGen.a
libLLVMBPFInfo.a libLLVMMSP430Desc.a libLLVMX86Desc.a
libLLVMBinaryFormat.a libLLVMMSP430Disassembler.a libLLVMX86Disassembler.a
libLLVMBitReader.a libLLVMMSP430Info.a libLLVMX86Info.a
libLLVMBitWriter.a libLLVMMipsAsmParser.a libLLVMX86TargetMCA.a
libLLVMBitstreamReader.a libLLVMMipsCodeGen.a libLLVMXCoreCodeGen.a
libLLVMCFGuard.a libLLVMMipsDesc.a libLLVMXCoreDesc.a
libLLVMCFIVerify.a libLLVMMipsDisassembler.a libLLVMXCoreDisassembler.a
libLLVMCodeGen.a libLLVMMipsInfo.a libLLVMXCoreInfo.a
libLLVMCore.a libLLVMNVPTXCodeGen.a libLLVMXRay.a
libLLVMCoroutines.a libLLVMNVPTXDesc.a libLLVMipo.a
libLLVMCoverage.a libLLVMNVPTXInfo.a libLTO.so
libLLVMDWARFLinker.a libLLVMObjCARCOpts.a libLTO.so.16
libLLVMDWP.a libLLVMObjCopy.a libPolly.a
libLLVMDebugInfoCodeView.a libLLVMObject.a libPollyISL.a
libLLVMDebugInfoDWARF.a libLLVMObjectYAML.a libRemarks.so
libLLVMDebugInfoGSYM.a libLLVMOption.a libRemarks.so.16
libLLVMDebugInfoLogicalView.a libLLVMOrcJIT.a libclang-16.so.1
libLLVMDebugInfoMSF.a libLLVMOrcShared.a libclang-cpp.so.16
libLLVMDebugInfoPDB.a libLLVMOrcTargetProcess.a libclang.so.1
libLLVMDebuginfod.a libLLVMPasses.a liblldb.so.1
libLLVMDemangle.a libLLVMPerfJITEvents.a liblldbIntelFeatures.so.16
libLLVMDiff.a libLLVMPowerPCAsmParser.a
Get various configuration information needed to compile programs which use
LLVM. Typically called from 'configure' scripts. Examples:
llvm-config --cxxflags
llvm-config --ldflags
llvm-config --libs engine bcreader scalaropts
Options:
--assertion-mode Print assertion mode of LLVM tree (ON or OFF).
--bindir Directory containing LLVM executables.
--build-mode Print build mode of LLVM tree (e.g. Debug or Release).
--build-system Print the build system used to build LLVM (e.g. `cmake` or `gn`).
--cflags C compiler flags for files that include LLVM headers.
--cmakedir Directory containing LLVM CMake modules.
--components List of all possible components.
--cppflags C preprocessor flags for files that include LLVM headers.
--cxxflags C++ compiler flags for files that include LLVM headers.
--has-rtti Print whether or not LLVM was built with rtti (YES or NO).
--help Print a summary of llvm-config arguments.
--host-target Target triple used to configure LLVM.
--ignore-libllvm Ignore libLLVM and link component libraries instead.
--includedir Directory containing LLVM headers.
--ldflags Print Linker flags.
--libdir Directory containing LLVM libraries.
--libfiles Fully qualified library filenames for makefile depends.
--libnames Bare library names for in-tree builds.
--libs Libraries needed to link against LLVM components.
--link-shared Link the components as shared libraries.
--link-static Link the component libraries statically.
--obj-root Print the object root used to build LLVM.
--prefix Print the installation prefix.
--shared-mode Print how the provided components can be collectively linked (`shared` or `static`).
--system-libs System Libraries needed to link against LLVM components.
--targets-built List of all targets currently built.
--version Print LLVM version.
Typical components:
all All LLVM libraries (default).
engine Either a native JIT or a bitcode interpreter.
Ubuntu clang version 16.0.0 (++20230109052936+64f06dda87cf-1~exp1~20230109173029.503)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;#m64
Selected multilib: .;#m64
"/usr/lib/llvm-16/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name 3.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/mnt/z/c -resource-dir /usr/lib/llvm-16/lib/clang/16 -I /lib/llvm-16/include/ -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -fdeprecated-macro -fdebug-compilation-dir=/mnt/z/c -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/3-9b8468.o -x c++ 3.cpp
clang -cc1 version 16.0.0 based upon LLVM 16.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/lib/llvm-16/include
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward
/usr/lib/llvm-16/lib/clang/16/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
"/usr/bin/ld" -pie -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o 82-14 /lib/x86_64-linux-gnu/Scrt1.o /lib/x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/3-9b8468.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-linux-gnu/9/crtendS.o /lib/x86_64-linux-gnu/crtn.o
/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x25
/tmp/3-9b8468.o: in function `main':
3.cpp:(.text+0x26f): undefined reference to `llvm::LLVMContext::LLVMContext()'
/usr/bin/ld: 3.cpp:(.text+0x28a): undefined reference to `llvm::LLVMContext::~LLVMContext()'
/usr/bin/ld: 3.cpp:(.text+0x2c0): undefined reference to `llvm::Module::Module(llvm::StringRef, llvm::LLVMContext&)'/usr/bin/ld: 3.cpp:(.text+0x2db): undefined reference to `llvm::Module::~Module()'
/usr/bin/ld: 3.cpp:(.text+0x34b): undefined reference to `vtable for llvm::ConstantFolder'
/usr/bin/ld: 3.cpp:(.text+0x35a): undefined reference to `vtable for llvm::IRBuilderDefaultInserter'
/usr/bin/ld: 3.cpp:(.text+0x384): undefined reference to `llvm::IRBuilderDefaultInserter::~IRBuilderDefaultInserter()'
/usr/bin/ld: 3.cpp:(.text+0x38d): undefined reference to `llvm::IRBuilderFolder::~IRBuilderFolder()'
/usr/bin/ld: 3.cpp:(.text+0x5b7): undefined reference to `llvm::errs()'
/usr/bin/ld: 3.cpp:(.text+0x5c9): undefined reference to `llvm::Function::print(llvm::raw_ostream&, llvm::AssemblyAnnotationWriter*, bool, bool) const'
/usr/bin/ld: 3.cpp:(.text+0x5df): undefined reference to `llvm::Function::eraseFromParent()'
/usr/bin/ld: 3.cpp:(.text+0x61d): undefined reference to `llvm::errs()'
/usr/bin/ld: 3.cpp:(.text+0x62f): undefined reference to `llvm::Function::print(llvm::raw_ostream&, llvm::AssemblyAnnotationWriter*, bool, bool) const'
/usr/bin/ld: 3.cpp:(.text+0x705): undefined reference to `llvm::errs()'
/usr/bin/ld: 3.cpp:(.text+0x717): undefined reference to `llvm::Function::print(llvm::raw_ostream&, llvm::AssemblyAnnotationWriter*, bool, bool) const'
/usr/bin/ld: 3.cpp:(.text+0x760): undefined reference to `llvm::errs()'
/usr/bin/ld: 3.cpp:(.text+0x772): undefined reference to `llvm::Module::print(llvm::raw_ostream&, llvm::AssemblyAnnotationWriter*, bool, bool) const'
/usr/bin/ld: /tmp/3-9b8468.o: in function `(anonymous namespace)::FunctionAST::codegen()':
3.cpp:(.text+0xb94): undefined reference to `llvm::Module::getFunction(llvm::StringRef) const'
/usr/bin/ld: 3.cpp:(.text+0xbee): undefined reference to `llvm::BasicBlock::BasicBlock(llvm::LLVMContext&, llvm::Twine const&, llvm::Function*, llvm::BasicBlock*)'
/usr/bin/ld: 3.cpp:(.text+0xc5e): undefined reference to `llvm::Function::BuildLazyArguments() const'
/usr/bin/ld: 3.cpp:(.text+0xc78): undefined reference to `llvm::Function::BuildLazyArguments() const'
/usr/bin/ld: 3.cpp:(.text+0xcc1): undefined reference to `llvm::Value::getName() const'
/usr/bin/ld: 3.cpp:(.text+0xd89): undefined reference to `llvm::verifyFunction(llvm::Function const&, llvm::raw_ostream*)'
/usr/bin/ld: 3.cpp:(.text+0xd95): undefined reference to `llvm::Function::eraseFromParent()'
/usr/bin/ld: /tmp/3-9b8468.o: in function `(anonymous namespace)::CallExprAST::codegen()':
3.cpp:(.text+0x1e41): undefined reference to `llvm::Module::getFunction(llvm::StringRef) const'
/usr/bin/ld: /tmp/3-9b8468.o: in function `(anonymous namespace)::NumberExprAST::codegen()':
3.cpp:(.text+0x2153): undefined reference to `llvm::detail::IEEEFloat::IEEEFloat(double)'
/usr/bin/ld: 3.cpp:(.text+0x2158): undefined reference to `llvm::APFloatBase::IEEEdouble()'
/usr/bin/ld: 3.cpp:(.text+0x2166): undefined reference to `llvm::APFloat::Storage::Storage(llvm::detail::IEEEFloat, llvm::fltSemantics const&)'
/usr/bin/ld: 3.cpp:(.text+0x2170): undefined reference to `llvm::detail::IEEEFloat::~IEEEFloat()'
/usr/bin/ld: 3.cpp:(.text+0x217d): undefined reference to `llvm::ConstantFP::get(llvm::LLVMContext&, llvm::APFloat const&)'
/usr/bin/ld: 3.cpp:(.text+0x218a): undefined reference to `llvm::APFloatBase::PPCDoubleDouble()'
/usr/bin/ld: 3.cpp:(.text+0x2197): undefined reference to `llvm::detail::IEEEFloat::~IEEEFloat()'
/usr/bin/ld: 3.cpp:(.text+0x21dc): undefined reference to `llvm::detail::IEEEFloat::~IEEEFloat()'
/usr/bin/ld: /tmp/3-9b8468.o: in function `(anonymous namespace)::BinaryExprAST::codegen()':
3.cpp:(.text+0x2393): undefined reference to `llvm::IRBuilderBase::CreateFCmpHelper(llvm::CmpInst::Predicate, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::MDNode*, bool)'
/usr/bin/ld: 3.cpp:(.text+0x23ad): undefined reference to `llvm::Type::getDoubleTy(llvm::LLVMContext&)'
/usr/bin/ld: 3.cpp:(.text+0x23ec): undefined reference to `llvm::IRBuilderBase::CreateConstrainedFPCast(unsigned int, llvm::Value*, llvm::Type*, llvm::Instruction*, llvm::Twine const&, llvm::MDNode*, std::optional<llvm::RoundingMode>, std::optional<llvm::fp::ExceptionBehavior>)'
/usr/bin/ld: /tmp/3-9b8468.o: in function `(anonymous namespace)::PrototypeAST::codegen()':
3.cpp:(.text+0x2467): undefined reference to `llvm::Type::getDoubleTy(llvm::LLVMContext&)'
/usr/bin/ld: 3.cpp:(.text+0x2504): undefined reference to `llvm::Type::getDoubleTy(llvm::LLVMContext&)'
/usr/bin/ld: 3.cpp:(.text+0x251b): undefined reference to `llvm::FunctionType::get(llvm::Type*, llvm::ArrayRef<llvm::Type*>, bool)'
/usr/bin/ld: 3.cpp:(.text+0x253b): undefined reference to `llvm::User::operator new(unsigned long)'
/usr/bin/ld: 3.cpp:(.text+0x2558): undefined reference to `llvm::Function::Function(llvm::FunctionType*, llvm::GlobalValue::LinkageTypes, unsigned int, llvm::Twine const&, llvm::Module*)'
/usr/bin/ld: 3.cpp:(.text+0x2570): undefined reference to `llvm::Function::BuildLazyArguments() const'
/usr/bin/ld: 3.cpp:(.text+0x2588): undefined reference to `llvm::Function::BuildLazyArguments() const'
/usr/bin/ld: 3.cpp:(.text+0x25ce): undefined reference to `llvm::Value::setName(llvm::Twine const&)'
/usr/bin/ld: 3.cpp:(.text+0x2614): undefined reference to `llvm::User::operator delete(void*)'
/usr/bin/ld: /tmp/3-9b8468.o: in function `std::unique_ptr<llvm::LLVMContext, std::default_delete<llvm::LLVMContext> >::~unique_ptr()':
3.cpp:(.text._ZNSt10unique_ptrIN4llvm11LLVMContextESt14default_deleteIS1_EED2Ev[_ZNSt10unique_ptrIN4llvm11LLVMContextESt14default_deleteIS1_EED2Ev]+0x13): undefined reference to `llvm::LLVMContext::~LLVMContext()'
/usr/bin/ld: /tmp/3-9b8468.o: in function `std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >::~unique_ptr()':
3.cpp:(.text._ZNSt10unique_ptrIN4llvm6ModuleESt14default_deleteIS1_EED2Ev[_ZNSt10unique_ptrIN4llvm6ModuleESt14default_deleteIS1_EED2Ev]+0x13): undefined reference to `llvm::Module::~Module()'
/usr/bin/ld: /tmp/3-9b8468.o: in function `std::unique_ptr<llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>, std::default_delete<llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter> > >::~unique_ptr()':
(...) etc.
/usr/bin/ld: 3.cpp:(.text._ZN4llvm13IRBuilderBase9CreateRetEPNS_5ValueE[_ZN4llvm13IRBuilderBase9CreateRetEPNS_5ValueE]+0x7b): undefined reference to `llvm::Instruction::setMetadata(unsigned int, llvm::MDNode*)'
/usr/bin/ld: 3.cpp:(.text._ZN4llvm13IRBuilderBase9CreateRetEPNS_5ValueE[_ZN4llvm13IRBuilderBase9CreateRetEPNS_5ValueE]+0x9e): undefined reference to `llvm::User::operator delete(void*)'
/usr/bin/ld: /tmp/3-9b8468.o:(.data+0x0): undefined reference to `llvm::DisableABIBreakingChecks'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas? Thanks.
The solution was to start a fresh WSL instance... :) In the new one it started compiling.
One more note, for the parts of the tutorial having an "extern printd()" such as part 6 etc., if using clang++ as suggested, add "-Wl,--export-dynamic" to the clang++ part of the command line, otherwise the extern printd() function couldn't be resolved.
A specific call for my case (however I don't use the folder structure from the example which is ../include/KaleidoscopeJIT.h from the repository, I copied only this file to the current directory):
clang++ -g 6.cpp -I KaleidoscopeJIT.h -Wl,--export-dynamic $(llvm-co
nfig --cxxflags --ldflags --system-libs --libs core orcjit native ) -O3 -o 62
./62
ready> extern printd(x);
ready> Read extern: declare double #printd(double)
ready> printd(1)
ready> ;
1.000000
Evaluated to 0.000000

undefined reference to raspicam

i have faced some error in camera initialization in geany compiler
g++ $(pkg-config opencv4 --cflags --libs) -o g++ $(pkg-config raspicam --cflags --libs) -o cameratest cameratest.cpp (in directory: /home/pi/Desktop)
/usr/bin/ld: /tmp/cc3JiNr2.o: in function `main':
cameratest.cpp:(.[text+0x14): undefined reference to `raspicam::RaspiCam_Cv::RaspiCam_Cv()'
/usr/bin/ld: cameratest.cpp:(.text+0x3c): undefined reference to `raspicam::RaspiCam_Cv::open()'
/usr/bin/ld: cameratest.cpp:(.text+0x9c): undefined reference to `raspicam::RaspiCam_Cv::getId[abi:cxx11]() const'
/usr/bin/ld: cameratest.cpp:(.text+0xd8): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
/usr/bin/ld: cameratest.cpp:(.text+0x108): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
collect2: error: ld returned 1 exit status
Compilation failed.

/usr/bin/ld: cannot find -lvtkRenderingOpenGL

Errors << apriltag_ros:make /home/ravinspect/catkin_ws/logs/apriltag_ros/build.make.001.log
/usr/bin/ld: cannot find -lvtkRenderingOpenGL
/usr/bin/ld: cannot find -lvtkImagingHybrid
/usr/bin/ld: cannot find -lvtkIOImage
/usr/bin/ld: cannot find -lvtkCommonTransforms
/usr/bin/ld: cannot find -lvtkCommonExecutionModel
/usr/bin/ld: cannot find -lvtkDICOMParser
/usr/bin/ld: cannot find -lvtkIOCore
/usr/bin/ld: cannot find -lvtkImagingColor
/usr/bin/ld: cannot find -lvtkRenderingContext2D
/usr/bin/ld: cannot find -lvtkRenderingGL2PS
/usr/bin/ld: cannot find -lvtkRenderingContextOpenGL
/usr/bin/ld: cannot find -lvtkRenderingLabel
collect2: error: ld returned 1 exit status
make[2]: ***
[/home/ravinspect/catkin_ws/devel/.private/apriltag_ros/lib/libapriltag_ros_common.so]
Error 1
make[1]: *** [CMakeFiles/apriltag_ros_common.dir/all] Error 2
I want to build a workspace with catkin build but i am taking this error while building workspace. I tried bunch of solutions but still i am taking this error.
Can anyone help me with this?
First install
sudo apt install libvtk5-dev
and then remove opencv and reinstall will solve the issue

Opencv linker error while cross-compiling the sample cpp (libopencv_calib3d.so: could not read symbols)

I am trying to cross compile a sample OpenCV cpp code for my beaglebone which has a ARM Cortex A8 based AM3359 processor. However when I start the cross-compiling I get the following error:
/usr/local/lib/libopencv_calib3d.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
It seems like a linker error. I am pretty sure that there is nothing wrong with libopencv_calib3d.so. Because when I compile the program for my PC, everything works fine. Therefore maybe the problem is with the method that I am using for cross compiling. Here is what I do:
I wrote a script in the name of compile_opencvarm.sh:
echo "Cross-Compiling $1"
if [[ $1 == *.c ]]
then
arm-linux-gnueabi-gcc -ggdb `pkg-config --cflags opencv` -o `basename $1 .c` $1 `pkg-config --libs opencv`;
elif [[ $1 == *.cpp ]]
then
arm-linux-gnueabi-g++ -ggdb `pkg-config --cflags opencv` -o `basename $1 .cpp` $1 `pkg-config --libs opencv`;
else
echo "Please compile only .c or .cpp files with this script"
fi
echo "Cross-Compiled Output => ${1%.*}"
and then added it to bashrc:
alias opencv_arm="~/.compile_opencvarm.sh"
Now when I do:
root#ghostrider:/home/zero/Desktop# opencv_arm peopledetect.cpp
Cross-Compiling peopledetect.cpp
/usr/local/lib/libopencv_calib3d.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
Cross-Compiled Output => peopledetect
Only difference with compiling script and cross-compiling script is that I used arm-linux-gnueabi prefix in the cross-compiling script. When I only compile the cpp file:
root#ghostrider:/home/zero/Desktop# opencv peopledetect.cpp
compiling peopledetect.cpp
Output file => peopledetect
Everything is OK. Program is executable.
Now what do you think my problem is? Is it a linker error or is it related to my cross-compiling process?
Regards
edit: Oh, now I noticed that I did not install arm-based cross libraries before the arm-linux-gnueabi compiler used them. So I installed them with:
sudo xapt -a armel -m libv4l-dev libgtk2.0-dev libcv-dev libcvaux-dev libhighgui-dev
and edited the script as following:
arm-linux-gnueabi-g++ -ggdb `arm-linux-gnueabi-pkg-config --cflags opencv` -o `basename $1 .cpp` $1 `arm-linux-gnueabi-pkg-config --libs opencv`;
But now I get the problem:
root#ghostrider:/home/zero/Desktop# opencv_arm peopledetect.cpp
compiling peopledetect.cpp
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/bin/ld: warning: liblapack.so.3gf, needed by /usr/arm-linux-gnueabi/lib/libcxcore.so, not found (try using -rpath or -rpath-link)
/tmp/ccDzUCLJ.o: In function `main':
/home/zero/Desktop/peopledetect.cpp:49: undefined reference to `cv::HOGDescriptor::setSVMDetector(cv::_InputArray const&)'
/home/zero/Desktop/peopledetect.cpp:84: undefined reference to `cv::HOGDescriptor::detectMultiScale(cv::Mat const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, cv::Size_<int>, cv::Size_<int>, double, double, bool) const'
/tmp/ccDzUCLJ.o: In function `cv::Mat::operator=(cv::Mat const&)':
/usr/include/opencv2/core/mat.hpp:317: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
/tmp/ccDzUCLJ.o: In function `cv::Mat::release()':
/usr/include/opencv2/core/mat.hpp:382: undefined reference to `cv::Mat::deallocate()'
/tmp/ccDzUCLJ.o: In function `_InputArray<float>':
/usr/include/opencv2/core/mat.hpp:1108: undefined reference to `vtable for cv::_InputArray'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgelsd_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dpotrf_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dpotri_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dsyevr_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgesv_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dpotrs_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgetri_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgels_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgesv_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgetrf_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgetrf_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgels_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `spotrf_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgelsd_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgesdd_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `spotri_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `ssyevr_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgesdd_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `spotrs_'
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgetri_'
collect2: ld returned 1 exit status
Output file => peopledetect
I solved my problem by cross-compiling all the OpenCV libraries by following this guide: http://processors.wiki.ti.com/index.php/Building_OpenCV_for_ARM_Cortex-A8
I followed this guide but "lnclude/opencv2" directory in the root of opencv distributive is empty after the building. So in fact i have libraries but dont have headers. What am i doing wrong?
UPD: I should be a little more careful, all answers in http://processors.wiki.ti.com/index.php/Building_OpenCV_for_ARM_Cortex-A8

Compile Link LUA5.1 Lib. Error in dev-cpp

this is my dev-cpp compiler log:
rm -f main.o luaTest.exe'
gcc.exe -c main.c -o main.o -I"E:/Dev-Cpp/include" -I"E:/Lua/5.1/include"'
gcc.exe main.o -o "luaTest.exe" -L"E:/Dev-Cpp/lib" -L "E:/lua/5.1/lua5.1.lib"'
main.o(.text+0x34):main.c: undefined reference to 'luaL_newstate'
main.o(.text+0x48):main.c: undefined reference to 'luaL_openlibs'
main.o(.text+0xab):main.c: undefined reference to 'luaL_loadbuffer'
main.o(.text+0xd5):main.c: undefined reference to 'lua_pcall'
main.o(.text+0x11c):main.c: undefined reference to 'lua_tolstring'
main.o(.text+0x14e):main.c: undefined reference to 'lua_settop'
main.o(.text+0x161):main.c: undefined reference to 'lua_close'
collect2: ld returned 1 exit status'
make.exe: *** [luaTest.exe] Error 1'
I can compiling & linking my code success with code::blocks. I can't figure out what's wrong with dev-cpp.
The linking step looks off. The option -L (uppercase L) sets a search directory for libs referenced via -l (lowercase L). The last step tries to link to lua5.1.lib using -L instead of the correct -l.
I have found out what's wrong with dev-cpp.when you want to link lib file you must shut down the makefile generation in the compiler option

Resources