DigiDNA / ISOBMFF

C++ Library for ISO/IEC 14496-12 - ISO Base Media File Format (QuickTime, MPEG-4, HEIF, etc)
https://imazing.com/isobmff
MIT License
262 stars 56 forks source link

Porting to Ubunto 16.04.1 with gcc 5.4.1 #1

Closed kcwayne53 closed 6 years ago

kcwayne53 commented 6 years ago

I am trying to compile this code on Ubuntu 16.04.1 and am running into numerous issues.

1) The ISOBMFF-master/Makefile include path for the PIMPL Submodule includes is incorrect

2) The default Makefile uses clang. I tried using clang-5.0 and it will not compile for reasons such as #include not resolvable. This might be an artifact of having gcc-5.4.1 installed, and I did not dig into it. The only reason I tried using clang is because that is the default setting in the project, and I wondered if that would resolve the other issues I am having with gcc.

3) gcc 5.4.1 will not compile with a complaints such as:

ISOBMFF/source/HVCC-Array.cpp:34:50: error: specialization of ‘template class XS::PIMPL::Object::IMPL’ in different namespace [-fpermissive] class XS::PIMPL::Object< ISOBMFF::HVCC::Array >::IMPL

4) I tried using cpp to compile, but it produces unrecognizable object files for the ar tool.

So I am wondering what versions of linux and gcc tools this code has ever been compiled on.

macmade commented 6 years ago

Linux build was mainly tested on:

The PIMPL include path is correct.
I think your forgot to clone recursively, as this is a submodule.

You can also:

git submodule init
git submodule update

In order to initialise the submodules afterwards...
I think this might be the main issue.

I'm not using GCC because this compiler is a complete mess.
That being said, clang should be fine on Ubuntu...

I'm leaving this issue opened.
Feel free to comment if you're still experiencing issues. : )

kcwayne53 commented 6 years ago

I did the recursive git pull of the repository onto a Ubuntu 17.10 instance, and installed clang (v 4.0.1). I did not customize anything, just ran make in ISOBMFF.

Here are the compile errors:

In file included from ISOBMFF/source/SingleItemTypeReferenceBox.cpp:31: In file included from ISOBMFF/include/ISOBMFF/SingleItemTypeReferenceBox.hpp:36: In file included from ISOBMFF/include/ISOBMFF/Box.hpp:36: ISOBMFF/include/ISOBMFF/BinaryStream.hpp:34:10: fatal error: 'string' file not found

include

I went through the same thing on the 16.4 Ubuntu, and finally landed on g++ version 7.2.0 as a compiler that could handle the syntax and find the standard C++ include files, but it does not resolve the references to the standard C library functions at compile time.

So I added include to Parser.hpp and BinaryStream.hpp to get around that and the library builds.

Having a library, I built a test program with the following code:

include "ISOBMFF.hpp"

include

main(int argc, char **argv) { const std::string fmp4File = {"vid"};

if 0

if (argc > 1) {
   fmp4File = argv[1];
}

endif

ISOBMFF::Parser myParser;
myParser(fmp4File);

And I get the following unresolved symbols

test.cpp:(.text+0x56): undefined reference to ISOBMFF::Parser::Parser()' test.cpp:(.text+0x69): undefined reference toISOBMFF::Parser::Parse(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' test.o: In function ISOBMFF::Parser::~Parser()': test.cpp:(.text._ZN7ISOBMFF6ParserD2Ev[_ZN7ISOBMFF6ParserD5Ev]+0x22): undefined reference toXS::PIMPL::Object::~Object()' collect2: error: ld returned 1 exit status Makefile:15: recipe for target 'test' failed

So the linkage problem may be messy g++ as you say, and I need to refocus on making clang work to replicate your results.

My main point of posting this is for you to see what many people will go through to use the package. I have worked on numerous very large C++ projects that use the gnu tools in environments where portability is paramount. If we were to pick up this project for our solution we would have to resolve that or it won't get into a build because as a philosophy we do not want to support variant compilers, and the regression testing to move to a new compiler is very large.

Hope this is useful to you.

kcwayne53 commented 6 years ago

I was able to get a build with clang by installing libc++-dev.

Then to build my test app, I had to bring in support libraries as follows:

CFLAGS=-I$(PROJECTPATH)/ISOBMFF/include -I$(PROJECTPATH)/Submodules/PIMPL/PIMPL/include -stdlib=libc++ -fno-strict-aliasing

all: clang -o testapp $(CFLAGS) -std=c++11 -L. -lc++ -lm -lISOBMFF testapp.cpp