简体   繁体   中英

Problems with compiling C++ Source for Converting .off Files to XML Readable by Android OpenGL ES

I found a method for importing 3D models to Android's OpenGL on Stackoverflow here:

Is there a way to import a 3D model into Android?

Attempting to follow the instructions I copied the source and tried to compile the program. I got a massive number of errors, here is just a small sample:

    /tmp/ccPavSpL.o:OFF-OpenGL_loader.cc:(.text+0xd): undefined reference to `std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >::size() const'

I think the problem was I wasn't passing in arguments to the program, so I tried passing arguments like so:

    $  gcc OFF-OpenGL_loader.cc circle.off output.xml

(My .off file was in the same directory as the other source files and the output.xml was also in the same file.) I got these errors

    /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld:circle.off: file format not recognized;
    treating as linker script
    /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld:circle.off:2: syntax error
    collect2: ld returned 1 exit status

Anyway so I have a feeling I wasn't supposed to have an output.xml file but when I didn't have one then it gave me a file not found error.

The opensource files were not in actual files so I feel like I should show you all my files and I feel weird uploading someone else's source to a github repo, so here is a rapid share link to the source files:

http://d01.megashares.com/dl/2YylIbE/SourceCodeAnd.offFile.zip

I feel weird sharing files like this^^ but I don't really see any other option. It just contains my .off file and .xml file and the C and C++ files.

Any help would be greatly appreciated, I've spent the past few days stuck on this. Thanks!

Edit

So I ran it with g++ and with no parameters and these were the results:

     $  g++ OFF-OpenGL_loader.cc
     /tmp/ccNFneYn.o:OFF-OpenGL_loader.cc:(.text+0x1aa): undefined reference to  
     `ReadFile::getExtension(char*)'/tmp/ccNFneYn.o:
    OFF-OpenGL_loader.cc:(.text+0x2f8): undefined reference to 
    operator>>(std::basic_ifstream<char, std::
    char_traits<char> >&, ReadFile&)'/tmp/ccNFneYn.o:OFF-
    OpenGL_loader.cc:(.text+0x6de): undefined reference to `ReadFile::ReadFile()'/tmp/ccNFneYn.o:OFF-
    OpenGL_loader.cc:(.text+0x6f9): undefined reference to `ReadFile::~ReadFile()'/usr/lib/gcc/i686-pc-
    cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: 
    /tmp/ccNFneYn.o: bad reloc address 0x1c in section 
    `.gcc_except_table'/usr/lib/gcc/i686-pc-cygwin/3.4.4/.
    ./../../../i686-pc-cygwin/bin/ld: final link failed: 
    Invalid operationcollect2: ld returned 1 exit status

What kind of errors am I looking for?

The problem was that when I ran my program in Visual Studio it would both compile and run the program, and because the source required parameters to be run, it would come up with runtime errors.

Then because I didn't know how to pass parameters to programs in visual studio, I tried using Cygwin which gave me errors, probably because it wasn't configured correctly. Not really sure why those errors happened.

So to solve this whole thing I just built my program with Visual Studio, navigated to the .exe file that it creates when it compiles, and then ran that .exe in the command line.

So the moral of the story is: always remember that when you hit that green play button, it both compiles and runs the program. So if your error has to do with the circumstances that you run your program in, you might get errors even if your code is perfectly fine.

Thanks Bo Persson for helping me get that idea!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM