GobySoft / dccl

Dynamic Compact Control Language
Other
17 stars 13 forks source link

Doesn't compile with libb64 1.2.1 due to missing definition #43

Closed russkel closed 5 years ago

russkel commented 5 years ago

Hello, I have been trying to compile DCCL w/ b64 support and have come across an issue:

In file included from /tmp/dccl-20190311-2927-10tibqz/dccl-3.0.10/build/include/dccl/binary.h:34,
                 from /tmp/dccl-20190311-2927-10tibqz/dccl-3.0.10/build/include/dccl/codec.h:36,
                 from /tmp/dccl-20190311-2927-10tibqz/dccl-3.0.10/src/bitset.cpp:23:
/home/linuxbrew/.linuxbrew/include/b64/encode.h:25:31: error: ‘BUFFERSIZE’ was not declared in this scope
   encoder(int buffersize_in = BUFFERSIZE)

After looking at some diffs and commit history I found it was changed in this commit (sorry I can't link to a specific file like on github) https://sourceforge.net/p/libb64/git/ci/9a462ed91d9146b6aacf6a49f08c102b88fe75e7/

The buffer size of 4096 was changed to a definition BUFFERSIZE, so in order to get DCCL to compile I added this -DCMAKE_CXX_FLAGS=-DBUFFERSIZE=4096.

It might need to be added to the project's cmake file so other people do not run into this issue. As an aside, is it possible to remove this dependency and replace it with something from a stdlib? The lib is quite old and not really maintained any more.

Cheers,

Russ

tsaubergine commented 5 years ago

Hi -

First, I should note that you can disable the use of base64 encoding/decoding by setting "enable_b64=OFF" in CMake (e.g. cd build; cmake .. -Denable_b64=OFF). This removes the need for lib64-dev. Depending on your usage, you may not need base64 encoding at all. I believe the only place the DCCL library itself uses it is in the dccl tool (for --format=base64).

Apparently Debian (and thus also derivatives such as Ubuntu) patches libb64 to use BUFSIZ from <cstdio>, which would be my recommendation for other systems:

Description: use BUFSIZ as buffer size
Author: Jakub Wilk <jwilk@debian.org>
Bug: http://sourceforge.net/tracker/?func=detail&atid=785907&aid=3591336&group_id=152942
Forwarded: no
Last-Update: 2012-11-30

--- a/include/b64/decode.h
+++ b/include/b64/decode.h
@@ -8,6 +8,7 @@
 #ifndef BASE64_DECODE_H
 #define BASE64_DECODE_H

+#include <cstdio>
 #include <iostream>

 namespace base64
@@ -22,7 +23,7 @@
        base64_decodestate _state;
        int _buffersize;

-       decoder(int buffersize_in = BUFFERSIZE)
+       decoder(int buffersize_in = BUFSIZ)
        : _buffersize(buffersize_in)
        {}

--- a/include/b64/encode.h
+++ b/include/b64/encode.h
@@ -8,6 +8,7 @@
 #ifndef BASE64_ENCODE_H
 #define BASE64_ENCODE_H

+#include <cstdio>
 #include <iostream>

 namespace base64
@@ -22,7 +23,7 @@
        base64_encodestate _state;
        int _buffersize;

-       encoder(int buffersize_in = BUFFERSIZE)
+       encoder(int buffersize_in = BUFSIZ)
        : _buffersize(buffersize_in)
        {}

There's no standard library in C/C++ for base64 encoding. Just because a library is old doesn't make it useful; I doubt there's much to maintain in the code here. Debian is keeping the packages up to date.

That said, if you have suggestions, please let us know.

russkel commented 5 years ago

There's no standard library in C/C++ for base64 encoding. Just because a library is old doesn't make it useful; I doubt there's much to maintain in the code here.

The idea was more to remove a dependency for something seemingly pedestrian. I am not very familiar with C++ at this stage so forgive my ignorance.