Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make error on Debian 10 #3

Closed
maxalmix opened this issue Oct 3, 2020 · 2 comments
Closed

make error on Debian 10 #3

maxalmix opened this issue Oct 3, 2020 · 2 comments

Comments

@maxalmix
Copy link

maxalmix commented Oct 3, 2020

Hi, I'm not a C++ expert, this is my output on my Debian 10

make
g++ -I/opt/local/include -g -Wall -std=c++14 -c -o render_bits.o render_bits.cc
In file included from resource_fork.hh:14,
from render_bits.cc:10:
quickdraw_formats.hh:48:8: warning: ignoring packed attribute because of unpacked non-POD field ‘rect bit_map_header::bounds’
rect bounds;
^~~~~~
quickdraw_formats.hh:55:8: warning: ignoring packed attribute because of unpacked non-POD field ‘rect pixel_map_header::bounds’
rect bounds;
^~~~~~
render_bits.cc: In function ‘int main(int, char**)’:
render_bits.cc:136:24: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
for (size_t x = 1; x < argc; x++) {
~~^~~~~~
render_bits.cc:176:16: error: ‘sqrt’ was not declared in this scope
double z = sqrt(pixel_count);
^~~~
render_bits.cc:176:16: note: suggested alternative: ‘stat’
double z = sqrt(pixel_count);
^~~~
stat
render_bits.cc:177:14: error: ‘floor’ was not declared in this scope
if (z != floor(z)) {
^~~~~
render_bits.cc:177:14: note: suggested alternative: ‘flock’
if (z != floor(z)) {
^~~~~
flock
make: *** [: render_bits.o] Error 1

@ghost
Copy link

ghost commented Oct 30, 2020

Can confirm it doesn't build either in Ubuntu 18.04 with g++ 7.5.0. I had to apply the following patch to get around some missing includes that g++ was complaining about and to fix the install prefix to the Phosg library to the one used by the Phosg Makefile here.

From cf8601994d232f558daea2077fbf92c156edaaa8 Mon Sep 17 00:00:00 2001
From: Miguel Angel Astor Romero <sonofgrendel@gmail.com>
Date: Fri, 30 Oct 2020 14:33:52 -0400
Subject: [PATCH] abcd

---
 Makefile         | 28 ++++++++++++++--------------
 bt_render.cc     |  2 ++
 render_bits.cc   |  1 +
 resource_dasm.cc |  1 +
 resource_fork.cc |  1 +
 5 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index 08576e0..4dc204c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,48 +1,48 @@
 COMMON_OBJECTS=resource_fork.o audio_codecs.o pict.o quickdraw_formats.o mc68k.o mc68k_dasm.o
 
-CXXFLAGS=-I/opt/local/include -g -Wall -std=c++14
-LDFLAGS=-L/opt/local/lib -lphosg
+CXXFLAGS=-I/usr/local/include/phosg -g -Wall -std=c++14
+LDFLAGS=-L/usr/local/lib -lm -lpthread
 EXECUTABLES=render_bits bt_render macski_decomp mohawk_dasm realmz_dasm dc_dasm resource_dasm infotron_render ferazel_render harry_render mshines_render sc2k_render
 
 all: $(EXECUTABLES)
 
 
 resource_dasm: resource_dasm.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o resource_dasm $^
+	g++ -o resource_dasm $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 
 bt_render: bt_render.o ambrosia_sprites.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o bt_render $^
+	g++ -o bt_render $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 dc_dasm: dc_dasm.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o dc_dasm $^
+	g++ -o dc_dasm $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 ferazel_render: ferazel_render.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o ferazel_render $^
+	g++ -o ferazel_render $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 harry_render: harry_render.o ambrosia_sprites.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o harry_render $^
+	g++ -o harry_render $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 infotron_render: infotron_render.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o infotron_render $^
+	g++ -o infotron_render $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 macski_decomp: macski_decomp.o
-	g++ $(LDFLAGS) -o macski_decomp $^
+	g++ -o macski_decomp $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 mohawk_dasm: mohawk_dasm.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o mohawk_dasm $^
+	g++ -o mohawk_dasm $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 mshines_render: mshines_render.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o mshines_render $^
+	g++ -o mshines_render $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 realmz_dasm: realmz_dasm.o realmz_lib.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o realmz_dasm $^
+	g++ -o realmz_dasm $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 render_bits: render_bits.o
-	g++ $(LDFLAGS) -o render_bits $^
+	g++ -o render_bits $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 sc2k_render: sc2k_render.o $(COMMON_OBJECTS)
-	g++ $(LDFLAGS) -o sc2k_render $^
+	g++ -o sc2k_render $^ /usr/local/lib/libphosg.a $(LDFLAGS)
 
 
 clean:
diff --git a/bt_render.cc b/bt_render.cc
index 81ac969..3c95024 100755
--- a/bt_render.cc
+++ b/bt_render.cc
@@ -1,3 +1,5 @@
+#include <cstring>
+
 #include <phosg/Filesystem.hh>
 #include <phosg/Image.hh>
 #include <phosg/Strings.hh>
diff --git a/render_bits.cc b/render_bits.cc
index 56a6c6c..2c6d1cb 100755
--- a/render_bits.cc
+++ b/render_bits.cc
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <cmath>
 
 #include <phosg/Encoding.hh>
 #include <phosg/Image.hh>
diff --git a/resource_dasm.cc b/resource_dasm.cc
index 89347da..f03ddc0 100644
--- a/resource_dasm.cc
+++ b/resource_dasm.cc
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <algorithm>
 
 #include <functional>
 #include <phosg/Encoding.hh>
diff --git a/resource_fork.cc b/resource_fork.cc
index 45ae1ff..ed9d3fa 100644
--- a/resource_fork.cc
+++ b/resource_fork.cc
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <algorithm>
 
 #include <exception>
 #include <phosg/Encoding.hh>
-- 
2.17.1

After the patch it fails with the following compilation error that I honestly can't make head or tails off (c++14 isn't my forte either), though by the looks of it, it makes me think that maaaaaaybe it needs a specific version of g++ higher than 7.5.0 🤔️

In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33:0,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/string:41,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/array:39,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/functional:54,
                 from /usr/local/include/phosg/Filesystem.hh:15,
                 from resource_fork.hh:8,
                 from resource_fork.cc:1:
/usr/include/c++/7/ext/new_allocator.h: In instantiation of ‘class __gnu_cxx::new_allocator<const std::__cxx11::basic_string<char> >’:
/usr/include/c++/7/bits/allocator.h:108:11:   required from ‘class std::allocator<const std::__cxx11::basic_string<char> >’
/usr/include/c++/7/bits/stl_vector.h:81:14:   required from ‘struct std::_Vector_base<const std::__cxx11::basic_string<char>, std::allocator<const std::__cxx11::basic_string<char> > >::_Vector_impl’
/usr/include/c++/7/bits/stl_vector.h:166:20:   required from ‘struct std::_Vector_base<const std::__cxx11::basic_string<char>, std::allocator<const std::__cxx11::basic_string<char> > >’
/usr/include/c++/7/bits/stl_vector.h:216:11:   required from ‘class std::vector<const std::__cxx11::basic_string<char> >’
resource_fork.cc:2584:44:   required from here
/usr/include/c++/7/ext/new_allocator.h:93:7: error: ‘const _Tp* __gnu_cxx::new_allocator<_Tp>::address(__gnu_cxx::new_allocator<_Tp>::const_reference) const [with _Tp = const std::__cxx11::basic_string<char>; __gnu_cxx::new_allocator<_Tp>::const_pointer = const std::__cxx11::basic_string<char>*; __gnu_cxx::new_allocator<_Tp>::const_reference = const std::__cxx11::basic_string<char>&]’ cannot be overloaded
       address(const_reference __x) const _GLIBCXX_NOEXCEPT
       ^~~~~~~
/usr/include/c++/7/ext/new_allocator.h:89:7: error: with ‘_Tp* __gnu_cxx::new_allocator<_Tp>::address(__gnu_cxx::new_allocator<_Tp>::reference) const [with _Tp = const std::__cxx11::basic_string<char>; __gnu_cxx::new_allocator<_Tp>::pointer = const std::__cxx11::basic_string<char>*; __gnu_cxx::new_allocator<_Tp>::reference = const std::__cxx11::basic_string<char>&]’
       address(reference __x) const _GLIBCXX_NOEXCEPT
       ^~~~~~~
resource_fork.cc: In member function ‘std::__cxx11::string ResourceFile::decode_styl(int16_t, uint32_t)’:
resource_fork.cc:2949:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     uint32_t end_offset = (x == num_commands - 1) ? text.size() : bswap32(cmds[x + 1].offset);
                            ~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33:0,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/string:41,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/array:39,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/functional:54,
                 from /usr/local/include/phosg/Filesystem.hh:15,
                 from resource_fork.hh:8,
                 from resource_fork.cc:1:
/usr/include/c++/7/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::deallocate(__gnu_cxx::new_allocator<_Tp>::pointer, __gnu_cxx::new_allocator<_Tp>::size_type) [with _Tp = const std::__cxx11::basic_string<char>; __gnu_cxx::new_allocator<_Tp>::pointer = const std::__cxx11::basic_string<char>*; __gnu_cxx::new_allocator<_Tp>::size_type = long unsigned int]’:
/usr/include/c++/7/bits/alloc_traits.h:462:9:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::deallocate(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, std::allocator_traits<std::allocator<_CharT> >::pointer, std::allocator_traits<std::allocator<_CharT> >::size_type) [with _Tp = const std::__cxx11::basic_string<char>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<const std::__cxx11::basic_string<char> >; std::allocator_traits<std::allocator<_CharT> >::pointer = const std::__cxx11::basic_string<char>*; std::allocator_traits<std::allocator<_CharT> >::size_type = long unsigned int]’
/usr/include/c++/7/bits/stl_vector.h:180:19:   required from ‘void std::_Vector_base<_Tp, _Alloc>::_M_deallocate(std::_Vector_base<_Tp, _Alloc>::pointer, std::size_t) [with _Tp = const std::__cxx11::basic_string<char>; _Alloc = std::allocator<const std::__cxx11::basic_string<char> >; std::_Vector_base<_Tp, _Alloc>::pointer = const std::__cxx11::basic_string<char>*; std::size_t = long unsigned int]’
/usr/include/c++/7/bits/stl_vector.h:162:22:   required from ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = const std::__cxx11::basic_string<char>; _Alloc = std::allocator<const std::__cxx11::basic_string<char> >]’
/usr/include/c++/7/bits/stl_vector.h:385:18:   required from ‘std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = const std::__cxx11::basic_string<char>; _Alloc = std::allocator<const std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<const std::__cxx11::basic_string<char> >]’
resource_fork.cc:2652:2:   required from here
/usr/include/c++/7/ext/new_allocator.h:125:19: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
  ::operator delete(__p);
  ~~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/7/functional:53:0,
                 from /usr/local/include/phosg/Filesystem.hh:15,
                 from resource_fork.hh:8,
                 from resource_fork.cc:1:
/usr/include/c++/7/new:124:6: note:   initializing argument 1 of ‘void operator delete(void*)’
 void operator delete(void*) _GLIBCXX_USE_NOEXCEPT
      ^~~~~~~~
In file included from /usr/include/c++/7/memory:64:0,
                 from /usr/local/include/phosg/Filesystem.hh:16,
                 from resource_fork.hh:8,
                 from resource_fork.cc:1:
/usr/include/c++/7/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = const std::__cxx11::basic_string<char>; _Args = {const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}]’:
/usr/include/c++/7/bits/stl_uninitialized.h:83:18:   required from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const std::__cxx11::basic_string<char>*; _ForwardIterator = const std::__cxx11::basic_string<char>*; bool _TrivialValueTypes = false]’
/usr/include/c++/7/bits/stl_uninitialized.h:134:15:   required from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const std::__cxx11::basic_string<char>*; _ForwardIterator = const std::__cxx11::basic_string<char>*]’
/usr/include/c++/7/bits/stl_uninitialized.h:289:37:   required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = const std::__cxx11::basic_string<char>*; _ForwardIterator = const std::__cxx11::basic_string<char>*; _Tp = const std::__cxx11::basic_string<char>]’
/usr/include/c++/7/bits/stl_vector.h:1331:33:   required from ‘void std::vector<_Tp, _Alloc>::_M_range_initialize(_ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = const std::__cxx11::basic_string<char>*; _Tp = const std::__cxx11::basic_string<char>; _Alloc = std::allocator<const std::__cxx11::basic_string<char> >]’
/usr/include/c++/7/bits/stl_vector.h:387:21:   required from ‘std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = const std::__cxx11::basic_string<char>; _Alloc = std::allocator<const std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<const std::__cxx11::basic_string<char> >]’
resource_fork.cc:2652:2:   required from here
/usr/include/c++/7/bits/stl_construct.h:75:13: error: invalid static_cast from type ‘const std::__cxx11::basic_string<char>*’ to type ‘void*’
     { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
             ^~~~~~~~~~~~~~~~~~~~~~~

Also tried to compile it with clang but it throws an impressive ammount of linking error with the Phosg library (also compiled with clang). The library itself compiles fine with both g++ and clang, however.

@fuzziqersoftware
Copy link
Owner

There were a couple of problems here; I've addressed them in b3bb502, which should make the project build properly in Ubuntu 18.04 / gcc 7.5.0 and hopefully other Linuxes as well; I don't have any other distributions already set up to try with though. This commit fixes numerous sign-compare warnings (clang doesn't warn about these), adds missing includes, and fixes the linker argument order so ld won't complain. It's remarkable to me that in 2020, the linker still isn't smart enough to link libraries correctly regardless of the order they're specified on the command line...

Feel free to reopen if this doesn't fix the build issues for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants