Comments (18)
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.
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.
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.
@kloczek Your issue is a different one and fixed with v1.2.1 (see #687)
from prometheus-cpp.
@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.
Did you try the latest 1.2.1 version?
from prometheus-cpp.
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.
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.
@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.
Are you using GCC 11 from devtoolset-11?
from prometheus-cpp.
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.
@kloczek and your distribution is also fedora rawhide?
from prometheus-cpp.
@kloczek Please test v1.2.2. I forgot to release a new version with the build fix. Sorry about that.
from prometheus-cpp.
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.
Are you using GCC 11 from devtoolset-11?
@gjasny No I have compiled it from source on my machine
from prometheus-cpp.
@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.
@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.
@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)
- Bazel workspace integration example does not seem to be viable HOT 1
- about Registry::Add some question HOT 2
- [Notice]: the CMake version need to be higher than 3.19 HOT 2
- CheckMetricName HOT 2
- build error `bin/prometheus_push_internal_test` with ubuntu 20.04 and 22.04 HOT 5
- benchmark missing `UseManualTime` HOT 1
- Native support for sidecar container process HOT 1
- Observing Segmentation fault during counter metric collection. HOT 5
- Compilation issue on CentOS HOT 2
- grafana cannot validate data source HOT 1
- Use with boost::beast Webserver HOT 2
- bzlmod issue HOT 1
- How to turn of the output? HOT 1
- Add async/callback mode to instruments? HOT 3
- Installing on ubuntu 22.04 HOT 5
- Publish to BCR ? HOT 3
- How to change default http protocol version from 0.9 to 1.1 HOT 7
- Use civetweb module
- bazel build sample error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prometheus-cpp.