gpt4 book ai didi

android - 编译 C++ 源代码以将 .off 文件转换为 Android OpenGL ES 可读的 XML 的问题

转载 作者:太空宇宙 更新时间:2023-11-04 02:59:51 25 4
gpt4 key购买 nike

我在 Stackoverflow 上找到了一种将 3D 模型导入 Android 的 OpenGL 的方法:

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

我试图按照说明复制源代码并尝试编译程序。我得到了大量的错误,这里只是一个小样本:

    /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'

我认为问题是我没有向程序传递参数,所以我尝试像这样传递参数:

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

(我的 .off 文件与其他源文件位于同一目录中,而 output.xml 也位于同一文件中。)我遇到了这些错误

    /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

无论如何,我觉得我不应该有一个 output.xml 文件,但当我没有时,它给了我一个找不到文件的错误。

开源文件不在实际文件中,所以我觉得我应该向您展示我的所有文件,并且我觉得将其他人的源代码上传到 github 存储库很奇怪,所以这里是源文件的快速共享链接:

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

我觉得像这样共享文件很奇怪^^,但我真的没有看到任何其他选择。它仅包含我的 .off 文件和 .xml 文件以及 C 和 C++ 文件。

任何帮助将不胜感激,过去几天我一直致力于此。谢谢!

编辑

所以我用 g++ 运行它,没有参数,结果如下:

     $  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

我在寻找什么样的错误?

最佳答案

问题是,当我在 Visual Studio 中运行我的程序时,它会同时编译和运行程序,并且由于源代码需要参数才能运行,所以它会出现运行时错误。

然后因为我不知道如何将参数传递给 visual studio 中的程序,我尝试使用 Cygwin,这给了我错误,可能是因为它没有正确配置。不太确定为什么会发生这些错误。

因此,为了解决整个问题,我只是使用 Visual Studio 构建我的程序,导航到它在编译时创建的 .exe 文件,然后在命令行中运行该 .exe。

所以这个故事的寓意是:永远记住,当您按下那个绿色播放按钮时,它会编译并运行程序。因此,如果您的错误与您运行程序的环境有关,那么即使您的代码非常好,您也可能会出错。

感谢 Bo Persson 帮助我实现了这个想法!

关于android - 编译 C++ 源代码以将 .off 文件转换为 Android OpenGL ES 可读的 XML 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13316198/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com