Errors when building kxsldbg and quanta #42

Closed
opened 1 month ago by ormorph · 9 comments
Collaborator

I made another update and decided to remove TDE completely and rebuild it again. Got several errors.
Kxsldbg

FAILED: kxsldbg/CMakeFiles/xsldbg.dir/xsldbgmain.cpp.o 
/usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -I/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999_build -I/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999_build/kxsldbg -I/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg -isystem /usr/trinity/14/include -isystem /usr/tqt3/include -isystem /usr/include/tqt -isystem /usr/include/libxml2  -O2 -pipe -g -std=c++11 -fdebug-prefix-map=/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999=. -fmacro-prefix-map=/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999=.  -DTQT_NO_ASCII_CAST -DTQT_NO_STL -DTQT_NO_COMPAT -DTQT_NO_TRANSLATION -DTQT_THREAD_SUPPORT -D_REENTRANT -I/usr/tqt3/include -I/usr/include/tqt -include tqt.h -DTQT_NO_ASCII_CAST -DTQT_NO_STL -DTQT_NO_COMPAT -DTQT_NO_TRANSLATION -DTQT_THREAD_SUPPORT -D_REENTRANT -include tqt.h -DNDEBUG -MD -MT kxsldbg/CMakeFiles/xsldbg.dir/xsldbgmain.cpp.o -MF kxsldbg/CMakeFiles/xsldbg.dir/xsldbgmain.cpp.o.d -o kxsldbg/CMakeFiles/xsldbg.dir/xsldbgmain.cpp.o -c /var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp
/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp: In function ‘xmlChar* xslDbgShellReadlineSimple(xmlChar*)’:
/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp:195:11: error: ‘free’ was not declared in this scope
  195 |           free(temp);
      |           ^~~~
/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp:42:1: note: ‘free’ is defined in header ‘<cstdlib>’; did you forget to ‘#include <cstdlib>’?
   41 | #include <kdebug.h>
  +++ |+#include <cstdlib>
   42 | /* Forward delare private functions */
/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp:197:11: error: ‘free’ was not declared in this scope
  197 |           free(line_read);

I solved the problem of assembling Kxsldbg using the patch:

--- a/kxsldbg/kxsldbgpart/libxsldbg/files.cpp	2024-03-17 14:07:04.763235488 +0300
+++ b/kxsldbg/kxsldbgpart/libxsldbg/files.cpp	2024-03-17 14:11:04.759225450 +0300
@@ -37,6 +37,8 @@
 #endif
 
 #endif /* BUILD_DOCS */
+#include <unistd.h>
+#include <cstdlib>
 
 
 /* top xml document */
--- a/kxsldbg/kxsldbgpart/libxsldbg/files_unix.cpp	2024-03-17 14:07:04.763235488 +0300
+++ b/kxsldbg/kxsldbgpart/libxsldbg/files_unix.cpp	2024-03-17 14:07:15.004235059 +0300
@@ -21,6 +21,7 @@
 #include "files.h"
 #include "utils.h"
 #include "options.h"
+#include <cstdlib>
 
 static char *tempNames[2] = { NULL, NULL };
 
--- a/kxsldbg/kxsldbgpart/libxsldbg/options.cpp	2024-03-17 14:07:04.763235488 +0300
+++ b/kxsldbg/kxsldbgpart/libxsldbg/options.cpp	2024-03-17 14:07:15.006235059 +0300
@@ -27,6 +27,7 @@
 #include <kstandarddirs.h> 
 #include <tqfileinfo.h>
 #include <tqstringlist.h>
+#include <cstdlib>
 
 
 /* keep track of our integer/boolean options */
--- a/kxsldbg/kxsldbgpart/libxsldbg/os_cmds.cpp	2024-03-17 14:07:04.763235488 +0300
+++ b/kxsldbg/kxsldbgpart/libxsldbg/os_cmds.cpp	2024-03-17 14:07:15.007235059 +0300
@@ -19,6 +19,7 @@
 #include "xsldbg.h"
 #include "debugXSL.h"
 #include "files.h"
+#include <cstdlib>
 
 /* -----------------------------------------
 
--- a/kxsldbg/kxsldbgpart/libxsldbg/xsldbg.cpp	2024-03-17 14:07:04.764235488 +0300
+++ b/kxsldbg/kxsldbgpart/libxsldbg/xsldbg.cpp	2024-03-17 14:07:15.008235059 +0300
@@ -39,6 +39,7 @@
 #include "files.h"
 #include "breakpoint.h"
 #include "debugXSL.h"
+#include <cstdlib>
 
 #include <libxml/xmlerror.h>
 #include "xsldbgmsg.h"
--- a/kxsldbg/xsldbgmain.cpp	2024-03-17 14:07:04.769235487 +0300
+++ b/kxsldbg/xsldbgmain.cpp	2024-03-17 14:07:15.009235059 +0300
@@ -39,6 +39,7 @@
 #include <tdelocale.h>
 #include <tdeglobal.h>
 #include <kdebug.h>
+#include <cstdlib>
 /* Forward delare private functions */
 static int notifyXsldbgAppSimple(XsldbgMessageEnum type, const void *data);
 static int notifyStateXsldbgAppSimple(XsldbgMessageEnum type, int commandId,

Apparently gcc-13.2.1 now works a little differently, as does clang-17. For clang I had to add the line #include <unistd.h>, since clang complained about the lack of chdir. I don’t know what changes this is connected with.

Error while building Quanta:

/var/tmp/portage/trinity-base/quanta-9999/work/quanta-9999/quanta/parsers/dtd/dtdparser.cpp:85:43: error: invalid conversion from ‘const xmlError*’ {aka ‘const _xmlError*’} to ‘xmlErrorPtr’ {aka ‘_xmlError*’} [-fpermissive]
   85 |     xmlErrorPtr errorPtr = xmlGetLastError();
      |                            ~~~~~~~~~~~~~~~^~
      |                                           |
      |                                           const xmlError* {aka const _xmlError*}

Since libxml2-2.12.0, the xmlGetLastError() function returns a const xmlError*. I applied this patch as a temporary solution:

--- a/quanta/parsers/dtd/dtdparser.cpp	2024-03-17 13:27:56.963333679 +0300
+++ b/quanta/parsers/dtd/dtdparser.cpp	2024-03-17 13:44:18.786292617 +0300
@@ -82,7 +82,9 @@
   if( DTD::dtd_ptr == NULL )
   {
     TQString errorStr = i18n("Unknown");
-    xmlErrorPtr errorPtr = xmlGetLastError();
+    xmlErrorPtr errorPtr;
+    const xmlError* errorConst = xmlGetLastError();
+    xmlCopyError(errorConst, errorPtr);
     if (errorPtr != NULL)
     {
       TQString s = TQString::fromLatin1(errorPtr->message);

This requires detailed consideration. The error is reproduced on both the stable version and the live version.

I made another update and decided to remove TDE completely and rebuild it again. Got several errors. **Kxsldbg** ``` FAILED: kxsldbg/CMakeFiles/xsldbg.dir/xsldbgmain.cpp.o /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -I/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999_build -I/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999_build/kxsldbg -I/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg -isystem /usr/trinity/14/include -isystem /usr/tqt3/include -isystem /usr/include/tqt -isystem /usr/include/libxml2 -O2 -pipe -g -std=c++11 -fdebug-prefix-map=/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999=. -fmacro-prefix-map=/var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999=. -DTQT_NO_ASCII_CAST -DTQT_NO_STL -DTQT_NO_COMPAT -DTQT_NO_TRANSLATION -DTQT_THREAD_SUPPORT -D_REENTRANT -I/usr/tqt3/include -I/usr/include/tqt -include tqt.h -DTQT_NO_ASCII_CAST -DTQT_NO_STL -DTQT_NO_COMPAT -DTQT_NO_TRANSLATION -DTQT_THREAD_SUPPORT -D_REENTRANT -include tqt.h -DNDEBUG -MD -MT kxsldbg/CMakeFiles/xsldbg.dir/xsldbgmain.cpp.o -MF kxsldbg/CMakeFiles/xsldbg.dir/xsldbgmain.cpp.o.d -o kxsldbg/CMakeFiles/xsldbg.dir/xsldbgmain.cpp.o -c /var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp /var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp: In function ‘xmlChar* xslDbgShellReadlineSimple(xmlChar*)’: /var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp:195:11: error: ‘free’ was not declared in this scope 195 | free(temp); | ^~~~ /var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp:42:1: note: ‘free’ is defined in header ‘<cstdlib>’; did you forget to ‘#include <cstdlib>’? 41 | #include <kdebug.h> +++ |+#include <cstdlib> 42 | /* Forward delare private functions */ /var/tmp/portage/trinity-base/kxsldbg-9999/work/kxsldbg-9999/kxsldbg/xsldbgmain.cpp:197:11: error: ‘free’ was not declared in this scope 197 | free(line_read); ``` I solved the problem of assembling Kxsldbg using the patch: ``` --- a/kxsldbg/kxsldbgpart/libxsldbg/files.cpp 2024-03-17 14:07:04.763235488 +0300 +++ b/kxsldbg/kxsldbgpart/libxsldbg/files.cpp 2024-03-17 14:11:04.759225450 +0300 @@ -37,6 +37,8 @@ #endif #endif /* BUILD_DOCS */ +#include <unistd.h> +#include <cstdlib> /* top xml document */ --- a/kxsldbg/kxsldbgpart/libxsldbg/files_unix.cpp 2024-03-17 14:07:04.763235488 +0300 +++ b/kxsldbg/kxsldbgpart/libxsldbg/files_unix.cpp 2024-03-17 14:07:15.004235059 +0300 @@ -21,6 +21,7 @@ #include "files.h" #include "utils.h" #include "options.h" +#include <cstdlib> static char *tempNames[2] = { NULL, NULL }; --- a/kxsldbg/kxsldbgpart/libxsldbg/options.cpp 2024-03-17 14:07:04.763235488 +0300 +++ b/kxsldbg/kxsldbgpart/libxsldbg/options.cpp 2024-03-17 14:07:15.006235059 +0300 @@ -27,6 +27,7 @@ #include <kstandarddirs.h> #include <tqfileinfo.h> #include <tqstringlist.h> +#include <cstdlib> /* keep track of our integer/boolean options */ --- a/kxsldbg/kxsldbgpart/libxsldbg/os_cmds.cpp 2024-03-17 14:07:04.763235488 +0300 +++ b/kxsldbg/kxsldbgpart/libxsldbg/os_cmds.cpp 2024-03-17 14:07:15.007235059 +0300 @@ -19,6 +19,7 @@ #include "xsldbg.h" #include "debugXSL.h" #include "files.h" +#include <cstdlib> /* ----------------------------------------- --- a/kxsldbg/kxsldbgpart/libxsldbg/xsldbg.cpp 2024-03-17 14:07:04.764235488 +0300 +++ b/kxsldbg/kxsldbgpart/libxsldbg/xsldbg.cpp 2024-03-17 14:07:15.008235059 +0300 @@ -39,6 +39,7 @@ #include "files.h" #include "breakpoint.h" #include "debugXSL.h" +#include <cstdlib> #include <libxml/xmlerror.h> #include "xsldbgmsg.h" --- a/kxsldbg/xsldbgmain.cpp 2024-03-17 14:07:04.769235487 +0300 +++ b/kxsldbg/xsldbgmain.cpp 2024-03-17 14:07:15.009235059 +0300 @@ -39,6 +39,7 @@ #include <tdelocale.h> #include <tdeglobal.h> #include <kdebug.h> +#include <cstdlib> /* Forward delare private functions */ static int notifyXsldbgAppSimple(XsldbgMessageEnum type, const void *data); static int notifyStateXsldbgAppSimple(XsldbgMessageEnum type, int commandId, ``` Apparently gcc-13.2.1 now works a little differently, as does clang-17. For clang I had to add the line `#include <unistd.h>,` since clang complained about the lack of `chdir`. I don’t know what changes this is connected with. Error while building **Quanta**: ``` /var/tmp/portage/trinity-base/quanta-9999/work/quanta-9999/quanta/parsers/dtd/dtdparser.cpp:85:43: error: invalid conversion from ‘const xmlError*’ {aka ‘const _xmlError*’} to ‘xmlErrorPtr’ {aka ‘_xmlError*’} [-fpermissive] 85 | xmlErrorPtr errorPtr = xmlGetLastError(); | ~~~~~~~~~~~~~~~^~ | | | const xmlError* {aka const _xmlError*} ``` Since `libxml2-2.12.0`, the `xmlGetLastError()` function returns a `const xmlError*`. I applied this patch as a temporary solution: ``` --- a/quanta/parsers/dtd/dtdparser.cpp 2024-03-17 13:27:56.963333679 +0300 +++ b/quanta/parsers/dtd/dtdparser.cpp 2024-03-17 13:44:18.786292617 +0300 @@ -82,7 +82,9 @@ if( DTD::dtd_ptr == NULL ) { TQString errorStr = i18n("Unknown"); - xmlErrorPtr errorPtr = xmlGetLastError(); + xmlErrorPtr errorPtr; + const xmlError* errorConst = xmlGetLastError(); + xmlCopyError(errorConst, errorPtr); if (errorPtr != NULL) { TQString s = TQString::fromLatin1(errorPtr->message); ``` This requires detailed consideration. The error is reproduced on both the stable version and the live version.
Poster
Collaborator

I checked, I can say that adding the line #include <cstdlib> is necessary after updating >=libxml2-2.12.0. Adding the line #include <unistd.h> is needed for >=clang-17. At least the reasons are now clear.

I checked, I can say that adding the line `#include <cstdlib>` is necessary after updating `>=libxml2-2.12.0`. Adding the line `#include <unistd.h>` is needed for `>=clang-17`. At least the reasons are now clear.
Owner

I don't see a problem to add an include if that is needed. Just create proper PR for it.

I don't see a problem to add an include if that is needed. Just create proper PR for it.
Poster
Collaborator

I don't see a problem to add an include if that is needed. Just create proper PR for it.

Perhaps there is still a problem. TDE can be compiled not only on Linux, but also on FreeBSD, so you need to be sure that the solution will work on both systems.
I don’t know if it’s possible to add the line for the native FreeBSD compiler:

#include <cstdlib>

Adding #include <cstdlib> to *.cpp files seems more correct, but this does not change the fact that previously this support was included somewhere in the libxml2 header files. It just happened that after the update it showed up.

The header file unistd.h will most likely be available on both operating systems, so most likely it can simply be included in the assembly without being tied to the compiler version, since the check for inclusion is already present in this file.

> I don't see a problem to add an include if that is needed. Just create proper PR for it. Perhaps there is still a problem. TDE can be compiled not only on Linux, but also on FreeBSD, so you need to be sure that the solution will work on both systems. I don’t know if it’s possible to add the line for the native FreeBSD compiler: ``` #include <cstdlib> ``` Adding `#include <cstdlib>` to `*.cpp` files seems more correct, but this does not change the fact that previously this support was included somewhere in the libxml2 header files. It just happened that after the update it showed up. The header file `unistd.h` will most likely be available on both operating systems, so most likely it can simply be included in the assembly without being tied to the compiler version, since the check for inclusion is already present in this file.
obache commented 1 month ago
Collaborator

Following in "files.cpp" should be chdir() header include for Windows, <unistd.h>' is for Unix, so #else` block may be better place for the header.

#ifdef WIN32
#include <direct.h>
#endif

For xmlGetLastError(), how about simply change xmlErrorPtr errorPtr = xmlGetLastError(); to const xmlErrorPtr errorPtr = xmlGetLastError(); ?

Following in "files.cpp" should be `chdir()` header include for Windows, `<unistd.h>' is for Unix, so `#else` block may be better place for the header. ``` #ifdef WIN32 #include <direct.h> #endif ``` For `xmlGetLastError()`, how about simply change `xmlErrorPtr errorPtr = xmlGetLastError();` to `const xmlErrorPtr errorPtr = xmlGetLastError();` ?
Poster
Collaborator

Following in "files.cpp" should be chdir() header include for Windows, <unistd.h>' is for Unix, so #else` block may be better place for the header.

Yes, that can be done. But that’s why I said that this is a temporary solution, since it requires more careful consideration. I just did this quickly to ensure assembly.

For xmlGetLastError(), how about simply change xmlErrorPtr errorPtr = xmlGetLastError(); to const xmlErrorPtr errorPtr = xmlGetLastError(); ?

I understand that you meant const xmlError*. I tried this from the very beginning, but the xmlResetError() function only works with the xmlErrorPtr type, so I quickly made other changes just to ensure the build.
I looked at the libxml2 code and came to the conclusion that these lines need to be changed in Quanta:

- xmlErrorPtr errorPtr = xmlGetLastError();
+ const xmlError* errorPtr = xmlGetLastError();
- xmlResetError(errorPtr);
+ xmlResetLastError();
+ errorPtr = nullptr;

This looks more correct.
Now it remains to make sure that the cstdlib file is available in FreeBSD, in earlier versions I know for sure it was available, but in the latest versions clang is used by default instead of gcc, so I don’t know what the situation is with this.

> Following in "files.cpp" should be chdir() header include for Windows, <unistd.h>' is for Unix, so #else` block may be better place for the header. Yes, that can be done. But that’s why I said that this is a temporary solution, since it requires more careful consideration. I just did this quickly to ensure assembly. > For xmlGetLastError(), how about simply change xmlErrorPtr errorPtr = xmlGetLastError(); to const xmlErrorPtr errorPtr = xmlGetLastError(); ? I understand that you meant `const xmlError*`. I tried this from the very beginning, but the xmlResetError() function only works with the xmlErrorPtr type, so I quickly made other changes just to ensure the build. I looked at the libxml2 code and came to the conclusion that these lines need to be changed in Quanta: ``` - xmlErrorPtr errorPtr = xmlGetLastError(); + const xmlError* errorPtr = xmlGetLastError(); ``` ``` - xmlResetError(errorPtr); + xmlResetLastError(); + errorPtr = nullptr; ``` This looks more correct. Now it remains to make sure that the `cstdlib` file is available in FreeBSD, in earlier versions I know for sure it was available, but in the latest versions clang is used by default instead of gcc, so I don’t know what the situation is with this.
Owner

My test machine is FreeBSD 13.3-RELEASE and cstdlib seems to be available.

My test machine is FreeBSD 13.3-RELEASE and `cstdlib` seems to be available.
Poster
Collaborator

My test machine is FreeBSD 13.3-RELEASE and cstdlib seems to be available.

Great then, I've already written several patches. Now I'll add PR.

> My test machine is FreeBSD 13.3-RELEASE and cstdlib seems to be available. Great then, I've already written several patches. Now I'll add PR.
ormorph referenced this issue from a commit 1 month ago
ormorph referenced this issue from a commit 1 month ago
Owner

cstdlib is part of the C++ C library since the c++98 standard, so I reckon it should be available pretty much everywhere

`cstdlib` is part of the C++ C library since the c++98 standard, so I reckon it should be available pretty much everywhere
ormorph referenced this issue from a commit 1 month ago
ormorph referenced this issue from a commit 1 month ago
ormorph referenced this issue from a commit 1 month ago
ormorph referenced this issue from a commit 1 month ago
MicheleC referenced this issue from a commit 1 month ago
MicheleC referenced this issue from a commit 1 month ago
MicheleC added this to the R14.1.2 release milestone 1 month ago
Owner

Solved by PR #43.

Solved by PR #43.
MicheleC closed this issue 1 month ago
Sign in to join this conversation.
No Milestone
No Assignees
4 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: TDE/tdewebdev#42
Loading…
There is no content yet.