I am attempting to link to a number of libraries in a very rudimentary manner (without the use of any Makefile or CMakeLists.txt), using the following clang++ command:
FILAMENT_LIBS="-lassimp -lbackend -lbluegl -lbluevk -lcamutils -lfilabridge -lfilaflat -lfilagui -lfilamat -lfilamat_combined -lfilamat_lite -lfilament -lfilameshio -lgeometry -lgltfio -lgltfio_core -lgltfio_pipeline -lgltfio_resources -libl -limage -limageio -limgui -lmatdbg -lmatdbg_resources -lmath -lmeshoptimizer -lrays -lshaders -lsmol-v -lutils"
clang++-7 -L../lib/x86_64/ ${FILAMENT_LIBS} -lpthread -lc++ -ldl -lSDL2 -I./ -I../include/ -I../app/ -I${RESOURCE_DIR} -Wno-extern-c-compat -std=c++14 -pthread ../suzanne.cpp ../app/Cube.cpp ../app/FilamentApp.cpp ../app/IBL.cpp ../app/IcoSphere.cpp ../app/Image.cpp ../app/NativeWindowHelperLinux.cpp ../app/Sphere.cpp -o suzanne
However, this gives the error FilamentApp.cpp:(.text+0x4d2): undefined reference to... followed by what must be every single one of the calls to functions in the aforementioned libraries.
To give some context, I am attempting to compile one of the sample apps provided by the rendering engine Filament. When this is compiled with the source code, everything works no issues, but when I attempt to link against the precompiled versions of the libraries, I get the above error.
Additionally, when I attempt to link against the same libraries with the tester main.cpp file and accompanying Makefile as described in the Filament documentation, everything links and compiles completely fine.
I have a feeling I'm doing something obvious wrong here, specifically with the clang command I am using, but I can't for the life of me see what it is. Any help would be much appreciated!
Edit - first few lines of errors:
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::loop()':
Engine.cpp:(.text._ZN8filament7details7FEngine4loopEv+0x22): undefined reference to `filament::backend::DefaultPlatform::create(filament::backend::Backend*)'
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::init()':
Engine.cpp:(.text._ZN8filament7details7FEngine4initEv+0x1f): undefined reference to `filament::backend::CommandStream::CommandStream(filament::backend::Driver&, filament::backend::CircularBuffer&)'
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::FEngine(filament::backend::Backend, filament::backend::Platform*, void*)':
Engine.cpp:(.text._ZN8filament7details7FEngineC2ENS_7backend7BackendEPNS2_8PlatformEPv+0x267): undefined reference to `filament::backend::CommandBufferQueue::CommandBufferQueue(unsigned long, unsigned long)'
Engine.cpp:(.text._ZN8filament7details7FEngineC2ENS_7backend7BackendEPNS2_8PlatformEPv+0x332): undefined reference to `filaflat::ShaderBuilder::ShaderBuilder()'
Engine.cpp:(.text._ZN8filament7details7FEngineC2ENS_7backend7BackendEPNS2_8PlatformEPv+0x342): undefined reference to `filaflat::ShaderBuilder::ShaderBuilder()'
Engine.cpp:(.text._ZN8filament7details7FEngineC2ENS_7backend7BackendEPNS2_8PlatformEPv+0x462): undefined reference to `filaflat::ShaderBuilder::~ShaderBuilder()'
Engine.cpp:(.text._ZN8filament7details7FEngineC2ENS_7backend7BackendEPNS2_8PlatformEPv+0x471): undefined reference to `filaflat::ShaderBuilder::~ShaderBuilder()'
Engine.cpp:(.text._ZN8filament7details7FEngineC2ENS_7backend7BackendEPNS2_8PlatformEPv+0x4a2): undefined reference to `filament::backend::CommandBufferQueue::~CommandBufferQueue()'
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::~FEngine()':
Engine.cpp:(.text._ZN8filament7details7FEngineD2Ev+0x3e): undefined reference to `filament::backend::DefaultPlatform::destroy(filament::backend::DefaultPlatform**)'
Engine.cpp:(.text._ZN8filament7details7FEngineD2Ev+0x10c): undefined reference to `filaflat::ShaderBuilder::~ShaderBuilder()'
Engine.cpp:(.text._ZN8filament7details7FEngineD2Ev+0x118): undefined reference to `filaflat::ShaderBuilder::~ShaderBuilder()'
Engine.cpp:(.text._ZN8filament7details7FEngineD2Ev+0x148): undefined reference to `filament::backend::CommandBufferQueue::~CommandBufferQueue()'
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::shutdown()':
Engine.cpp:(.text._ZN8filament7details7FEngine8shutdownEv+0x207): undefined reference to `filament::backend::CommandBufferQueue::flush()'
Engine.cpp:(.text._ZN8filament7details7FEngine8shutdownEv+0x20f): undefined reference to `filament::backend::CommandBufferQueue::requestExit()'
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::flushCommandBuffer(filament::backend::CommandBufferQueue&)':
Engine.cpp:(.text._ZN8filament7details7FEngine18flushCommandBufferERNS_7backend18CommandBufferQueueE+0x12): undefined reference to `filament::backend::CommandBufferQueue::flush()'
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::flush()':
Engine.cpp:(.text._ZN8filament7details7FEngine5flushEv+0x19): undefined reference to `filament::backend::CommandBufferQueue::flush()'
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::execute()':
Engine.cpp:(.text._ZN8filament7details7FEngine7executeEv+0x1b): undefined reference to `filament::backend::CommandBufferQueue::waitForCommands() const'
Engine.cpp:(.text._ZN8filament7details7FEngine7executeEv+0x4c): undefined reference to `filament::backend::CommandStream::execute(void*)'
Engine.cpp:(.text._ZN8filament7details7FEngine7executeEv+0x57): undefined reference to `filament::backend::CommandBufferQueue::releaseBuffer(filament::backend::CommandBufferQueue::Slice const&)'
/tmp/suzanne-ef5171.o: In function `main::$_0::operator()(filament::Engine*, filament::View*, filament::Scene*) const':
suzanne.cpp:(.text+0x1dc0): undefined reference to `TEXTURES_ALBEDO_S3TC_OFFSET'
suzanne.cpp:(.text+0x1dc7): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1dce): undefined reference to `TEXTURES_ALBEDO_S3TC_SIZE'
suzanne.cpp:(.text+0x1e10): undefined reference to `TEXTURES_AO_OFFSET'
suzanne.cpp:(.text+0x1e17): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1e1d): undefined reference to `TEXTURES_AO_SIZE'
suzanne.cpp:(.text+0x1e5e): undefined reference to `TEXTURES_METALLIC_OFFSET'
suzanne.cpp:(.text+0x1e65): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1e6b): undefined reference to `TEXTURES_METALLIC_SIZE'
suzanne.cpp:(.text+0x1eac): undefined reference to `TEXTURES_ROUGHNESS_OFFSET'
suzanne.cpp:(.text+0x1eb3): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1eb9): undefined reference to `TEXTURES_ROUGHNESS_SIZE'
suzanne.cpp:(.text+0x1f85): undefined reference to `TEXTURES_NORMAL_OFFSET'
suzanne.cpp:(.text+0x1f8c): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1f93): undefined reference to `TEXTURES_NORMAL_SIZE'
suzanne.cpp:(.text+0x1fdb): undefined reference to `RESOURCES_TEXTUREDLIT_OFFSET'
suzanne.cpp:(.text+0x1fe2): undefined reference to `RESOURCES_PACKAGE'
suzanne.cpp:(.text+0x1fe9): undefined reference to `RESOURCES_TEXTUREDLIT_SIZE'
suzanne.cpp:(.text+0x21ea): undefined reference to `RESOURCES_SUZANNE_OFFSET'
suzanne.cpp:(.text+0x21f0): undefined reference to `RESOURCES_PACKAGE'
/tmp/FilamentApp-94694a.o: In function `FilamentApp::run(Config const&, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, unsigned long, unsigned long)':
FilamentApp.cpp:(.text+0xd8e): undefined reference to `RESOURCES_DEPTHVISUALIZER_OFFSET'
FilamentApp.cpp:(.text+0xd95): undefined reference to `RESOURCES_PACKAGE'
FilamentApp.cpp:(.text+0xd9c): undefined reference to `RESOURCES_DEPTHVISUALIZER_SIZE'
FilamentApp.cpp:(.text+0xe2c): undefined reference to `RESOURCES_AIDEFAULTMAT_OFFSET'
FilamentApp.cpp:(.text+0xe33): undefined reference to `RESOURCES_PACKAGE'
FilamentApp.cpp:(.text+0xe3a): undefined reference to `RESOURCES_AIDEFAULTMAT_SIZE'
FilamentApp.cpp:(.text+0xeaf): undefined reference to `RESOURCES_TRANSPARENTCOLOR_OFFSET'
FilamentApp.cpp:(.text+0xeb6): undefined reference to `RESOURCES_PACKAGE'
FilamentApp.cpp:(.text+0xebd): undefined reference to `RESOURCES_TRANSPARENTCOLOR_SIZE'
/tmp/FilamentApp-94694a.o: In function `FilamentApp::Window::configureCamerasForWindow()':
FilamentApp.cpp:(.text+0x6902): undefined reference to `filament::Camera::setLensProjection(double, double, double, double)'
FilamentApp.cpp:(.text+0x6a34): undefined reference to `filament::Camera::lookAt(filament::math::details::TVec3<float> const&, filament::math::details::TVec3<float> const&)'
../lib/x86_64//libfilament.a(VertexBuffer.cpp.o): In function `filament::VertexBuffer::Builder::attribute(filament::VertexAttribute, unsigned char, filament::backend::ElementType, unsigned int, unsigned char)':
Edit 2 - error list after 2nd alteration:
/tmp/suzanne-e10eca.o: In function `main::$_0::operator()(filament::Engine*, filament::View*, filament::Scene*) const':
suzanne.cpp:(.text+0x1dc0): undefined reference to `TEXTURES_ALBEDO_S3TC_OFFSET'
suzanne.cpp:(.text+0x1dc7): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1dce): undefined reference to `TEXTURES_ALBEDO_S3TC_SIZE'
suzanne.cpp:(.text+0x1e10): undefined reference to `TEXTURES_AO_OFFSET'
suzanne.cpp:(.text+0x1e17): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1e1d): undefined reference to `TEXTURES_AO_SIZE'
suzanne.cpp:(.text+0x1e5e): undefined reference to `TEXTURES_METALLIC_OFFSET'
suzanne.cpp:(.text+0x1e65): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1e6b): undefined reference to `TEXTURES_METALLIC_SIZE'
suzanne.cpp:(.text+0x1eac): undefined reference to `TEXTURES_ROUGHNESS_OFFSET'
suzanne.cpp:(.text+0x1eb3): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1eb9): undefined reference to `TEXTURES_ROUGHNESS_SIZE'
suzanne.cpp:(.text+0x1f85): undefined reference to `TEXTURES_NORMAL_OFFSET'
suzanne.cpp:(.text+0x1f8c): undefined reference to `TEXTURES_PACKAGE'
suzanne.cpp:(.text+0x1f93): undefined reference to `TEXTURES_NORMAL_SIZE'
suzanne.cpp:(.text+0x1fdb): undefined reference to `RESOURCES_TEXTUREDLIT_OFFSET'
suzanne.cpp:(.text+0x1fe2): undefined reference to `RESOURCES_PACKAGE'
suzanne.cpp:(.text+0x1fe9): undefined reference to `RESOURCES_TEXTUREDLIT_SIZE'
suzanne.cpp:(.text+0x21ea): undefined reference to `RESOURCES_SUZANNE_OFFSET'
suzanne.cpp:(.text+0x21f0): undefined reference to `RESOURCES_PACKAGE'
/tmp/FilamentApp-0b5ad4.o: In function `FilamentApp::run(Config const&, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, unsigned long, unsigned long)':
FilamentApp.cpp:(.text+0xd8e): undefined reference to `RESOURCES_DEPTHVISUALIZER_OFFSET'
FilamentApp.cpp:(.text+0xd95): undefined reference to `RESOURCES_PACKAGE'
FilamentApp.cpp:(.text+0xd9c): undefined reference to `RESOURCES_DEPTHVISUALIZER_SIZE'
FilamentApp.cpp:(.text+0xe2c): undefined reference to `RESOURCES_AIDEFAULTMAT_OFFSET'
FilamentApp.cpp:(.text+0xe33): undefined reference to `RESOURCES_PACKAGE'
FilamentApp.cpp:(.text+0xe3a): undefined reference to `RESOURCES_AIDEFAULTMAT_SIZE'
FilamentApp.cpp:(.text+0xeaf): undefined reference to `RESOURCES_TRANSPARENTCOLOR_OFFSET'
FilamentApp.cpp:(.text+0xeb6): undefined reference to `RESOURCES_PACKAGE'
FilamentApp.cpp:(.text+0xebd): undefined reference to `RESOURCES_TRANSPARENTCOLOR_SIZE'
/tmp/FilamentApp-0b5ad4.o: In function `FilamentApp::Window::configureCamerasForWindow()':
FilamentApp.cpp:(.text+0x6902): undefined reference to `filament::Camera::setLensProjection(double, double, double, double)'
FilamentApp.cpp:(.text+0x6a34): undefined reference to `filament::Camera::lookAt(filament::math::details::TVec3<float> const&, filament::math::details::TVec3<float> const&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Edit 3
The variables referred to in the above errors are stored in the files
./generated/resources/resources.h and
./generated/resources/textures.h,
in relation to the clang++ directory of execution. The header file includes for these files look like this:
#include "generated/resources/resources.h"
#include "generated/resources/textures.h"
and I have included -I./ in the clang command, so surely clang should be able to see these files?
Here is textures.h:
#ifndef TEXTURES_H_
#define TEXTURES_H_
#include <stdint.h>
extern "C" {
extern const uint8_t TEXTURES_PACKAGE[];
extern int TEXTURES_ALBEDO_S3TC_OFFSET;
extern int TEXTURES_ALBEDO_S3TC_SIZE;
extern int TEXTURES_ROUGHNESS_OFFSET;
extern int TEXTURES_ROUGHNESS_SIZE;
extern int TEXTURES_METALLIC_OFFSET;
extern int TEXTURES_METALLIC_SIZE;
extern int TEXTURES_AO_OFFSET;
extern int TEXTURES_AO_SIZE;
extern int TEXTURES_NORMAL_OFFSET;
extern int TEXTURES_NORMAL_SIZE;
}
#define TEXTURES_ALBEDO_S3TC_DATA (TEXTURES_PACKAGE + TEXTURES_ALBEDO_S3TC_OFFSET)
#define TEXTURES_ROUGHNESS_DATA (TEXTURES_PACKAGE + TEXTURES_ROUGHNESS_OFFSET)
#define TEXTURES_METALLIC_DATA (TEXTURES_PACKAGE + TEXTURES_METALLIC_OFFSET)
#define TEXTURES_AO_DATA (TEXTURES_PACKAGE + TEXTURES_AO_OFFSET)
#define TEXTURES_NORMAL_DATA (TEXTURES_PACKAGE + TEXTURES_NORMAL_OFFSET)
#endif
Edit 4:
Error list after finding resource libraries:
/tmp/FilamentApp-11fd11.o: In function `FilamentApp::Window::configureCamerasForWindow()':
FilamentApp.cpp:(.text+0x6902): undefined reference to `filament::Camera::setLensProjection(double, double, double, double)'
FilamentApp.cpp:(.text+0x6a34): undefined reference to `filament::Camera::lookAt(filament::math::details::TVec3<float> const&, filament::math::details::TVec3<float> const&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Edit 5:
Some more errors...
../lib/x86_64//libfilament.a(Engine.cpp.o): In function `filament::details::FEngine::loop()':
/home/joel/Documents/KiwiTest/filament-source/out/cmake-debug/../../filament/src/Engine.cpp:448: undefined reference to `filament::matdbg::DebugServer::DebugServer(filament::backend::Backend, int)'
/home/joel/Documents/KiwiTest/filament-source/out/cmake-debug/../../filament/src/Engine.cpp:453: undefined reference to `filament::matdbg::DebugServer::~DebugServer()'
../lib/x86_64//libfilament.a(Material.cpp.o): In function `filament::Material::Builder::build(filament::Engine&)':
/home/joel/Documents/KiwiTest/filament-source/out/cmake-debug/../../filament/src/Material.cpp:110: undefined reference to `filament::matdbg::DebugServer::addMaterial(utils::CString const&, void const*, unsigned long, void*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Put all libraries last on the line when compiling:
clang++-7 -stdlib=libc++ -L../lib/x86_64/ -I./ -I../include/ -I../app/ -I${RESOURCE_DIR} -Wno-extern-c-compat -std=c++14 ../suzanne.cpp ../app/Cube.cpp ../app/FilamentApp.cpp ../app/IBL.cpp ../app/IcoSphere.cpp ../app/Image.cpp ../app/NativeWindowHelperLinux.cpp ../app/Sphere.cpp -o suzanne ${FILAMENT_LIBS} -lSDL2 -ldl -pthread
Also, use only -pthread (remove -lpthread). There's no need for both.
You may also want to remove -lc++ and replace it with -stdlib=libc++ (which does not need to be towards the end of the line).
What happens when linking your program is that when the linker encounters a symbol (function) that has not been encountered before, it puts it on a list of unresolved symbols. For every library it examines after that, the unresolved symbols are checked. If it encounters symbols that exists in libraries already examined, linking will fail.
The ordering of the filament libraries is also important so try:
FILAMENT_LIBS=-lfilament -lbackend -lbluegl -lbluevk -lfilabridge -lfilaflat -lutils -lgeometry -lsmol-v -libl
as stated in the documentation. Note that I removed the non-filament libraries from FILAMENT_LIBS. Put those libraries in a separate variable and place that before the FILAMENT_LIBS variable when compiling.
If SDL2 uses filament, you should put -lSDL2 before the filament libraries, otherwise, leave it where it is.
If it's still failing, you can, as a last resort, wrap the filament libraries in a library group to make it resolve the internal filament dependencies:
-Wl,--start-group $(FILAMENT_LIBS) -Wl,--end-group
This is however not what you want since it's slow, but, it's an option.
An even more desperate option would be to wrap all libraries inside the -Wl,--start-group ... -Wl,--end-group pair just to verify that it compiles and that you have all the libraries and object files needed.
I downloaded some example protobuff codes and sfml-networking but i cant compile the files and i dont what's wrong i definitly installed "libprotobuf-dev" and "protobuf-compiler" and also the code seem to run ok on other Pcs but when i use command make in terminal i get this error
this is the repository i cloned the example from :
https://github.com/An-Alone-Cow/schat
please help me i tried every thing
i also reinstalled all protobuff things several times and even installed manually from github repository provided by google
this is the error massege i get
g++ main.o messages.pb.o -L/usr/SFML-2.5.1/lib/ -lprotobuf -lsfml-network -lsfml-system -o run
main.o: In function `google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()':
main.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0x7): undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
messages.pb.o: In function `Message* google::protobuf::Arena::CreateMaybeMessage<Message>(google::protobuf::Arena*)':
messages.pb.cc:(.text+0x177a): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text+0x1799): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o: In function `__static_initialization_and_destruction_0(int, int)':
messages.pb.cc:(.text+0x1855): undefined reference to `google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)'
messages.pb.o: In function `google::protobuf::Arena::AllocHook(std::type_info const*, unsigned long) const':
messages.pb.cc:(.text._ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom[_ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom]+0x3d): undefined reference to `google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
messages.pb.o: In function `google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x22f): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x24e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o: In function `google::protobuf::internal::InitSCC(google::protobuf::internal::SCCInfoBase*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE[_ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE]+0x4d): undefined reference to `google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*)'
messages.pb.o: In function `google::protobuf::internal::OnShutdownDestroyMessage(void const*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x16): undefined reference to `google::protobuf::internal::DestroyMessage(void const*)'
messages.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x1e): undefined reference to `google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*)'
messages.pb.o: In function `Message::GetMetadataStatic()':
messages.pb.cc:(.text._ZN7Message17GetMetadataStaticEv[_ZN7Message17GetMetadataStaticEv]+0xc): undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*)'
messages.pb.o: In function `google::protobuf::internal::InternalMetadataWithArenaBase<google::protobuf::UnknownFieldSet, google::protobuf::internal::InternalMetadataWithArena>::mutable_unknown_fields_slow()':
messages.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x15e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x17a): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o:(.data.rel.ro._ZTV7Message[_ZTV7Message]+0xb8): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
collect2: error: ld returned 1 exit status
Makefile:2: recipe for target 'run' failed
make: *** [run] Error 1
[1]: https://github.com/An-Alone-Cow/schat
I am trying to run the c++ word count program in hadoop. When I run the following command:
g++ wordcount.cpp -o a -L/usr/local/hadoop/lib/native -lhadooppipes -lhadooputils -lpthread -I/usr/local/hadoop/include -Wall
I am getting the following errors:
/tmp/ccfwwM9D.o: In function `WordCountMap::map(HadoopPipes::MapContext&)':
wordcount.cpp:(.text._ZN12WordCountMap3mapERN11HadoopPipes10MapContextE[_ZN12WordCountMap3mapERN11HadoopPipes10MapContextE]+0x4a): undefined reference to `HadoopUtils::splitString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)'
/tmp/ccfwwM9D.o: In function `WordCountReduce::reduce(HadoopPipes::ReduceContext&)':
wordcount.cpp:(.text._ZN15WordCountReduce6reduceERN11HadoopPipes13ReduceContextE[_ZN15WordCountReduce6reduceERN11HadoopPipes13ReduceContextE]+0x5d): undefined reference to `HadoopUtils::toInt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
wordcount.cpp:(.text._ZN15WordCountReduce6reduceERN11HadoopPipes13ReduceContextE[_ZN15WordCountReduce6reduceERN11HadoopPipes13ReduceContextE]+0x81): undefined reference to `HadoopUtils::toString[abi:cxx11](int)'
/usr/local/hadoop/lib/native/libhadooppipes.a(HadoopPipes.cc.o): In function `HadoopPipes::BinaryProtocol::createDigest(std::string&, std::string&)':
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:426: undefined reference to `EVP_sha1'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:426: undefined reference to `HMAC_Init'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:427: undefined reference to `HMAC_Update'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:429: undefined reference to `HMAC_Final'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:430: undefined reference to `HMAC_CTX_cleanup'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:436: undefined reference to `BIO_f_base64'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:436: undefined reference to `BIO_new'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:437: undefined reference to `BIO_s_mem'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:437: undefined reference to `BIO_new'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:438: undefined reference to `BIO_push'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:439: undefined reference to `BIO_write'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:440: undefined reference to `BIO_ctrl'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:441: undefined reference to `BIO_ctrl'
/home/ambari-qa/hadoop/hadoop-tools/hadoop-pipes/src/main/native/pipes/impl/HadoopPipes.cc:446: undefined reference to `BIO_free_all'
collect2: error: ld returned 1 exit status
I am trying to do some tests with TBB at HPCG benchmark. However I didn't compiled the program successfully so far. I am getting errors like these:
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::start_for<tbb::blocked_range<int>, tbb::internal::parallel_for_body<ComputeSPMV_ref(SparseMatrix_STRUCT const&, Vector_STRUCT&, Vector_STRUCT&)::{lambda(int)#1}, int>, tbb::auto_partitioner const>::~start_for()':
ComputeSPMV_ref.cpp:(.text+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::start_for<tbb::blocked_range<int>, tbb::internal::parallel_for_body<ComputeSPMV_ref(SparseMatrix_STRUCT const&, Vector_STRUCT&, Vector_STRUCT&)::{lambda(int)#1}, int>, tbb::auto_partitioner const>::~start_for()':
ComputeSPMV_ref.cpp:(.text+0x23): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::start_for<tbb::blocked_range<int>, tbb::internal::parallel_for_body<ComputeSPMV_ref(SparseMatrix_STRUCT const&, Vector_STRUCT&, Vector_STRUCT&)::{lambda(int)#1}, int>, tbb::auto_partitioner const>::execute()':
ComputeSPMV_ref.cpp:(.text+0x182): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x1ad): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x26b): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x296): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x43b): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x470): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x52c): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
src/ComputeSPMV_ref.o: In function `ComputeSPMV_ref(SparseMatrix_STRUCT const&, Vector_STRUCT&, Vector_STRUCT&)':
ComputeSPMV_ref.cpp:(.text+0x9d0): undefined reference to `tbb::task_group_context::init()'
ComputeSPMV_ref.cpp:(.text+0x9e9): undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0xa29): undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
ComputeSPMV_ref.cpp:(.text+0xa52): undefined reference to `tbb::task_group_context::~task_group_context()'
ComputeSPMV_ref.cpp:(.text+0xad4): undefined reference to `tbb::task_group_context::~task_group_context()'
ComputeSPMV_ref.cpp:(.text+0xae0): undefined reference to `vtable for tbb::task'
ComputeSPMV_ref.cpp:(.text+0xaee): undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::flag_task::~flag_task()':
ComputeSPMV_ref.cpp:(.text._ZN3tbb10interface68internal9flag_taskD2Ev[_ZN3tbb10interface68internal9flag_taskD5Ev]+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::signal_task::~signal_task()':
ComputeSPMV_ref.cpp:(.text._ZN3tbb10interface68internal11signal_taskD2Ev[_ZN3tbb10interface68internal11signal_taskD5Ev]+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::flag_task::~flag_task()':
ComputeSPMV_ref.cpp:(.text._ZN3tbb10interface68internal9flag_taskD0Ev[_ZN3tbb10interface68internal9flag_taskD0Ev]+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::signal_task::~signal_task()':
ComputeSPMV_ref.cpp:(.text._ZN3tbb10interface68internal11signal_taskD0Ev[_ZN3tbb10interface68internal11signal_taskD0Ev]+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o:(.rodata+0x110): undefined reference to `typeinfo for tbb::task'
src/ComputeSPMV_ref.o:(.rodata._ZTIN3tbb10interface68internal11signal_taskE[_ZTIN3tbb10interface68internal11signal_taskE]+0x10): undefined reference to `typeinfo for tbb::task'
src/ComputeSPMV_ref.o:(.rodata._ZTIN3tbb10interface68internal9flag_taskE[_ZTIN3tbb10interface68internal9flag_taskE]+0x10): undefined reference to `typeinfo for tbb::task'
src/ComputeSPMV_ref.o:(.rodata._ZTVN3tbb10interface68internal9flag_taskE[_ZTVN3tbb10interface68internal9flag_taskE]+0x28): undefined reference to `tbb::task::note_affinity(unsigned short)'
src/ComputeSPMV_ref.o:(.rodata._ZTVN3tbb10interface68internal11signal_taskE[_ZTVN3tbb10interface68internal11signal_taskE]+0x28): undefined reference to `tbb::task::note_affinity(unsigned short)'
collect2: error: ld returned 1 exit status
make: *** [bin/xhpcg] Error 1
Compile instruction look like this:
make
/usr/bin/g++ -DHPCG_NOMPI -DHPCG_NOOPENMP -I./src -I./src/GCC_TBB -O3 -ltbb -std=c++11 -ffast-math -ftree-vectorize -ftree-vectorizer-verbose=0 -fopenmp testing/main.o src/CG.o src/CG_ref.o ....
I downloaded and install latest source code from Intel.Also I already use -ltbb and -std=c++11 at compile time and I include tbb files inside my code. I can't figure out the problem so far. Does anyone face anything like this before with Intel TBB? I am assuming that is something with the linking of library but I can't figure it out
Try to insert "-ltbb -std=c++11" just before -o and it should work!
Patroklos Patroklou's answer didn't help, so I put -ltbb at the end of my command and it worked.
Ubuntu 20.04
g++-9, libstdc++-9-dev
Trying to compile a cpp program in I run into the following linking errors:
11:42:55 **** Incremental Build of configuration Debug for project mrconv ****
Info: Internal Builder is used for build
g++ "-IC:\\Users\\Jesse\\Documents\\Work\\Research\\FiberTracking\\Software\\mrtrix\\source\\mrtrix-0.2.11\\lib" "-IC:\\Users\\Jesse\\Programs\\gtk+\\lib" "-IC:\\Users\\Jesse\\Programs\\gtk+\\bin" "-IC:\\Users\\Jesse\\Programs\\gtk+\\include\\glib-2.0" "-IC:\\Users\\Jesse\\Programs\\gtk+\\lib\\glib-2.0\\include" "-IC:\\gtkmm64\\include\\glibmm-2.4\\glibmm" "-IC:\\gtkmm64\\include\\glibmm-2.4" "-IC:\\gtkmm64\\lib\\glibmm-2.4\\include" "-IC:\\gtkmm64\\include\\sigc++-2.0" "-IC:\\gtkmm64\\lib\\sigc++-2.0\\include" "-IC:\\Program Files (x86)\\GnuWin32\\include" "-IC:\\Program Files (x86)\\GnuWin32\\include\\gsl" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\mrconvert.o" "..\\src\\mrconvert.cpp"
g++ "-LC:\\GnuWin32\\lib\\" -o mrconv.exe "src\\mrconvert.o" -llibgsl
src\mrconvert.o: In function `main':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:119: undefined reference to `MR::App::run(int, char**)'
src\mrconvert.o: In function `ZN5MyApp7executeEv':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:123: undefined reference to `MR::parse_floats(std::string const&)'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:167: undefined reference to `MR::DataType::parse(std::string const&)'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:174: undefined reference to `MR::Image::parse_axes_specifier(MR::Image::Axes const&, std::string const&)'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:201: undefined reference to `MR::parse_ints(std::string const&, int)'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:225: undefined reference to `MR::ProgressBar::init(unsigned int, std::string const&)'
src\mrconvert.o: In function `_static_initialization_and_destruction_0':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:55: undefined reference to `MR::Argument::End'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:95: undefined reference to `MR::Option::End'
src\mrconvert.o: In function `ZNK2MR9Exception7displayEv':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:187: undefined reference to `MR::Exception::level_offset'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:187: undefined reference to `MR::error'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:188: undefined reference to `MR::Exception::level_offset'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:188: undefined reference to `MR::info'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:189: undefined reference to `MR::debug'
src\mrconvert.o: In function `ZN2MR11ProgressBar3incEv':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:451: undefined reference to `MR::ProgressBar::current_val'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:451: undefined reference to `MR::ProgressBar::current_val'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:452: undefined reference to `MR::ProgressBar::display'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:452: undefined reference to `MR::ProgressBar::stop'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `MR::ProgressBar::multiplier'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `MR::ProgressBar::stop_watch'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `Glib::Timer::elapsed() const'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `MR::ProgressBar::current_val'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `MR::ProgressBar::multiplier'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:454: undefined reference to `MR::ProgressBar::percent'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:455: undefined reference to `MR::ProgressBar::percent'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:456: undefined reference to `MR::ProgressBar::display_func'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:458: undefined reference to `MR::ProgressBar::stop'
src\mrconvert.o: In function `ZN2MR11ProgressBar4doneEv':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:461: undefined reference to `MR::ProgressBar::display'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:461: undefined reference to `MR::ProgressBar::done_func'
src\mrconvert.o: In function `ZN2MR5Image6ObjectD1Ev':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:49: undefined reference to `MR::info'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:49: undefined reference to `MR::Image::Mapper::unmap(MR::Image::Header const&)'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:49: undefined reference to `MR::Image::Mapper::~Mapper()'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:49: undefined reference to `MR::Image::Mapper::~Mapper()'
src\mrconvert.o: In function `ZN2MR5Image6Object3mapEv':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:57: undefined reference to `MR::Image::Mapper::map(MR::Image::Header const&)'
src\mrconvert.o: In function `ZNK2MR7ArgBase9get_imageERNS_5Image6HeaderE':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/args.h:201: undefined reference to `MR::Image::Object::create(std::string const&, MR::Image::Header&)'
src\mrconvert.o: In function `ZN5MyAppC1EiPPcPPKcPKN2MR8ArgumentEPKNS5_6OptionEPKjS3_S3_':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:119: undefined reference to `MR::App::App(int, char**, char const**, MR::Argument const*, MR::Option const*, unsigned int const*, char const*, char const*)'
src\mrconvert.o: In function `ZN5MyAppD1Ev':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:119: undefined reference to `MR::App::~App()'
collect2.exe: error: ld returned 1 exit status
11:42:57 Build Finished (took 1s.854ms)
It would appear these are internal linking errors? How do I go about finding the source of these errors?
you need to compile all the files and link them together. It's either missing a cpp file or library
This might be the problem. You need to use -L to specify where library files are. -I is to specify where included files are located.
g++ "-IC:\\Users\\Jesse\\Documents\\Work\\Research\\FiberTracking\\Software\\mrtrix\\source\\mrtrix-0.2.11\\lib" "-IC:\\Users\\Jesse\\Programs\\gtk+\\lib" "-IC:\\Users\\Jesse\\Programs\\gtk+\\bin" "-IC:\\Users\\Jesse\\Programs\\gtk+\\include\\glib-2.0" "-IC:\\Users\\Jesse\\Programs\\gtk+\\lib\\glib-2.0\\include" "-IC:\\gtkmm64\\include\\glibmm-2.4\\glibmm" "-IC:\\gtkmm64\\include\\glibmm-2.4" "-IC:\\gtkmm64\\lib\\glibmm-2.4\\include" "-IC:\\gtkmm64\\include\\sigc++-2.0" "-IC:\\gtkmm64\\lib\\sigc++-2.0\\include" "-IC:\\Program Files (x86)\\GnuWin32\\include" "-IC:\\Program Files (x86)\\GnuWin32\\include\\gsl" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\mrconvert.o" "..\\src\\mrconvert.cpp"
I think some of them shouldbe changed to -L. for example
"-IC:\\Users\\Jesse\...lib"
Should be
-L"C:\\Users\\Jesse\...lib"
And should go on the linkage line. i.e. The second line where you link everything.