BlindMindStudios / StarRuler2-Source

4X Space Strategy game Star Ruler 2's open source distribution.
http://starruler2.com
Other
1.45k stars 244 forks source link

Attempted Build on linux error: cannot convert ‘unsigned int*’ to ‘png_uint_32* #1

Open se5a opened 5 years ago

se5a commented 5 years ago
se5a@se5aMint /mnt/98448323-4372-4c8a-904a-30b587cc3685/Games/StarRuler2-Source-master $ make -f source/linux/Makefile compile
source/os/source/threads.cpp
source/os/source/threads_gcc.cpp
source/os/source/files.cpp
source/os/source/files_linux.cpp
source/os/source/files_linux.cpp: In function ‘std::__cxx11::string getWorkingDirectory()’:
source/os/source/files_linux.cpp:18:22: warning: ignoring return value of ‘char* getcwd(char*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
  getcwd(buffer, 1024);
                      ^
source/os/source/virtual_asm_linux.cpp
source/os/source/virtual_asm_x64.cpp
source/sound/source/CSound.cpp
source/sound/source/CSoundDevice.cpp
source/sound/source/CSoundSource.cpp
source/sound/source/CStreamSound.cpp
source/sound/source/CSSOgg.cpp
source/sound/source/CSSWave.cpp
source/sound/source/CSSWave.cpp: In constructor ‘audio::CSSWave::CSSWave(FILE*, audio::ISoundDevice*)’:
source/sound/source/CSSWave.cpp:22:20: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   read(dwordTxt, 4);
                    ^
source/sound/source/CSSWave.cpp:30:20: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   read(dwordTxt, 4);
                    ^
source/sound/source/CSSWave.cpp:35:20: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   read(dwordTxt, 4);
                    ^
source/sound/source/CSSWave.cpp:40:22: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   read(&chunkSize, 4);
                      ^
source/sound/source/CSSWave.cpp:43:19: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   read(&format, 2); //1 for PCM, 0xFFFE for extensible
                   ^
source/sound/source/CSSWave.cpp:60:22: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
    read(&PCMData, 16);
                      ^
source/sound/source/CSSWave.cpp:66:22: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
    read(&PCMData, 18);
                      ^
source/sound/source/CSSWave.cpp:75:20: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
    read(&format, 2);
                    ^
source/sound/source/CSSWave.cpp:86:20: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   read(dwordTxt, 4);
                    ^
source/sound/source/CSSWave.cpp:90:23: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
    read(&dwordData, 4);
                       ^
source/sound/source/CSSWave.cpp:92:21: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
    read(dwordTxt, 4);
                     ^
source/sound/source/CSSWave.cpp:98:22: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   read(&dwordData, 4);
                      ^
source/sound/source/IAudioReference.cpp
source/sound/source/ISound.cpp
source/sound/source/ISoundDevice.cpp
source/sound/source/ISoundSource.cpp
source/as_addons/source/scriptany.cpp
source/as_addons/source/scriptarray.cpp
source/as_addons/source/scriptdictionary.cpp
source/as_addons/source/scriptmap.cpp
source/as_addons/source/scripthandle.cpp
source/as_addons/source/scriptmath.cpp
source/as_addons/source/scriptmath.cpp: In function ‘float fpFromIEEE(asUINT)’:
source/as_addons/source/scriptmath.cpp:83:39: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  return *reinterpret_cast<float*>(&raw);
                                       ^
source/as_addons/source/scriptmath.cpp: In function ‘asUINT fpToIEEE(float)’:
source/as_addons/source/scriptmath.cpp:87:39: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  return *reinterpret_cast<asUINT*>(&fp);
                                       ^
source/as_addons/source/scriptmath.cpp: In function ‘double fpFromIEEE(asQWORD)’:
source/as_addons/source/scriptmath.cpp:91:40: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  return *reinterpret_cast<double*>(&raw);
                                        ^
source/as_addons/source/scriptmath.cpp: In function ‘asQWORD fpToIEEE(double)’:
source/as_addons/source/scriptmath.cpp:95:40: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  return *reinterpret_cast<asQWORD*>(&fp);
                                        ^
source/as_addons/source/scriptstdstring.cpp
source/as_addons/source/scriptstdstring.cpp:352:15: warning: ‘AddStringUInt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)’ defined but not used [-Wunused-function]
 static string AddStringUInt(const string &str, unsigned int i)
               ^
source/as_addons/source/scriptstdstring.cpp:366:15: warning: ‘AddIntString(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’ defined but not used [-Wunused-function]
 static string AddIntString(int i, const string &str)
               ^
source/as_addons/source/scriptstdstring.cpp:396:15: warning: ‘AddStringInt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’ defined but not used [-Wunused-function]
 static string AddStringInt(const string &str, int i)
               ^
source/as_addons/source/scriptstdstring.cpp:410:15: warning: ‘AddUIntString(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’ defined but not used [-Wunused-function]
 static string AddUIntString(unsigned int i, const string &str)
               ^
source/as_addons/source/scriptstdstring_utils.cpp
source/as_addons/source/scripthelper.cpp
source/libircclient/src/libircclient.c
source/network/source/address.cpp
source/network/source/message.cpp
source/network/source/message.cpp: In member function ‘void net::Message::writeSmallVec3(double, double, double)’:
source/network/source/message.cpp:1031:36: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  unsigned floatBits = *(unsigned*)&fPrimaryDim;
                                    ^
source/network/source/message.cpp: In member function ‘void net::Message::readSmallVec3(double&, double&, double&)’:
source/network/source/message.cpp:1049:32: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  double primaryDim = *(float*)&floatBits;
                                ^
source/network/source/time.cpp
source/network/source/init.cpp
source/network/source/transport.cpp
source/network/source/message_handler.cpp
source/network/source/connection.cpp
source/network/source/sequence.cpp
source/network/source/server.cpp
source/network/source/client.cpp
source/network/source/lobby.cpp
source/util/source/image.cpp
source/util/source/image.cpp: In function ‘Image* loadPNG(const char*)’:
source/util/source/image.cpp:286:85: error: cannot convert ‘unsigned int*’ to ‘png_uint_32* {aka long unsigned int*}’ for argument ‘3’ to ‘png_uint_32 png_get_IHDR(png_structp, png_infop, png_uint_32*, png_uint_32*, int*, int*, int*, int*, int*)’
 t_IHDR(png, png_info, &w, &h, &depth, &format, &interlace, &compress, &filter);
                                                                              ^
source/util/source/image.cpp: In function ‘void PNG_UTIL::f_read(png_structp, png_bytep, png_size_t)’:
source/util/source/image.cpp:218:50: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
  fread(out, count, 1, (FILE*)png_get_io_ptr(png));
                                                  ^
source/util/gcc/Makefile:89: recipe for target 'obj/lin64/util/image.o' failed
make[1]: *** [obj/lin64/util/image.o] Error 1
source/linux/Makefile:326: recipe for target 'makelibs' failed
make: *** [makelibs] Error 2
se5a@se5aMint /mnt/98448323-4372-4c8a-904a-30b587cc3685/Games/StarRuler2-Source-master $ 
lucyllewy commented 5 years ago

You need to use a more recent libpng. I got past this error by using libpng16-16 on Ubuntu Xenial.

se5a commented 5 years ago

Ah right, I'll give that a shot. Checking dependencies was on my list of things to try but I figured someone else would have the same problem so I figured I might as well create an issue for someone else to find. Quick reply, thanks. ;)

se5a commented 5 years ago

Still getting the same error with libpng16-16 version (1.6.20-2).

Xatenev commented 5 years ago

@se5a Are you sure that you are really using that freshly downloaded libpng version now? The issue has been fixed in libpng 1.6 and occured due to version 1.2 assuming sizeof(unsigned long int)==4, which is not true on Linux x86_64[1].

The makefile used in the compilation process uses GCC to determine the location of the required dependencies[2]:

@cp "$$(realpath $$(gcc $(ARCHFLAGS) $(LDFLAGS) --print-file-name=$@))" "$(BINDIR)/$@"

Make sure you don't have multiple libpng versions and try to manually execute this command and make sure you actually get the expected result.

[1]: https://bugs.launchpad.net/ubuntu/+source/libpng/+bug/1348144 [2]: https://github.com/BlindMindStudios/StarRuler2-Source/blob/master/source/linux/Makefile#L335

se5a commented 5 years ago

looks like I have libpng12 installed as well, and apt-get remove wont uninstall it due to unmet dependencies. not sure what command I'm supposed to be manually executing there and what the result I should be expecting is.

Xatenev commented 5 years ago

@se5a You can try pointing your makefile to the full path of libpng 1.6 here:

https://github.com/BlindMindStudios/StarRuler2-Source/blob/master/source/linux/Makefile#L144

COPY_LIBS += libpng.so

becomes

COPY_LIBS += your/path/to/libpng.1.6.so

Should work, as thats exactly what they have done with darwin OS some lines above that.

jtrees commented 5 years ago

@Xatenev I tried your suggestion to no avail. Any other ideas?

Lucas7211 commented 5 years ago

Worth noting that the COPY_LIBS behavior is disabled in the Makefile. We used it for storing the library versions that the binary was linked against for commercial packages, but it's not needed when compiling on the system that will be running the binary, and the Makefile currently uses system libraries instead.

I'm not sure how your distro handles multiple versions of libpng, but it seems that the system's is using the older version, potentially the -lpng might be linking to that one as well then. You'll need to figure out which header file to include for png in source/util/source/image.cpp, as well as which linker flag to use in the Makefile.

se5a commented 5 years ago

ah. so that'll be why putting nonsense in the COPY_LIBS line didn't even make a difference. (couldn't figure out whether the filename should have been libpng.1.6.so or libpng16.so.16.20.0 or libpng16.so.16 or if I was barking up the wrong tree completely, and it seemed to give the same output whatever I put)

I'm using linux Mint which can be pretty much be treated as Ubuntu. (guess I should have mentioned that in the first post)

so now I'm getting well out of my depth, build problems are the main reason I never got around to learning cpp... how do I figure out what header file to include in the image.cpp and what linker flag to use in the makefile?

WulftheNordicRanger commented 5 years ago

What solved this error for me was installing libpng16-dev and libpng16-devtools. Give that a try and see if it works for you

se5a commented 5 years ago

Bingo!

Maybe if the readme had a list of dependencies by name as required by apt-get it would help.

remggo commented 5 years ago

@se5a That would be a great idea. Can you write a pull request for the Readme with the Libraries you needed on Ubuntu?

se5a commented 5 years ago

Well that's the thing, I don't know. did I need libpng16-16 or libpng16-dev or libpng16-devtools or did I need all three? or two? or what? and now I'm getting: make: *** No rule to make target '/usr/include/freetype2/freetype/freetype.h', needed by 'obj/lin64/render/font_ft2.o'. Stop. is this an unmet freetype dependancy or something else?

remggo commented 5 years ago

I do not know about the free type error you get, but I will look tonight which libraries I have installed on Archlinux because at my end it compiled without any issue. Maybe it helps you narrow down which packages are needed on Ubuntu.

WulftheNordicRanger commented 5 years ago

I'm glad it worked for you! I myself am trying to figure out how to fix the freetype2 error. I can say that downloading and installing freetype2 from the developer's website doesn't work.

ethchest commented 5 years ago

How did you guys install libpng16 without breaking freetype? On Ubuntu 16.04 this depends on libpng12. According to other game devs it should be possible to install both, except Ubuntu doesn't like it.

se5a commented 5 years ago

not sure, I apt-get installed libpng16-16 libpng16-dev libpng16-devtools first, then the freetype ones you pointed out. not sure if order makes any difference...