少し奇妙な問題があります。いくつかの異なるアーキテクチャ、特にこれら2:SH4とMIPS用にコンパイルするプロジェクトがあります。
しばらくの間、一部のコードがSH4でコンパイルされますが、インクルードがないためにMIPSではコンパイルされないという問題がありました。問題をこのテストファイルに絞り込みました。
#include <sstream>
// deliberately not including the needed includes
int main()
{
const char *toto = "Hello World";
// using printf and strlen which require <stdio.h> and <string.h>
printf("Toto has len %d\n", strlen(toto));
return 0;
}
このコマンドでSH4にコンパイルする
$ sh4-linux-g++ -O0 -g -Wall -Werror -Wno-write-strings \
-fno-rtti -fno-exceptions test.cpp -o test
$
->まったく問題ありません。ファイルは実際には正常に実行されます。
一方、MIPSでは
$ mips-linux-gnu-g++ -O0 -g -Wall -Werror -Wno-write-strings \
-fno-rtti -fno-exceptions test.cpp -o test
test.cpp: In function 'int main()':
test.cpp:6: error: 'strlen' was not declared in this scope
$
今、私はいくつかのことを実行しました。特に、両方のg++の依存関係の生成です。私が見るものはこれです:
SH4
$ sh4-linux-g++ -O0 -g -Wall -Werror -Wno-write-strings \
-fno-rtti -fno-exceptions test.cpp -M |grep "/string.h"
/opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/string.h \
->string.hが自動的に含まれます。
MIPS
mips-linux-gnu-g++ -O0 -g -Wall -Werror -Wno-write-strings \
-fno-rtti -fno-exceptions test.cpp -M |grep "/string.h"
->string.hがインクルードにありません
詳細については:
SH4 version = 4.2.4 (2007)
MIPS version = 4.3.2 (2008)
何が起きてる?<sstream>
インクルードは、SH4でコンパイルするときにstrlen()に必要なものすべてに沿ってドラッグするようですが、MIPSではドラッグしません。バージョンが違うせいかもしれませんが、よくわかりません。
結局のところ、私の本当の問題は、SH4で開発するときに、コンパイルされた場合、すべてのターゲットでコンパイルされることを確認したいということです。これに対する解決策はありますか?