Code Monkey home page Code Monkey logo

Comments (18)

kloczek avatar kloczek commented on August 28, 2024 1

In my case I had disabled the testing -DENABLE_TESTING=OFF and the source got compiled well and has generated the libs, not sure why the example code is not able to compile and displaying undefined reference error

But this is nothing more than just swiping dust under the carpet πŸ˜‹

from prometheus-cpp.

kloczek avatar kloczek commented on August 28, 2024

This is not about example programs but when source code is configured with -D ENABLE_TESTING=ON
Have the same issue:

[ 98%] Linking CXX executable ../../../bin/prometheus_push_internal_test
cd /home/tkloczko/rpmbuild/BUILD/prometheus-cpp-1.2.1/x86_64-redhat-linux-gnu/push/tests/internal && /usr/bin/cmake -E cmake_link_script CMakeFiles/prometheus_push_internal_test.dir/link.txt --verbose=1
/usr/bin/g++ -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -fno-rtti -DNDEBUG -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--gc-sections -Wl,--as-needed -Wl,--build-id=sha1 -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,pack-relative-relocs -flto=auto -fuse-linker-plugin CMakeFiles/prometheus_push_internal_test.dir/label_encoder_test.cc.o -o ../../../bin/prometheus_push_internal_test  -Wl,-rpath,/home/tkloczko/rpmbuild/BUILD/prometheus-cpp-1.2.1/x86_64-redhat-linux-gnu/lib /usr/lib64/libgmock_main.so.1.14.0 ../../../lib/libprometheus-cpp-push.so.1.2.0 ../../../lib/libprometheus-cpp-core.so.1.2.0 /usr/lib64/libgmock.so.1.14.0 /usr/lib64/libgtest.so.1.14.0
/usr/bin/ld: /tmp/ccepa2St.ltrans0.ltrans.o: in function `prometheus::(anonymous namespace)::LabelEncoderTest_unicode_Test::TestBody()':
/home/tkloczko/rpmbuild/BUILD/prometheus-cpp-1.2.1/push/tests/internal/label_encoder_test.cc:15:(.text._ZN10prometheus12_GLOBAL__N_129LabelEncoderTest_unicode_Test8TestBodyEv+0x274): undefined reference to `prometheus::detail::encodeLabel(std::ostream&, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&)'
/usr/bin/ld: /tmp/ccepa2St.ltrans0.ltrans.o: in function `prometheus::(anonymous namespace)::LabelEncoderTest_path_Test::TestBody()':
/home/tkloczko/rpmbuild/BUILD/prometheus-cpp-1.2.1/push/tests/internal/label_encoder_test.cc:15:(.text._ZN10prometheus12_GLOBAL__N_126LabelEncoderTest_path_Test8TestBodyEv+0x237): undefined reference to `prometheus::detail::encodeLabel(std::ostream&, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&)'
/usr/bin/ld: /tmp/ccepa2St.ltrans0.ltrans.o: in function `prometheus::(anonymous namespace)::LabelEncoderTest_empty_Test::TestBody()':
/home/tkloczko/rpmbuild/BUILD/prometheus-cpp-1.2.1/push/tests/internal/label_encoder_test.cc:15:(.text._ZN10prometheus12_GLOBAL__N_127LabelEncoderTest_empty_Test8TestBodyEv+0x226): undefined reference to `prometheus::detail::encodeLabel(std::ostream&, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&)'
/usr/bin/ld: /tmp/ccepa2St.ltrans0.ltrans.o: in function `prometheus::(anonymous namespace)::LabelEncoderTest_regular_Test::TestBody()':
/home/tkloczko/rpmbuild/BUILD/prometheus-cpp-1.2.1/push/tests/internal/label_encoder_test.cc:15:(.text._ZN10prometheus12_GLOBAL__N_129LabelEncoderTest_regular_Test8TestBodyEv+0x239): undefined reference to `prometheus::detail::encodeLabel(std::ostream&, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [push/tests/internal/CMakeFiles/prometheus_push_internal_test.dir/build.make:105: bin/prometheus_push_internal_test] Error 1

from prometheus-cpp.

captKBK avatar captKBK commented on August 28, 2024

In my case I had disabled the testing -DENABLE_TESTING=OFF and the source got compiled well and has generated the libs, not sure why the example code is not able to compile and displaying undefined reference error

from prometheus-cpp.

gjasny avatar gjasny commented on August 28, 2024

@kloczek Your issue is a different one and fixed with v1.2.1 (see #687)

from prometheus-cpp.

gjasny avatar gjasny commented on August 28, 2024

@captKBK could you please run:

nm -C /root/prometheus_poc/prometheus_libs/lib64/libprometheus-cpp-pull.a | grep 'Exposer::Exposer'

to see the defined symbols? Your test_prometheus.cpp wants a std::__cxx11::basic_string string (note the __cxx11). I wonder what the prometheus-cpp-pull lib defines.

from prometheus-cpp.

gjasny avatar gjasny commented on August 28, 2024

Did you try the latest 1.2.1 version?

from prometheus-cpp.

captKBK avatar captKBK commented on August 28, 2024

Hi @gjasny
I tried the above command

Here is the output,
I have generated shared libraries files,

[root@localhost cppApp]# nm -C /root/prometheus_poc/prometheus_libs/lib64/libprometheus-cpp-pull.so | grep 'Exposer::Exposer'
000000000002f00e T prometheus::Exposer::Exposer(std::string const&, unsigned long, CivetCallbacks const*)
000000000002f1ce T prometheus::Exposer::Exposer(std::vector<std::string, std::allocatorstd::string >, CivetCallbacks const*)
000000000002f00e T prometheus::Exposer::Exposer(std::string const&, unsigned long, CivetCallbacks const*)
000000000002f1ce T prometheus::Exposer::Exposer(std::vector<std::string, std::allocatorstd::string >, CivetCallbacks const*)

from prometheus-cpp.

kloczek avatar kloczek commented on August 28, 2024

Did you try the latest 1.2.1 version?

If you will look one more time on output which I've provided you can find that it was generated on building exactly that version.

from prometheus-cpp.

gjasny avatar gjasny commented on August 28, 2024

@captKBK It looks like your prometheus-cpp-pull lib was compiled with _GLIBCXX_USE_CXX11_ABI=0 and your test case with _GLIBCXX_USE_CXX11_ABI=1. To be fully sure please omit the -C argument from the nm command and also use nm on test_prometheus.o. If the defined and used Exposer::Exposer constructor differ in the unmangled form we know for sure that _GLIBCXX_USE_CXX11_ABI is the culprit.

Theoretically the error will vanish if you run:

scl enable devtolset-11 -- g++ -std=c++11 -o prom.exe test_prometheus.cpp -I/root/prometheus_poc/prometheus_libs/include -L/root/prometheus_poc/prometheus_libs/lib64/ -lprometheus-cpp-pull -lprometheus-cpp-core -lz

from prometheus-cpp.

gjasny avatar gjasny commented on August 28, 2024

Are you using GCC 11 from devtoolset-11?

from prometheus-cpp.

kloczek avatar kloczek commented on August 28, 2024

Are you using GCC 11 from devtoolset-11?

I'm using devel snapshot of the gcc 14,x which is now available in fedora rawhide.

from prometheus-cpp.

gjasny avatar gjasny commented on August 28, 2024

@kloczek and your distribution is also fedora rawhide?

from prometheus-cpp.

gjasny avatar gjasny commented on August 28, 2024

@kloczek Please test v1.2.2. I forgot to release a new version with the build fix. Sorry about that.

from prometheus-cpp.

kloczek avatar kloczek commented on August 28, 2024

Just tested 1.2.2 and now all looks good and it passes test suite as wellπŸ˜„

+ cd prometheus-cpp-1.2.2
+ /usr/bin/ctest --test-dir x86_64-redhat-linux-gnu --output-on-failure --force-new-ctest-process -j48
Internal ctest changing into directory: /home/tkloczko/rpmbuild/BUILD/prometheus-cpp-1.2.2/x86_64-redhat-linux-gnu
Test project /home/tkloczko/rpmbuild/BUILD/prometheus-cpp-1.2.2/x86_64-redhat-linux-gnu
    Start 1: prometheus_core_test
    Start 2: prometheus_util_test
    Start 3: prometheus_pull_integration_test
    Start 4: prometheus_pull_test
    Start 5: prometheus_push_internal_test
1/5 Test #2: prometheus_util_test ...............   Passed    0.01 sec
2/5 Test #5: prometheus_push_internal_test ......   Passed    0.01 sec
3/5 Test #1: prometheus_core_test ...............   Passed    1.30 sec
4/5 Test #4: prometheus_pull_test ...............   Passed    2.01 sec
5/5 Test #3: prometheus_pull_integration_test ...   Passed   28.12 sec

100% tests passed, 0 tests failed out of 5

@kloczek Please test v1.2.2. I forgot to release a new version with the build fix. Sorry about that.

Thing happens .. you don't need to say sorry as your rection was instant πŸ˜‹

Thank you very muchπŸ‘

from prometheus-cpp.

captKBK avatar captKBK commented on August 28, 2024

Are you using GCC 11 from devtoolset-11?

@gjasny No I have compiled it from source on my machine

from prometheus-cpp.

kloczek avatar kloczek commented on August 28, 2024

@kloczek and your distribution is also fedora rawhide?

Almost 100% in case of most of the packages however I'm still I need to finish clean gcc so this is why I'm using gcc from rawhide.

from prometheus-cpp.

gjasny avatar gjasny commented on August 28, 2024

@captKBK you probably compiled prometheus-cpp with a different compiler than you used for your test_prometheus.cpp. If you use the same one the error will vanish.

from prometheus-cpp.

captKBK avatar captKBK commented on August 28, 2024

@gjasny Yes that worked, I found root cause, gcc 4.8 was still existing in my machine and while compiling prometheus-cpp it was considering gcc 4.8 and not 11.2, I removed it and recompiled the prometheus-cpp source, it worked fine. Thanks for the help!

from prometheus-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.