Linker error with clock_gettime when using iostream

Linker error with clock_gettime when using iostream

BY 25 Jul 2017 Native Application Development

Hello,

    I am currently in the process of developping a Tizen Native Service which depends on a portable homemade C++ library. This library includes iostream in some of it’s debug capabilities.

   However, I am unable to build even the smallest program in Tizen Studio which includes both thread and iostream:

   Take this sample program:

#include <tizen.h>
#include <service_app.h>
#include "service.h"
#include <iostream>

bool service_app_create(void *data)
{
    // Todo: add your code here.
    return true;
}

void service_app_terminate(void *data)
{
    // Todo: add your code here.
    return;
}

void service_app_control(app_control_h app_control, void *data)
{
    // Todo: add your code here.
    return;
}

int main(int argc, char* argv[])
{
    char ad[50] = {0,};
    service_app_lifecycle_callback_s event_callback;
	app_event_handler_h handlers[5] = {NULL, };

	event_callback.create = service_app_create;
	event_callback.terminate = service_app_terminate;
	event_callback.app_control = service_app_control;

	return service_app_main(argc, argv, &event_callback, ad);
}

When using the wearable 2.3.2 arm GCC-4.9 tool chain, I get the following error when the linker is invoked:

arm-linux-gnueabi-g++ -o service src/service.o   -L”../lib” -Xlinker –as-needed  -pie -lpthread –sysroot=”/home/bruno/tizen-studio/tools/smart-build-interface/../../platforms/tizen-2.3.2/wearable/rootstraps/wearable-2.3.2-device.core” -Xlinker –version-script=”../.exportMap” -L”/home/bruno/tizen-studio/tools/smart-build-interface/../../platforms/tizen-2.3.2/wearable/rootstraps/wearable-2.3.2-device.core/usr/lib” -lBrokenLocale -lanl -lappcore-agent -lappcore-watch -lbadge -lbase-utils-i18n -lbundle -lcairo -lcapi-appfw-alarm -lcapi-appfw-app-common -lcapi-appfw-app-control -lcapi-appfw-application -lcapi-appfw-app-manager -lcapi-appfw-package-manager -lcapi-appfw-preference -lcapi-appfw-widget-application -lcapi-base-common -lcapi-content-media-content -lcapi-content-mime-type -lcapi-data-control -lcapi-location-manager -lcapi-maps-service -lcapi-media-audio-io -lcapi-media-camera -lcapi-media-codec -lcapi-media-image-util -lcapi-media-metadata-extractor -lcapi-media-player -lcapi-media-radio -lcapi-media-recorder -lcapi-media-sound-manager -lcapi-media-tone-player -lcapi-media-tool -lcapi-media-wav-player -lcapi-message-port -lcapi-messaging-messages -lcapi-network-bluetooth -lcapi-network-connection -lcapi-network-nfc -lcapi-network-smartcard -lcapi-network-wifi -lcapi-system-device -lcapi-system-info -lcapi-system-media-key -lcapi-system-runtime-info -lcapi-system-sensor -lcapi-system-system-settings -lcapi-telephony -lcapi-ui-efl-util -lcidn -lcore-context-manager -lcrypto -lcrypt -lc -lcurl -ldlog -ldl -lecore_con -lecore_evas -lecore_fb -lecore_file -lecore_imf_evas -lecore_imf -lecore_input_evas -lecore_input -lecore_ipc -lecore -lecore_x -ledbus -ledje -leet -lefl-extension -lefreet_mime -lefreet -lefreet_trash -leina -leio -lelementary -lembryo -lethumb_client -lethumb -levas -lewebkit2 -lexif -lfontconfig -lfreetype -lgio-2.0 -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -ljson-glib-1.0 -lkey-manager-client -lminizip -lm -lnotification -lnsl -lnss_compat -lnss_dns -lnss_files -lnss_hesiod -lnss_nisplus -lnss_nis -loauth -lopenal -lprivilege-info -lpthread -lpush -lresolv -lrt -lsqlite3 -lssl -lstorage -lstt -ltbm -lthread_db -lttrace -ltts -lutil -lwidget_service -lwidget_viewer_evas -lxml2 -lz -Xlinker -rpath=”/opt/usr/apps/org.example.service/lib” -Werror-implicit-function-declaration/home/bruno/tizen-studio/tools/arm-linux-gnueabi-gcc-4.9/bin/../lib/gcc/arm-linux-gnueabi/4.9.2/../../../../arm-linux-gnueabi/lib/libstdc++.so: undefined reference to `clock_gettime@GLIBC_2.17′

This issue was encountered with Tizen Studio 1.2 with the wear-2.3.2 package. I cannot find which library is supposed to provide the clock_gettime symbol, but it does not seem to be included in the system libs.

This same program works without any issue when using the gcc 4.6 tool chain, but I find it strange that I cannot use the latest version of the libs for my project.

 

Written by