Bug report #2021

[FreeBSD] problem compiling Qgis with grass. Kpty.c qtermwidget

Added by slash - about 11 years ago. Updated over 10 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Build/Install
Affected QGIS version: Regression?:No
Operating System:FreeBSD Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:12081

Description

On FreeBSD 8.0RC1 (i don't know for older version) you can't compile Qgis with Grass option.
There is a problem with kpty.c file in qtermwidget

[ 77%] Building CXX object src/plugins/grass/CMakeFiles/grassplugin.dir/qtermwidget/kpty.o
/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp: In member function 'void KPty::login(const char*, const char*)':

/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:489: error: 'utmpname' was not declared in this scope
/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:490: error: 'setutent' was not declared in this scope

/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:491: error: 'pututline' was not declared in this scope
/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:492: error: 'endutent' was not declared in this scope

/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:493: error: 'updwtmp' was not declared in this scope
/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp: In member function 'void KPty::logout()':

/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:539: error: 'utmpname' was not declared in this scope
/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:540: error: 'setutent' was not declared in this scope

/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:541: error: 'getutline' was not declared in this scope
/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:558: error: 'pututline' was not declared in this scope

/usr/ports/graphics/qgis/work/qgis-1.3.0/src/plugins/grass/qtermwidget/kpty.cpp:560: error: 'endutent' was not declared in this scope
  • Error code 1

Stop in /usr/ports/graphics/qgis/work/qgis-1.3.0.

  • Error code 1
Stop in /usr/ports/graphics/qgis/work/qgis-1.3.0.
  • Error code 1
Stop in /usr/ports/graphics/qgis/work/qgis-1.3.0.
  • Error code 1
Stop in /usr/ports/graphics/qgis.
  • Error code 1

Stop in /usr/ports/graphics/qgis.

kpty.cpp Magnifier - The source code correct for FreeBSD (I hope) (17.7 KB) slash -, 2009-10-21 10:30 AM

freebsd_patch_qgis.tar.gz (7.56 KB) slash -, 2010-08-24 10:24 AM

History

#1 Updated by slash - about 11 years ago

I have found the problem by myself (and maybe the solution).

The file kpty.cpp in /qgis/src/plugins/grass/qtermwidget make a call to functions in utmp.h header of the GLIBC. setutent updwtmp & co...

In fact we don't have this functions in FreeBSD Headers.

So the solution is to copy/paste the code source of this functions in the ktpy file like in the attached file.

It's not beautiful but it works. I have can build install and use grass plugins without crash with this solutions.

Regards.

#2 Updated by Paolo Cavallini over 10 years ago

Still true fro current trunk?

#3 Updated by slash - over 10 years ago

Sorry, i was away from qgis for a time.

The bug is still true in the current trunk.

The solutions is the same :

QGis use some functions of the Glibc. If you see the man page of getutent & the others you have this disclaimer :

Portability Note: Although many operating systems provide a subset of these functions, they are not standardized. There are often subtle differences in the return types, and there are considerable differences between the various definitions of struct utmp. When programming for the GNU system, it is probably best to stick with the functions described in this section. If however, you want your program to be portable, consider using the XPG functions described in XPG Functions, or take a look at the BSD compatible functions in Logging In and Out.

You can also include the functions in other source code like this change i've made to compile with grass plugins on my FreeBSD :

Change in src/plugins/grass/qtermwidget/kpty.cpp :

--- src/plugins/grass/qtermwidget/kpty.cpp.orig 2010-08-24 18:47:22.000000000 0
+
+ src/plugins/grass/qtermwidget/kpty.cpp 2010-08-24 18:48:06.000000000 +0
@ -24,6 +24,10 @

#include "kpty_p.h"

#if defined(+FreeBSD)
#include "kpty_hack_for_bsd"
#endif

#ifdef +sgi
#define +svr4

#endif

New file in src/plugins/grass/qtermwidget/:
kpty_hack_for_bsd.h
kpty_hack_for_bsd.cpp

(this files includes functions getutent & other).

This solutions is sometimes used on BSD.

Also, i have add a path in the FindGRASS.cmake.

In the attach file (freebsd_patch_qgis.tar.gz) you have :

The diff file for FindGRASS.cmake with the 2 files (original and modified)
The diff file for src/plugins/grass/qtermwidget/ktpy.cpp with the 2 files (original and modified)
The new files in src/plugins/grass/qtermwidget/.

#4 Updated by Jürgen Fischer over 10 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

should be fixed with dd614ec7 (SVN r14147).

Also available in: Atom PDF