Issue when trying to link my C++ program to the proper library

82 views
Skip to first unread message

Gérald Fenoy

unread,
Aug 9, 2021, 10:21:28 AM8/9/21
to iRODS-Chat
Dear all,
sorry for sending this message but I tried various compiler flags combinaison expecting to be able to link my C++ application to the proper libraries but it seems that I still miss something.

Actually, when I don't use the escaped_kvp_string method from irods the program compile properly. But, when I try to add this method invocation then my compilation failed with the following message:

<<<

service_internal_irods.c:(.text+0xb06): undefined reference to `irods::escaped_kvp_string(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'

collect2: error: ld returned 1 exit status

<<<


The command we are using to link is the following:


<<<

g++  -D_GLIBCXX_USE_CXX11_ABI=0 -DBOOST_SYSTEM_NO_DEPRECATED -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_LARGE_FILES -Dlinux_platform -DNDEBUG -std=gnu++1z -I/usr/include/irods/ -DUSE_JSON -I/usr/include/json-c/ -I/usr/include/js/   -I/usr/include/gdal -I/usr/include/libxml2    -I/usr/include/python3.6m -I/usr/include/python3.6m -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H   -I/include -DRELY_ON_DB -DDEB -fpic -I/usr//include -I/usr//include -I/usr/include   -DUSE_MS -I/usr/include/mapserver  -DUSE_AMQP -I/usr/include/irods/ -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE  zoo_loader.o zoo_service_loader.o service_internal_amqp.o service_internal_ms.o service_internal_python.o     service_internal_js.o        service_json.o service_callback.o service_internal_r.o service_internal_irods.o response_print.o server_internal.o caching.o request_parser.o ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -L. -lzoo_service  -L/lib -lcrypto -ldl -lcurl  -L../../thirds/cgic206 -lcgic -L/usr/lib -lgdal -lxml2 -lm -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -L/usr/lib -lpython3.6m -lpthread -ldl  -lutil -lm  -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -lpython3.6  -lrabbitmq   -L/usr/lib -lmozjs185 -lm  -L/usr/lib -lfcgi -lcrypto -L/usr//lib -lssl -L/usr//lib -luuid -L/usr/lib -lmapserver       -L/usr/lib/ -lR -L/usr/lib -ljson-c -lxslt -lxml2 -Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs -Wl,-z,origin -L/usr/lib -lirods_server -lirods_client -lirods_plugin_dependencies -lirods_common /opt/irods-externals/boost1.67.0-0/lib/libboost_system.so /opt/irods-externals/boost1.67.0-0/lib/libboost_filesystem.so /opt/irods-externals/boost1.67.0-0/lib/libboost_thread.so /opt/irods-externals/boost1.67.0-0/lib/libboost_program_options.so /opt/irods-externals/boost1.67.0-0/lib/libboost_regex.so  /opt/irods-externals/boost1.67.0-0/lib/libboost_chrono.so -Wl,-rpath,/opt/irods-externals/boost1.67.0-0/lib  /opt/irods-externals/fmt6.1.2-1/lib/libfmt.so -Wl,-rpath,/opt/irods-externals/fmt6.1.2-1/lib /opt/irods-externals/clang-runtime6.0-0/lib/libc++.so.1 /opt/irods-externals/clang-runtime6.0-0/lib/libc++abi.so.1 /opt/irods-externals/fmt6.1.2-1/lib/libfmt.so.6 -Wl,-rpath,/usr/lib -Wl,-rpath,/opt/irods-externals/clang-runtime6.0-0/lib 

<<<


I may be wrong but I think that the undefined function mentioned is actually available in libirods_common.so:


# nm /usr/lib/libirods_common.so | grep escaped_kvp_string

00000000000dca10 T _ZN5irods18escaped_kvp_stringERKNSt3__13mapINS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES7_NS0_4lessIS7_EENS5_INS0_4pairIKS7_S7_EEEEEE

00000000000d9a40 T _ZN5irods24parse_escaped_kvp_stringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERNS0_3mapIS6_S6_NS0_4lessIS6_EENS4_INS0_4pairIS7_S6_EEEEEES8_S8_S8_


In the code, I use the following:


<<<

std::stringstream ttl_str;  ttl_str << ttl;

std::stringstream passwd;  passwd.str(pcaPassword);

irods::kvp_map_t ctx_map;

ctx_map[ irods::AUTH_TTL_KEY ] = ttl_str.str();

ctx_map[ irods::AUTH_PASSWORD_KEY ] = passwd.str();

std::string ctx_str = irods::escaped_kvp_string(ctx_map);

<<<


Can anyone indicate what am I doing wrong?


Best regards.


Gérald Fenoy


dmoore.renci

unread,
Aug 10, 2021, 10:01:50 AM8/10/21
to iRODS-Chat
hi Gérald,

  Have you tried compiling and linking with the Clang toolchain? On Ubuntu 18.04, clang++ 6.0.0 is native (one only need to install the package), and then the incantation should be something like:

  /opt/irods-externals/clang6.0-0/bin/clang++  SOURCE_FILE.cc   -stdlib=libc++  -Wl,-rpath,/opt/irods-externals/clang-runtime6.0-0/lib:/opt/irods-externals/boost1.67.0-11/lib  -I /usr/include/irods -I /opt/irods-externals/boost1.67.0-0/include  [ ... other compile options...]

Hope this helps.

Daniel Moore / Applications Engineer / iRODS Consortium 

dmoore.renci

unread,
Aug 10, 2021, 10:03:17 AM8/10/21
to iRODS-Chat
Gérald,

Sorry, meant to say you should not have to install the Ubuntu 18.04, but can rely on it if necessary. The recommended path is to use the irods-externals package for clang, boost, etc.

Gérald Fenoy

unread,
Aug 11, 2021, 6:54:33 AM8/11/21
to iRODS-Chat
Hi Daniel,
thanks a lot for your answer, it has solved my issue.

Sorry for late reply but, in our project, it was required to also add the following option at compile time: -std=c++17 and add the following DSO /usr/lib/x86_64-linux-gnu/libstdc++.so.6 at link time. 

Anyway, now it build properly, thanks again.

Best regards

Gérald FENOY

Terrell Russell

unread,
Aug 11, 2021, 7:20:01 AM8/11/21
to irod...@googlegroups.com
Hi Gérald,

Glad that worked.    We'd be very interested in hearing about your integration if you're allowed/willing to share.

And if you're very enthusiastic, I'd invite you to consider giving a talk at either TRiRODS[1] or the iRODS User Group Meeting[2] in June 2022.

Terrell




--
--
The Integrated Rule-Oriented Data System (iRODS) - https://irods.org
 
iROD-Chat: http://groups.google.com/group/iROD-Chat
---
You received this message because you are subscribed to the Google Groups "iRODS-Chat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to irod-chat+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/irod-chat/cdbd4adc-6d44-4645-8998-e79e9dedcaa5n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages