Opened 15 years ago

Closed 14 years ago

#1 closed patch (fixed)

smartmontools build fails on QNX

Reported by: Christian Franke Owned by: jhering
Priority: major Milestone: Release 5.40
Component: all Version: 5.39
Keywords: QNX getopt_long Cc:

Description (last modified by Gabriele Pohl)

The compilation on QNX fails due to missing getopt_long(). A proposed patch using the existing implementation in 'posix/getopt*' compiles, but leads to further problems related to exception handling.

See also thread Compilation failure on QNX in smartmontools-devel. (ML-Archiv accessible for smartmontools developers only)

Attachments (3)

configure-getopt.patch (1.6 KB ) - added by Christian Franke 14 years ago.
Proposed patch for configure.in and Makefile.am, requires r3083.
getopt.h-getopt.patch (444 bytes ) - added by stevestereo 14 years ago.
uncomments getopt in getopt.h in order to use getopt provided by QNX ibc
configure-getopt-qnx.patch (2.0 KB ) - added by stevestereo 14 years ago.
based on configure-getopt.patch but includes fix for getopt and missing cast in os_qnxnto.cpp

Download all attachments as: .zip

Change History (15)

comment:1 by Gabriele Pohl, 15 years ago

Description: modified (diff)
Keywords: QNX getopt_long added

comment:2 by Bruce Allen, 15 years ago

Owner: changed from somebody to jhering
Status: newassigned

comment:3 by Christian Franke, 15 years ago

Version: 5.39

comment:4 by Christian Franke, 15 years ago

Milestone: Release 5.40

No feedback yet, milestone removed.

comment:5 by Christian Franke, 14 years ago

Milestone: Release 5.40

ticket #68 has been marked as a duplicate of this ticket.

comment:6 by jhering, 14 years ago

Status: assignedaccepted
Type: defectpatch

comment:7 by Christian Franke, 14 years ago

r3083: getopt_long() from 'posix/getopt*' is now in a new directory 'getopt'.

by Christian Franke, 14 years ago

Attachment: configure-getopt.patch added

Proposed patch for configure.in and Makefile.am, requires r3083.

by stevestereo, 14 years ago

Attachment: getopt.h-getopt.patch added

uncomments getopt in getopt.h in order to use getopt provided by QNX ibc

comment:8 by stevestereo, 14 years ago

checked out SVN 3108 and applied the configure-getopt.patch.
was able to configure and so on but build fails with the following output:

# make
make  all-recursive
make[1]: Entering directory `/tmp/smartmontools'
Making all in .
make[2]: Entering directory `/tmp/smartmontools'
g++ -DHAVE_CONFIG_H -I.  -DBUILD_INFO='"(local build)"' -DSMARTMONTOOLS_SYSCONFDIR='"/usr/local/e
tc"'    -I./getopt -DHAVE_GETOPT_LONG   -g -O2 -Wall -W -fno-strict-aliasing -MT smartd.o -MD -MP
 -MF .deps/smartd.Tpo -c -o smartd.o smartd.cpp
In file included from smartd.cpp:42:
./getopt/getopt.h:147: error: declaration of C function 'int getopt()' conflicts with
/usr/qnx650/target/qnx6/usr/include/unistd.h:501: error: previous declaration 'int getopt(int, ch
ar* const*, const char*)' here
make[2]: *** [smartd.o] Error 1
make[2]: Leaving directory `/tmp/smartmontools'
Making all in examplescripts
make[2]: Entering directory `/tmp/smartmontools/examplescripts'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/tmp/smartmontools/examplescripts'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/smartmontools'
make: *** [all] Error 2

Reason is that getopt() is also provided by QNX libs.
-> I uncommented line 147 in getopt.h to overcome this error, but I don't know
about compatibility. ( I added a patch with my change )

Another approach might be to not use the getopt sources from smartmontools but
use native getopt() and install libgetopt from pgksrc to get getopt_long instead.
What do you think?

in reply to:  8 ; comment:9 by Christian Franke, 14 years ago

Replying to stevestereo:

Reason is that getopt() is also provided by QNX libs.
-> I uncommented line 147 in getopt.h to overcome this error, but I don't know
about compatibility. ( I added a patch with my change )

With the following Makefile.am change (rerun ./autogen.sh) it might work without changing getopt.h:

 if NEED_GETOPT_LONG
-AM_CPPFLAGS += -I$(srcdir)/getopt -DHAVE_GETOPT_LONG
+AM_CPPFLAGS += -I$(srcdir)/getopt -DHAVE_GETOPT_LONG -D__GNU_LIBRARY__
 endif

-D__GNU_LIBRARY__ worked in the original patch, see ticket #68.

Another approach might be to not use the getopt sources from smartmontools but
use native getopt() and install libgetopt from pgksrc to get getopt_long instead.
What do you think?

smartmontools uses getopt_long() only, native getopt() is not needed. Using libgetopt should work without any changes to current SVN if libgetopt provides its own /LIBGETOPT_INCLUDE_DIR/getopt.h and smartmontools is configured with

./configure CPPFLAGS=-I/LIBGETOPT_INCLUDE_DIR

If this works we can add this setting to configure.in later.

in reply to:  9 comment:10 by stevestereo, 14 years ago

With the following Makefile.am change (rerun ./autogen.sh) it might work without changing getopt.h:

 if NEED_GETOPT_LONG
-AM_CPPFLAGS += -I$(srcdir)/getopt -DHAVE_GETOPT_LONG
+AM_CPPFLAGS += -I$(srcdir)/getopt -DHAVE_GETOPT_LONG -D__GNU_LIBRARY__
 endif

-D__GNU_LIBRARY__ worked in the original patch, see ticket #68.

smartmontools uses getopt_long() only, native getopt() is not needed. Using libgetopt should work without any changes to current SVN if libgetopt provides its own /LIBGETOPT_INCLUDE_DIR/getopt.h and smartmontools is configured with

./configure CPPFLAGS=-I/LIBGETOPT_INCLUDE_DIR

If this works we can add this setting to configure.in later.

Tried your proposal and it worked, here is what I did

# svn revert --recursive .        
# patch < configure-getopt.patch  
changed stated line in Makefile.am and added -D__GNU_LIBRARY__ manually
# ./autogen.sh                    
# ./configure CPPFLAGS=-I/LIBGETOPT_INCLUDE_DIR 
# make

getopt()does not conflict anymore

by stevestereo, 14 years ago

Attachment: configure-getopt-qnx.patch added

based on configure-getopt.patch but includes fix for getopt and missing cast in os_qnxnto.cpp

comment:11 by stevestereo, 14 years ago

created a patch with all the changes for getopt() and a missing cast
https://sourceforge.net/attachment/ticket/1/configure-getopt-qnx.patch
sequence which was working for me:

# svn revert --recursive .                      
Reverted 'configure.in'
Reverted 'os_qnxnto.cpp'
Reverted 'Makefile.am'
# patch < configure-getopt-qnx.patch 
patching file configure.in
patching file os_qnxnto.cpp
patching file Makefile.am
# ./autogen.sh
configure.in:33: installing `./config.guess'
configure.in:33: installing `./config.sub'
configure.in:23: installing `./install-sh'
configure.in:23: installing `./missing'
# ./configure
# make

Afterwards I was able to run smartctl -a /dev/hd0 within my virtualbox

# ./smartctl -a /dev/hd0 
smartctl 5.40 2010-05-13 r3107 [i386-pc-nto-qnx6.5.0] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Device Model:     VBOX HARDDISK
Serial Number:    VBbba89e3c-9d8b4274
Firmware Version: 1.0
User Capacity:    42,949,672,960 bytes
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   6
ATA Standard is:  ATA/ATAPI-6 published, ANSI INCITS 361-2002
Local Time is:    Mon May 24 17:54:13 2010 UTC
SMART support is: Unavailable - device lacks SMART capability.

Next step is to run it on a real QNX target...

comment:12 by Christian Franke, 14 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.