Board index FlightGear Support Compiling

Problems with porting regex to nasal

Building FlightGear from source, and in the need for help?

Problems with porting regex to nasal

Postby www2 » Mon Jan 01, 2018 7:19 pm

Hi i have a problem with porting the regex library from the nasal source code to simgear/flightgear.
After an good run compiling simgear i get an strange error flightgear in a area that i have never touch any code
Code: Select all
Linking CXX executable test_flightplan
libfgtestlib.so: undefined reference to `pcre_exec'
libfgtestlib.so: undefined reference to `pcre_study'
libfgtestlib.so: undefined reference to `pcre_free'
libfgtestlib.so: undefined reference to `pcre_compile'


the only change in fgfs that i have done is add this line between line 874 and line 880 in NasalSys.cxx
Code: Select all
hashset(_globals, "re", naInit_regex(_context));


buildlog
Code: Select all
./download_and_compile.sh FGFS
VERSION=0e43ff4ed5a91be9ba8c24bf06b9f2e55353f58f
APT_GET_UPDATE=n
DOWNLOAD_PACKAGES=n
COMPILE=y
RECONFIGURE=y
DOWNLOAD=n
JOPTION=
OOPTION=
BUILD_TYPE=RelWithDebInfo
***********************************
Considering a package alternative: libopenscenegraph-3.4-dev libopenscenegraph-dev libopenscenegraph-[0-9]+\.[0-9]+-dev
Package alternative matched for libopenscenegraph-3.4-dev
Considering a package alternative: libpng-dev libpng12-dev libpng16-dev
Package alternative matched for libpng-dev
Considering an optional package alternative: qtdeclarative5-private-dev
Optional package alternative matched for qtdeclarative5-private-dev
Considering an optional package alternative: qml-module-qtquick2
Optional package alternative matched for qml-module-qtquick2
DIRECTORY= /home/user-name/fgfs
***********************************
****************************************
************** FLIGHTGEAR **************
****************************************
CMAKE Build type: RelWithDebInfo
-- Setting build type to 'Dev' as none was specified.
-- System is: Linux
-- Linux distro is: Ubuntu
-- Web browser launcher command is: xdg-open
-- Using default data directory for base package:  /home/user-name/fgfs/install/flightgear/lib/FlightGear
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- libudev stable: 1
-- Found UDev: /lib/x86_64-linux-gnu/libudev.so
--    include: /usr/include
-- Found Git: /usr/bin/git 
-- Git revision is 31de119169ed935d29342ec8f2514370f02c3604
-- event-based input enabled. Using /lib/x86_64-linux-gnu/libudev.so
-- Boost version: 1.62.0
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so 
-- Found osgText: /usr/lib/x86_64-linux-gnu/libosgText.so 
-- Found osgSim: /usr/lib/x86_64-linux-gnu/libosgSim.so 
-- Found osgDB: /usr/lib/x86_64-linux-gnu/libosgDB.so 
-- Found osgParticle: /usr/lib/x86_64-linux-gnu/libosgParticle.so 
-- Found osgFX: /usr/lib/x86_64-linux-gnu/libosgFX.so 
-- Found osgUtil: /usr/lib/x86_64-linux-gnu/libosgUtil.so 
-- Found osgViewer: /usr/lib/x86_64-linux-gnu/libosgViewer.so 
-- Found osgGA: /usr/lib/x86_64-linux-gnu/libosgGA.so 
-- Found osg: /usr/lib/x86_64-linux-gnu/libosg.so 
-- Found OpenThreads: /usr/lib/x86_64-linux-gnu/libOpenThreads.so 
-- Found OpenSceneGraph: /usr/lib/x86_64-linux-gnu/libosgText.so;/usr/lib/x86_64-linux-gnu/libosgSim.so;/usr/lib/x86_64-linux-gnu/libosgDB.so;/usr/lib/x86_64-linux-gnu/libosgParticle.so;/usr/lib/x86_64-linux-gnu/libosgFX.so;/usr/lib/x86_64-linux-gnu/libosgUtil.so;/usr/lib/x86_64-linux-gnu/libosgViewer.so;/usr/lib/x86_64-linux-gnu/libosgGA.so;/usr/lib/x86_64-linux-gnu/libosg.so;/usr/lib/x86_64-linux-gnu/libOpenThreads.so (found suitable version "3.4.0", minimum required is "3.2.0")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'dbus-1'
--   Found dbus-1, version 1.10.10
-- Using DBus
-- Qt launcher enabled, checking for Qt 5.4 / qmake
-- Will enable Qt launcher GUI
--   Qt5Widgets version: 5.7.1
--   Qt5Widgets include dir: /usr/include/x86_64-linux-gnu/qt5/;/usr/include/x86_64-linux-gnu/qt5/QtWidgets;/usr/include/x86_64-linux-gnu/qt5/QtGui;/usr/include/x86_64-linux-gnu/qt5/QtCore;/usr/lib/x86_64-linux-gnu/qt5//mkspecs/linux-g++-64;/usr/include
-- Checking whether private include directories for module Qt5Gui exist
--   Qt5Quick private include dir: /usr/include/x86_64-linux-gnu/qt5/QtQuick/5.7.1;/usr/include/x86_64-linux-gnu/qt5/QtQuick/5.7.1/QtQuick;/usr/include/x86_64-linux-gnu/qt5/QtQml/5.7.1;/usr/include/x86_64-linux-gnu/qt5/QtQml/5.7.1/QtQml;/usr/include/x86_64-linux-gnu/qt5/QtNetwork/5.7.1;/usr/include/x86_64-linux-gnu/qt5/QtNetwork/5.7.1/QtNetwork;/usr/include/x86_64-linux-gnu/qt5/QtCore/5.7.1;/usr/include/x86_64-linux-gnu/qt5/QtCore/5.7.1/QtCore;/usr/include/x86_64-linux-gnu/qt5/QtGui/5.7.1;/usr/include/x86_64-linux-gnu/qt5/QtGui/5.7.1/QtGui
-- /usr/include
-- adding runtime JS dependencies
-- Found PLIB: optimized;/usr/lib/libplibpuaux.so;debug;/usr/lib/libplibpuaux.so;optimized;/usr/lib/libplibjs.so;debug;/usr/lib/libplibjs.so;optimized;/usr/lib/libplibpu.so;debug;/usr/lib/libplibpu.so;optimized;/usr/lib/libplibfnt.so;debug;/usr/lib/libplibfnt.so;optimized;/usr/lib/libplibsg.so;debug;/usr/lib/libplibsg.so;optimized;/usr/lib/libplibul.so;debug;/usr/lib/libplibul.so 
-- Min Simgear version is 2017.4.0
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for windows.h
-- Looking for windows.h - not found
-- RTI: DISABLED
-- OpenMP: DISABLED
-- SSE/SSE2 support: ENABLED
-- Looking for mkfifo
-- Looking for mkfifo - found
-- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.6.34")
-- Found GLEW: /usr/include 
-- Found Freetype: /usr/lib/x86_64-linux-gnu/libfreetype.so 
-- Found GLUT: /usr/lib/x86_64-linux-gnu/libglut.so 
-- found GLUT inc /usr/include, lib /usr/lib/x86_64-linux-gnu/libglut.so;/usr/lib/x86_64-linux-gnu/libXmu.so;/usr/lib/x86_64-linux-gnu/libXi.so
-- Found OpenAL: /usr/lib/x86_64-linux-gnu/libopenal.so 
-- Tests: ENABLED
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user-name/fgfs/build/flightgear
MAKE flightgear
[  0%] Built target fgsqlite3
[  7%] Built target iaxclient_lib
[ 12%] Built target flite_hts
[ 13%] Built target hts_engine
[ 13%] Built target fgelev
[ 15%] Built target fgpanel
[ 16%] Built target fgviewer
[ 17%] Built target UGsmooth
[ 17%] Built target MIDGsmooth
[ 17%] Built target GPSsmooth
Scanning dependencies of target fgcom
[ 17%] Building CXX object utils/fgcom/CMakeFiles/fgcom.dir/fgcom.cxx.o
[ 17%] Linking CXX executable fgcom
[ 17%] Built target fgcom
[ 17%] Built target fgtraffic
Scanning dependencies of target fgtestlib
[ 17%] Building CXX object tests/CMakeFiles/fgtestlib.dir/__/src/Scripting/NasalSys.cxx.o
[ 17%] Linking CXX shared library libfgtestlib.so
[ 25%] Built target fgtestlib
[ 25%] Linking CXX executable test_flightplan
libfgtestlib.so: undefined reference to `pcre_exec'
libfgtestlib.so: undefined reference to `pcre_study'
libfgtestlib.so: undefined reference to `pcre_free'
libfgtestlib.so: undefined reference to `pcre_compile'
collect2: error: ld returned 1 exit status
tests/CMakeFiles/test_flightplan.dir/build.make:99: recept voor doel 'tests/test_flightplan' is mislukt
make[2]: *** [tests/test_flightplan] Fout 1
CMakeFiles/Makefile2:1886: recept voor doel 'tests/CMakeFiles/test_flightplan.dir/all' is mislukt
make[1]: *** [tests/CMakeFiles/test_flightplan.dir/all] Fout 2
Makefile:149: recept voor doel 'all' is mislukt
make: *** [all] Fout 2
INSTALL flightgear
[  0%] Built target fgsqlite3
[  7%] Built target iaxclient_lib
[ 12%] Built target flite_hts
[ 13%] Built target hts_engine
[ 13%] Built target fgelev
[ 15%] Built target fgpanel
[ 16%] Built target fgviewer
[ 17%] Built target UGsmooth
[ 17%] Built target MIDGsmooth
[ 17%] Built target GPSsmooth
[ 17%] Built target fgcom
[ 17%] Built target fgtraffic
[ 25%] Built target fgtestlib
[ 25%] Linking CXX executable test_flightplan
libfgtestlib.so: undefined reference to `pcre_exec'
libfgtestlib.so: undefined reference to `pcre_study'
libfgtestlib.so: undefined reference to `pcre_free'
libfgtestlib.so: undefined reference to `pcre_compile'
collect2: error: ld returned 1 exit status
tests/CMakeFiles/test_flightplan.dir/build.make:99: recept voor doel 'tests/test_flightplan' is mislukt
make[2]: *** [tests/test_flightplan] Fout 1
CMakeFiles/Makefile2:1886: recept voor doel 'tests/CMakeFiles/test_flightplan.dir/all' is mislukt
make[1]: *** [tests/CMakeFiles/test_flightplan.dir/all] Fout 2
Makefile:149: recept voor doel 'all' is mislukt
make: *** [all] Fout 2
***********************************
All optional package alternatives have found a matching package.
www2
 
Posts: 319
Joined: Thu Apr 16, 2009 2:58 pm
OS: Ubuntu

Re: Problems with porting regex to nasal

Postby Hooray » Mon Jan 01, 2018 7:46 pm

Just like I said to you in the last few PMs: neither the SQLite, nor the pcre, lib are actually bindings that are by default available (used) by FlightGear (or SimGear for that matter).
To change that (for whatever reason), you would have to look up Andy's original github repo, and add the bindings, as well as the underlying libs (pcre & sqlite) to the build system (cmake in the case of sg/fg).

Regarding the time it takes to build the whole thing, you don't need simgear-scene (opengl stuff) - you can just build the headless stuff, see: http://wiki.flightgear.org/Building_usi ... ld_Targets
That would also be the most correct way to integrate everything, as a cmake option: http://wiki.flightgear.org/Developing_using_CMake

Other than that, things should just work - the link to the standalone nasal interpreter (based on simgear) should be a good starting point actually.
If I remember correctly, the treading library integration should also be suitable to serve as reference.


In other words, the correct order to proceed with this, would be:

1) fix up the cmake system to add the libs that you need (sqlite/pcre) => that in and of itself should already build just fine
2) next, add the source files that link in the bindings => that should also build "as is"
3) finally, the naInit* stuff is what is needed to call any module specific initialization logic

By the way, what you are doing/trying to do isn't "porting regex to nasal"; but rather integrating the existing regex/sqlite bindings into SimGear/FlightGear

If in doubt, refer to Andy's github repo and its nasal-main.c there (IIRC)

http://www.gitorious.org/fg/nasal-core- ... one-sg-3.1

PS: Like I also said previously, I highly dount that the sqlite bindings will be useful, particularly if you are planning on using them in conjunction with the navdb/navcache stuff
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Problems with porting regex to nasal

Postby Alant » Mon Jan 01, 2018 11:38 pm

Perhaps you should ask this on the devel email list as only last week changes were made to flightgear/simgear regex code.

Alan
Alant
 
Posts: 1219
Joined: Wed Jun 23, 2010 6:58 am
Location: Portugal
Callsign: Tarnish99
Version: latest Git
OS: Windows 10/11

Re: Problems with porting regex to nasal

Postby Hooray » Mon Jan 01, 2018 11:47 pm

Actually, according to the posting, he is is trying to integrate the existing PCRE support into FlightGear: https://github.com/andyross/nasal/blob/ ... regexlib.c
The SimGear related regex changes were about something entirely else, i.e. the addon framework - unrelated to the Nasal engine: https://sourceforge.net/p/flightgear/si ... 687f0eba7/
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Problems with porting regex to nasal

Postby Alant » Tue Jan 02, 2018 12:22 am

OK, sorry for the noise.

However I still think that it might be better raising this type of question on the devel list as it involves source code changes.

Alan
Alant
 
Posts: 1219
Joined: Wed Jun 23, 2010 6:58 am
Location: Portugal
Callsign: Tarnish99
Version: latest Git
OS: Windows 10/11

Re: Problems with porting regex to nasal

Postby www2 » Tue Jan 02, 2018 2:20 am

I rebuild with a clean source tree for simgear and flight gear and i get the same problem

here is my current log output:
Code: Select all
Linking CXX executable test_flightplan
libfgtestlib.so: undefined reference to `pcre_exec'
libfgtestlib.so: undefined reference to `pcre_study'
libfgtestlib.so: undefined reference to `pcre_free'
libfgtestlib.so: undefined reference to `pcre_compile'
collect2: error: ld returned 1 exit status
tests/CMakeFiles/test_flightplan.dir/build.make:99: recept voor doel 'tests/test_flightplan' is mislukt
make[2]: *** [tests/test_flightplan] Fout 1
CMakeFiles/Makefile2:1886: recept voor doel 'tests/CMakeFiles/test_flightplan.dir/all' is mislukt
make[1]: *** [tests/CMakeFiles/test_flightplan.dir/all] Fout 2
Makefile:149: recept voor doel 'all' is mislukt
make: *** [all] Fout 2
All optional package alternatives have found a matching package.


here is the diff file for simgear:
Code: Select all
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bbf4e46c..8cbf439a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -299,6 +299,7 @@ if (NOT MSVC)
   endif()
 endif()
 
+
 if(HAVE_UNISTD_H)
     set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
     check_cxx_source_compiles(
@@ -438,6 +439,14 @@ else()
     message(STATUS "OpenMP: DISABLED")
 endif()
 
+
+find_package(PCRE REQUIRED)
+if(PCRE_FOUND)
+ message(STATUS "Okay, PCRE found via CMake:${PCRE_LIBRARY}")
+endif(PCRE_FOUND)
+
+
+
 if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
 # boost goes haywire wrt static asserts
     check_cxx_compiler_flag(-Wno-unused-local-typedefs HAS_NOWARN_UNUSED_TYPEDEFS)
diff --git a/CMakeModules/FindPCRE.cmake b/CMakeModules/FindPCRE.cmake
new file mode 100644
index 00000000..da7d6349
--- /dev/null
+++ b/CMakeModules/FindPCRE.cmake
@@ -0,0 +1,58 @@
+#
+# $Id$
+#
+# - Find pcre
+# Find the native PCRE includes and library
+#
+#  PCRE_INCLUDE_DIR  - where to find pcre.h, etc.
+#  PCRE_LIBRARY      - Path to the pcre library.
+#  PCRE_FOUND        - True if pcre found.
+
+
+IF (PCRE_INCLUDE_DIR)
+  # Already in cache, be silent
+  SET(PCRE_FIND_QUIETLY TRUE)
+ENDIF (PCRE_INCLUDE_DIR)
+
+FIND_PATH(SYSTEM_PCRE_INCLUDE_DIR pcre.h)
+
+SET(PCRE_NAMES pcre)
+FIND_LIBRARY(SYSTEM_PCRE_LIBRARY NAMES ${PCRE_NAMES} )
+
+# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+  PCRE DEFAULT_MSG SYSTEM_PCRE_LIBRARY SYSTEM_PCRE_INCLUDE_DIR
+)
+
+# Make sure it's got the jit enabled. If not, don't use it.
+IF (PCRE_FOUND)
+  INCLUDE(CheckCSourceRuns)
+  SET(CMAKE_REQUIRED_LIBRARIES pcre)
+  CHECK_C_SOURCE_RUNS("#include <pcre.h>
+int main() {
+  int has_jit = 0;
+  pcre_config(PCRE_CONFIG_JIT, &has_jit);
+  return has_jit ? 0 : 1;
+}
+" SYSTEM_PCRE_HAS_JIT)
+ENDIF (PCRE_FOUND)
+
+IF(NOT SYSTEM_PCRE_HAS_JIT)
+  MESSAGE(STATUS
+    "System PCRE does not have JIT enabled - will use hhvm-third-party/pcre")
+  UNSET(PCRE_INCLUDE_DIR CACHE)
+  UNSET(PCRE_LIBRARY CACHE)
+
+  # This is used to configure bundled pcre
+  SET(PCRE_SUPPORT_JIT ON CACHE BOOL "")
+  SET(PCRE_SUPPORT_UTF ON CACHE BOOL "")
+  SET(PCRE_SUPPORT_UNICODE_PROPERTIES ON CACHE BOOL "")
+ELSE()
+  SET(PCRE_INCLUDE_DIR ${SYSTEM_PCRE_INCLUDE_DIR}
+    CACHE PATH "PCRE include directory")
+  SET(PCRE_LIBRARY ${SYSTEM_PCRE_LIBRARY} CACHE FILEPATH "PCRE library")
+ENDIF()
+
+MARK_AS_ADVANCED( PCRE_LIBRARY PCRE_INCLUDE_DIR )
diff --git a/simgear/nasal/CMakeLists.txt b/simgear/nasal/CMakeLists.txt
index 8f4d2c90..06a77e83 100644
--- a/simgear/nasal/CMakeLists.txt
+++ b/simgear/nasal/CMakeLists.txt
@@ -19,6 +19,7 @@ set(SOURCES
     mathlib.c
     misc.c
     parse.c
+    regexlib.c
     string.c
     thread-posix.c
     thread-win32.c
diff --git a/simgear/nasal/regexlib.c b/simgear/nasal/regexlib.c
new file mode 100644
index 00000000..7cab8e10
--- /dev/null
+++ b/simgear/nasal/regexlib.c
@@ -0,0 +1,85 @@
+#include <pcre.h>
+#include <string.h>
+#include "data.h"
+
+static void regexDestroy(void* r);
+static const naGhostType naRegexGhostType = { regexDestroy, "regex" };
+
+struct Regex {
+    pcre* re;
+    pcre_extra* extra;
+};
+
+static int parseOpts(naContext c, char* s)
+{
+    int opts = 0;
+    while(*s) {
+        switch(*s++) {
+        case 'i': opts |= PCRE_CASELESS; break;
+        case 'm': opts |= PCRE_MULTILINE; break;
+        case 's': opts |= PCRE_DOTALL; break;
+        case 'x': opts |= PCRE_EXTENDED; break;
+        default: naRuntimeError(c, "unrecognized regex option");
+        }
+    }
+    return opts;
+}
+
+static naRef f_comp(naContext c, naRef me, int argc, naRef* args)
+{
+    int erroff, opts = 0;
+    const char* errptr;
+    struct Regex* regex;
+    naRef pat = argc > 0 ? naStringValue(c, args[0]) : naNil();
+    naRef optr = argc > 1 ? args[1] : naNil();
+    if(!IS_STR(pat) || (!IS_NIL(optr) && !IS_STR(optr)))
+        naRuntimeError(c, "bad arg to regex.comp");
+    if(IS_STR(optr)) opts = parseOpts(c, naStr_data(optr));
+    regex = naAlloc(sizeof(struct Regex));
+    regex->re = pcre_compile(naStr_data(pat), opts, &errptr, &erroff, 0);
+    if(regex->re == 0) {
+        naFree(regex);
+        naRuntimeError(c, "bad regex"); // FIXME: expose errptr/erroff
+    }
+    regex->extra = pcre_study(regex->re, 0, &errptr);
+    return naNewGhost(c, (void*)&naRegexGhostType, regex);
+}
+
+static naRef f_exec(naContext c, naRef me, int argc, naRef* args)
+{
+    int i, n, i0, ovector[30];
+    struct Regex* r = argc > 0 ? naGhost_ptr(args[0]) : 0;
+    naRef result, str = argc > 1 ? naStringValue(c, args[1]) : naNil();
+    naRef start = argc > 2 ? naNumValue(args[2]) : naNum(0);
+    if(!r || naGhost_type(args[0]) != &naRegexGhostType || !IS_NUM(start))
+        naRuntimeError(c, "bad argument to regex.study");
+    i0 = (int)start.num;
+    n = pcre_exec(r->re, r->extra, naStr_data(str)+i0,
+                  naStr_len(str)-i0, 0, 0, ovector, 30);
+    result = naNewVector(c);
+    if(n > 0) {
+        naVec_setsize(c, result, n*2);
+        for(i=0; i<2*n; i++) naVec_set(result, i, naNum(ovector[i]+i0));
+    }
+    return result;
+}
+
+static void regexDestroy(void* r)
+{
+    struct Regex* regex = (struct Regex*)r;
+    pcre_free(regex->re);
+    if(regex->extra) pcre_free(regex->extra);
+    naFree(regex);
+}
+
+static naCFuncItem funcs[] = {
+    { "comp", f_comp },
+    { "exec", f_exec },
+    { 0 }
+};
+
+naRef naInit_regex(naContext c)
+{
+    naRef ns = naGenLib(c, funcs);
+    return ns;
+}


and the diff for flightgear
Code: Select all
diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx
index e1e156df9..0fa1393ae 100644
--- a/src/Scripting/NasalSys.cxx
+++ b/src/Scripting/NasalSys.cxx
@@ -875,6 +875,7 @@ void FGNasalSys::init()
     hashset(_globals, "math", naInit_math(_context));
     hashset(_globals, "bits", naInit_bits(_context));
     hashset(_globals, "io", naInit_io(_context));
+    hashset(_globals, "re", naInit_regex(_context));
     hashset(_globals, "thread", naInit_thread(_context));
     hashset(_globals, "utf8", naInit_utf8(_context));
 


edit re is current only for testing purpose if i have fix this problem i change re to regex.
www2
 
Posts: 319
Joined: Thu Apr 16, 2009 2:58 pm
OS: Ubuntu

Re: Problems with porting regex to nasal

Postby Hooray » Tue Jan 02, 2018 2:22 am

Please see my original respone, like I said already, you also need to link in the regex library itself (pcre).
If in doubt, refer to the original Makefile, then look up the cmake related links I posted to adapt the CMakeLists.txt file accordingly.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Problems with porting regex to nasal

Postby www2 » Tue Jan 02, 2018 4:57 am

@Hooray
I can not isolate my problem.

this is a clean build of FGFS
Code: Select all
[ 97%] Building CXX object src/Main/CMakeFiles/fgfs.dir/__/Viewer/viewmgr.cxx.o
[ 98%] Building CXX object src/Main/CMakeFiles/fgfs.dir/__/Viewer/GraphicsWindowQt5.cpp.o
[ 98%] Building CXX object src/Main/CMakeFiles/fgfs.dir/__/Viewer/PUICamera.cxx.o
[ 98%] Building CXX object src/Main/CMakeFiles/fgfs.dir/fgfs_automoc.cpp.o
[ 98%] Linking CXX executable fgfs
/usr/bin/ld: /home/user-name/fgfs/install/simgear/lib/libSimGearCore.a(regexlib.c.o): undefined reference to symbol 'pcre_study'
//lib/x86_64-linux-gnu/libpcre.so.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
src/Main/CMakeFiles/fgfs.dir/build.make:12680: recept voor doel 'src/Main/fgfs' is mislukt
make[2]: *** [src/Main/fgfs] Fout 1
CMakeFiles/Makefile2:3289: recept voor doel 'src/Main/CMakeFiles/fgfs.dir/all' is mislukt
make[1]: *** [src/Main/CMakeFiles/fgfs.dir/all] Fout 2
Makefile:160: recept voor doel 'all' is mislukt
make: *** [all] Fout 2
[  0%] Built target fgsqlite3
[  7%] Built target iaxclient_lib
[ 12%] Built target flite_hts
[ 13%] Built target hts_engine
[ 13%] Built target fgelev
[ 15%] Built target fgpanel
[ 15%] Built target fgviewer
[ 15%] Built target UGsmooth
[ 16%] Built target MIDGsmooth
[ 16%] Built target GPSsmooth
[ 16%] Built target fgcom
[ 17%] Built target fgtraffic
[ 25%] Built target fgtestlib
[ 25%] Linking CXX executable test_flightplan
libfgtestlib.so: undefined reference to `pcre_exec'
libfgtestlib.so: undefined reference to `pcre_study'
libfgtestlib.so: undefined reference to `pcre_free'
libfgtestlib.so: undefined reference to `pcre_compile'
collect2: error: ld returned 1 exit status
tests/CMakeFiles/test_flightplan.dir/build.make:99: recept voor doel 'tests/test_flightplan' is mislukt
make[2]: *** [tests/test_flightplan] Fout 1
CMakeFiles/Makefile2:1814: recept voor doel 'tests/CMakeFiles/test_flightplan.dir/all' is mislukt
make[1]: *** [tests/CMakeFiles/test_flightplan.dir/all] Fout 2
Makefile:160: recept voor doel 'all' is mislukt
www2
 
Posts: 319
Joined: Thu Apr 16, 2009 2:58 pm
OS: Ubuntu

Re: Problems with porting regex to nasal

Postby Hooray » Tue Jan 02, 2018 12:49 pm

I have already provided the correct, and working, answer - you also need to link in the regex library itself - which is usually done by modifying CMakeListst.txt accordingly.
Honestly, you could save yourself quite a bit of time by reading what I posted or at least asking for clarification if you don't understand something I posted.

I suggest to re-read my responses so far, and then run a google search: http://lmgtfy.com/?q=cmake+linking+to+pcre+library
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Problems with porting regex to nasal

Postby www2 » Tue Jan 02, 2018 10:59 pm

Current stauts is building and exec flightgear but whene i enter regex.comp("som value") and hit enter than crash flightgear.
www2
 
Posts: 319
Joined: Thu Apr 16, 2009 2:58 pm
OS: Ubuntu

Re: Problems with porting regex to nasal

Postby Hooray » Tue Jan 02, 2018 11:02 pm

so, congratulations - it seems, you fixed the build issue then ?
If so, my suggestion would be to ignore FlightGear for now, and focus on just Nasal/SimGear - and get the standalone version working first.
For instance, the Nasal unit tests doing regex, should also work in your SimGear version: https://github.com/andyross/nasal/blob/ ... x-test.nas
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU


Return to Compiling

Who is online

Users browsing this forum: No registered users and 3 guests