0

画像コンバーター用の端末で、Mac で C++ と C の混合コードをコンパイルしようとしていますが、いくつかのエラーが発生しています。イメージャー コンバーターのコードは、次の場所から入手できます。

https://code.google.com/p/ptmconvert/

最初、C++ コンパイラは、一部のファイルが C++ であり、一部は C だけであるという事実にうるさくなっていましたが、ここにある条件定義を使用して修正できました: How do I add Objective C code to a FireBreath計画?

つまり、メインの .cpp コードがインポートする .h ファイルの周りに#ifdef __OBJC__...を追加しただけです。#endif

ただし、別のインクルードから 2 つのエラーがまだ発生しており、同じ問題なのか別の問題なのかわかりません。

詳細な説明には、2 つのエラーと一連の警告が含まれています。

ptmconvert.cpp:236: error: ‘stbi_load_from_memory’ was not declared in this scope
ptmconvert.cpp:239: error: ‘stbi_failure_reason’ was not declared in this scope

そして、短いエラーは次のとおりです。

ptmconvert.cpp:236:25: error: use of undeclared identifier
'stbi_load_from_memory'
            planes[p] = stbi_load_from_memory(reinterpret_cast<unsigned ...
                        ^
ptmconvert.cpp:239:17: error: use of undeclared identifier 'stbi_failure_reason'
            if (stbi_failure_reason())
                ^
ptmconvert.cpp:242:35: error: use of undeclared identifier 'stbi_failure_reason'
                ss << "(stb) " << stbi_failure_reason() << std::endl;
                                   ^
ptmconvert.cpp:326:53: error: use of undeclared identifier 'stbi_image_free'
        std::for_each(planes.begin(), planes.end(), stbi_image_free);
                                                    ^
ptmconvert.cpp:388:10: error: use of undeclared identifier 'stbi_write_png'
    if (!stbi_write_png("coeffH.png", ptm->width, ptm->height, 3, ...
         ^
ptmconvert.cpp:391:10: error: use of undeclared identifier 'stbi_write_png'
    if (!stbi_write_png("coeffL.png", ptm->width, ptm->height, 3, ...
         ^
ptmconvert.cpp:394:10: error: use of undeclared identifier 'stbi_write_png'
    if (!stbi_write_png("rgb.png", ptm->width, ptm->height, 3, &rgbdata[0], 0))
         ^
7 errors generated.

同じ問題である場合、おそらく stb_image.c ファイルのどこかに別の条件を追加できますか?

わかりましたので、インクルードをコメントアウトするのはばかげていました。それをしないでください、将来の読者。今私が得ているエラーは、いくつかの用語が定義されていないということです:

Undefined symbols for architecture x86_64:
  "_stbi_failure_reason", referenced from:
      ptm_read(char const*, PTMHeader12*) in ptmconvert-g4SsIR.o
  "_stbi_image_free", referenced from:
      ptm_read(char const*, PTMHeader12*) in ptmconvert-g4SsIR.o
  "_stbi_load_from_memory", referenced from:
      ptm_read(char const*, PTMHeader12*) in ptmconvert-g4SsIR.o
ld: symbol(s) not found for architecture x86_64

どんな助け/提案も大歓迎です。

4

1 に答える 1

0

わかりました。コンパイラがエラーを出す理由は、c++ プログラムの makefile がないためです。ただし、cmakelists.txtCMake と呼ばれるメイクファイル作成者に指示を与える があります: http://www.cmake.org/

ptmconvert をコンパイルするにはcmakelists.txt、makefile を作成するディレクトリに CMake をインストールして実行する必要があります。その後、同じディレクトリで make を実行すると、実行可能な PTM コンバーターが作成されます。

ptmconverter を実行するには、次のように入力します。./ptmconvert yourPTMfile.ptm

于 2013-05-11T21:17:48.623 に答える