「区切り記号の欠落(TABを意味しましたか?)」に対する苦情

「区切り記号の欠落(TABを意味しましたか?)」に対する苦情

ファイルをインストールしようとしたときに、som_pak-3.1-NAcMoS.tar.gz次のコマンドを使用しました。

$ tar xvf som_pak-3.1-NAcMoS.tar.gz
$ cd som_pak-3.1
$ cp makefile.unix makefile
$ make
$ cd ..
$ ln -s som_pak-3.1 $NACMOS_HOME/som_pak

ただし、makeコマンドの実行中に次のエラーが発生します。

*区切り文字がありません(8つのスペースではなくTABを意味しましたか?)。止まる

  • 誰でもエラーの原因を教えてもらえますか?
  • 含めるパッケージがありますか?

ベストアンサー1

発生したエラー:

***区切り文字がありません(8つのスペースではなくTABを意味しましたか?)。止まる

makefileタブの代わりにスペースが含まれていることを意味します。このユーティリティは、代替用途makeに非常に面倒であることが知られています。したがって、ファイル内のルールセクションの先頭に含まれる可能性が高くなります。SpaceTabmakefileSpace

はい

次の3つのファイルがあるとします.c

こんにちはc
char *
hello() 
{
  return "Hello";
}
world.c
char *
world() 
{
  return "world";
}
メインプログラム:
#include <stdio.h>

/* Prototypes. */
char *hello();
char *world();

int
main(int argc, char *argv[]) 
{
    printf("%s, %s!\n", hello(), world());
    return 0;
}    

以下があるとしましょうMakefile

# The executable 'helloworld' depends on all 3 object files
helloworld: main.o hello.o world.o
        cc -o helloworld main.o hello.o world.o # Line starts with TAB!

# Build main.o (only requires main.c to exist)
main.o: main.c
        cc -c main.c # Line starts with TAB!

# Build hello.o (only requires hello.c to exist)
hello.o: hello.c
        cc -c hello.c # Line starts with TAB!

# Build world.o (only requires world.c to exist)
world.o: world.c
        cc -c world.c # Line starts with TAB!

#  Remove object files, executables (UNIX/Windows), Emacs backup files, 
#+ and core files
clean:
        rm -rf  *.o helloworld *~ *.core core # Line starts with TAB!

それではターゲットを作成してみましょう。

私がターゲットに対して実行したときhelloworld

$ make helloworld
makefile:3: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.

見慣れていますか?

問題を解く

Spaces実際の文字に変更することでTabこの問題を解決できます。一度はvimファイルを修復したことがあります。ただ開いてください:

$ vim makefile

次に、次のコマンドを実行します。

:%s/^[ ]\+/^I/

メモ: ^I特殊文字です。^後で入力すると、+ - +とはI異なる方法で解釈されます。CtrlVCtrlI

これにより、1以上で始まるすべての行がSpaces実際の行に置き換えられますTab

ここで目標を再実行すると、次のようになりますhelloworld

$ make helloworld
cc -c main.c # Line starts with TAB!
cc -c hello.c # Line starts with TAB!
cc -c world.c # Line starts with TAB!
cc -o helloworld main.o hello.o world.o # Line starts with TAB!

引用する

おすすめ記事