Bug 26650 - Compilation fails on Solaris due to missing -lrt for nanosleep
Summary: Compilation fails on Solaris due to missing -lrt for nanosleep
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All Solaris
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-19 07:59 UTC by Fabian Groffen
Modified: 2010-02-21 09:01 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Fabian Groffen 2010-02-19 07:59:14 UTC
cmake output on a Sun sparc running Solaris 10:

Linking CXX executable perf-test
CMakeFiles/perf-test.dir/perf-test.cc.o: In function `sleep_milliseconds(int)':
perf-test.cc:(.text+0x51c): undefined reference to `nanosleep'
collect2: ld returned 1 exit status
make[2]: *** [test/perf-test] Error 1
make[1]: *** [test/CMakeFiles/perf-test.dir/all] Error 2
make: *** [all] Error 2

nanosleep is in -lrt on Solaris, which is missing in the link line (cmake nicely hides it away, pretty useful).  The autoconf based build properly detected this.  I don't understand enough of the cmake maze to suggest a patch to do the equivalent of the autoconf macro to check whether a function needs a library to be linked with.

Please add the appropriate construct to the cmake system.
Comment 1 Albert Astals Cid 2010-02-19 11:21:14 UTC
Can you:
 a) provide access to an opensolaris system for testing?
or
 b) test patches?
Comment 2 Albert Astals Cid 2010-02-19 11:21:39 UTC
s/opensolaris/solaris 10/
Comment 3 Fabian Groffen 2010-02-21 07:22:57 UTC
I have access to opensolaris/Intel, Solaris 10/Intel and Solaris 10/Sparc, and can easily test, but cannot provide access to them.  Easiest for you to test out stuff would be to quickly install (open)solaris in e.g. a virtual box instance.

I worked around the issue for now by exporting LDFLAGS=-lrt on Solaris while compiling.
Comment 4 Albert Astals Cid 2010-02-21 07:57:14 UTC
Can you please test this patch?

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 6049c9a..04de970 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -49,3 +49,8 @@ check_for_dir("dirent.h" HAVE_DIRENT_H)
 check_for_dir("ndir.h" HAVE_NDIR_H)
 check_for_dir("sys/dir.h" HAVE_SYS_DIR_H)
 check_for_dir("sys/ndir.h" HAVE_SYS_NDIR_H)
+
+check_function_exists("nanosleep" HAVE_NANOSLEEP)
+if(NOT HAVE_NANOSLEEP)
+  check_library_exists("rt" "nanosleep" "" LIB_RT_HAS_NANOSLEEP)
+endif(NOT HAVE_NANOSLEEP)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2c6ec36..eada899 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,12 +1,17 @@

 if (ENABLE_SPLASH)

-  set (perf_test_SRCS
-    perf-test.cc
-    perf-test-preview-dummy.cc
-  )
-  add_executable(perf-test ${perf_test_SRCS})
-  target_link_libraries(perf-test poppler)
+  if (HAVE_NANOSLEEP OR LIB_RT_HAS_NANOSLEEP)
+    set (perf_test_SRCS
+      perf-test.cc
+      perf-test-preview-dummy.cc
+    )
+    add_executable(perf-test ${perf_test_SRCS})
+    target_link_libraries(perf-test poppler)
+    if (LIB_RT_HAS_NANOSLEEP)
+      target_link_libraries(perf-test rt)
+    endif (LIB_RT_HAS_NANOSLEEP)
+  endif (HAVE_NANOSLEEP OR LIB_RT_HAS_NANOSLEEP)

 endif (ENABLE_SPLASH)
Comment 5 Fabian Groffen 2010-02-21 08:34:44 UTC
...
-- Looking for nanosleep
-- Looking for nanosleep - not found
-- Looking for nanosleep in rt
-- Looking for nanosleep in rt - found
...

And it completes its build.  So patch looks good to me!
Comment 6 Albert Astals Cid 2010-02-21 09:01:39 UTC
Will be in next 0.13.x release


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.