0

我正在尝试使用 make 在 ubuntu 12.04 64bit 上编译程序。编译时出现错误

/bin/bash: -c: line 0: 意外标记附近的语法错误`(

这是在我将符号链接更改/bin/sh/bin/bash而不是破折号之后。(我这样做是因为我之前遇到过同样的错误,然后环顾互联网,我发现脚本可能会调用 sh/dash 中不可用的 bash 函数。)

我也试过把SHELL = /bin/bash我的makefile放在顶部,但仍然没有用......

任何帮助将非常感激。

编辑

SHELL = /bin/bash
CC = gcc
CFLAGS= -std=gnu99 -L/ATLAS/lib/ubuntu12.04 -lflint -lgsl -lcblas -latlas  -lm -lmpfr -lmpir -lrt -Wall -fopenmp
default: GPVSignature
GPVSignature: GPVSignature.o  Keygeneration.o chol_parallel.o Sampling2.o  sha1.o     sha2.o timing.o
    $(CC) $(CFLAGS) -o GPVSignature GPVSignature.o  Keygeneration.o   chol_parallel.o Sampling2.o  sha1.o sha2.o timing.o

clean: 
        rm -f GPVSignature *.o


SSH_AGENT_PID=2065
GPG_AGENT_INFO=/tmp/keyring-alBJt6/gpg:0:1
TERM=xterm
SHELL=/bin/bash
XDG_SESSION_COOKIE=ff0e3de12be325b4ae6276d100000009-1353535027.801191-1696704263
WINDOWID=56623110
GNOME_KEYRING_CONTROL=/tmp/keyring-alBJt6
NO_PROXY=localhost,127.0.0.0/8
USER=salman
http_proxy=http:(---)
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;  33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/tmp/keyring-alBJt6/ssh
SESSION_MANAGER=local/ubuntu:@/tmp/.ICE-unix/2026,unix/ubuntu:/tmp/.ICE-unix/2026
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:  /bin:/usr/games
DESKTOP_SESSION=ubuntu
PWD=/home/salman/
GNOME_KEYRING_PID=2015
LANG=en_US.UTF-8
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
UBUNTU_MENUPROXY=libappmenu.so
COMPIZ_CONFIG_PROFILE=ubuntu
GDMSESSION=ubuntu
HOME=/home/salman
SHLVL=1
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
no_proxy=localhost,127.0.0.0/8
LOGNAME=salman
BUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-RUfHXImIYm,guid=c49ca476a7f4b008964105c90000004e
LESSOPEN=| /usr/bin/lesspipe %s
DISPLAY=:0
XDG_CURRENT_DESKTOP=Unity
LESSCLOSE=/usr/bin/lesspipe %s %s
COLORTERM=gnome-terminal
XAUTHORITY=/home/salman/.Xauthority
_=/usr/bin/env
OLDPWD=/home/salman/Desktop
4

1 回答 1

0

How about this?:

SHELL:=/bin/bash
CC:=gcc
CFLAGS:=-std=gnu99 -L/ATLAS/lib/ubuntu12.04 -lflint -lgsl -lcblas -latlas  -lm -lmpfr -lmpir -lrt -Wall -fopenmp

default: GPVSignature
GPVSignature: GPVSignature.c  Keygeneration.c chol_parallel.c Sampling2.c  sha1.c     sha2.c timing.c

clean: 
    rm -f GPVSignature *.o

The indentation under the clean: line (before the rm) is a TAB character! This is important. My guess is that you don't have the indentation correct on the recipe lines (under GPVSignature: and under clean:). Also, you don't need to give an explicit recipe, because GNU make comes with a number of recipes of its own.

Note: I am assuming the file extensions are .c here, because it is customary and you use gcc, not g++. If that's not the case you need to introduce a pattern rule to tell GNU make how to create .o files from whatever extension you are using for your source files.

Even assuming your original recipe, I'd suggest the following more succinct line:

$(CC) $(CFLAGS) -o $@ $^

... also indented by a single tab character (unless you tell GNU make to use a different character, which you obviously don't).


Two more things.

  1. Is the Makefile/GNUmakefile a simple ASCII text file or a UTF-8 file with BOM? Execute file Makefile and post the output, please.
  2. Check the following screenshots. This (second screenshot) is how it should look correctly indented with tabs in Vim (assuming you have the syntax file installed) ... specifically note the colors of the recipe for GPVSignature. The first screenshot is wrong, the second is

Wrong indentation of make file, notice the white/gray text for the recipe line

Correct indentation

Other than that I am out of ideas. And there would have to be something you aren't mentioning.

于 2012-11-21T19:48:32.407 回答