我正在使用gcc版本4.7.2开发Ubuntu 12.10。
我正在尝试制作以下makefile:
CC = g++
CCFLAGS = -fPIC -O3 -Wall -ffast-math -msse -msse2 -fopenmp
LINKFLAGS = -shared -Wl -fopenmp -lgomp
INPUT = im2col.cpp fastpool.cpp local_response_normalization.cpp neuron.cpp
TARGET = libcpputil.so
# If we are going to use MKL, we include additional flags
MKL_FLAGS = -D DECAF_USE_MKL
MKL_LINK_FLAGS = -lmkl_rt
all: $(INPUT)
$(CC) -c $(CCFLAGS) $(INPUT)
$(CC) $(LINKFLAGS) -o $(TARGET) *.o
all_mkl: $(INPUT)
$(CC) -c $(CCFLAGS) $(MKL_FLAGS) $(INPUT)
$(CC) $(LINKFLAGS) $(MKL_LINK_FLAGS) -o $(TARGET) *.o
speedtest_lrn: speedtest_lrn.cpp local_response_normalization.cpp
$(CC) $(CCFLAGS) -lgomp -o speedtest_lrn speedtest_lrn.cpp local_response_normalization.cpp
clean:
rm *.so
rm *.o
但不知何故,g ++无法识别选项-wl。这是我得到的错误:
make -C layers/cpp/
make[1]: Entering directory `/home/ubuntu/decaf-release-master/decaf/layers/cpp'
g++ -c -fPIC -O3 -Wall -ffast-math -msse -msse2 -fopenmp im2col.cpp fastpool.cpp local_response_normalization.cpp neuron.cpp
g++ -shared -Wl -fopenmp -lgomp -o libcpputil.so *.o
g++: error: unrecognized command line option ‘-Wl’
make[1]: *** [all] Error 1
make[1]: Leaving directory `/home/ubuntu/decaf-release-master/decaf/layers/cpp'
make: *** [all] Error 2
Failed to build the C libraries; exiting
编辑:当我尝试删除“-wl”时,我得到:
ubuntu@ubuntu-VirtualBox:~/decaf-release-master$ python setup.py
make -C layers/cpp/
make[1]: Entering directory `/home/ubuntu/decaf-release-master/decaf/layers/cpp'
g++ -c -fPIC -O3 -Wall -ffast-math -msse -msse2 -fopenmp im2col.cpp fastpool.cpp local_response_normalization.cpp neuron.cpp
g++ -shared -fopenmp -lgomp -o libcpputil.so *.o
make[1]: Leaving directory `/home/ubuntu/decaf-release-master/decaf/layers/cpp'
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
当我在Ubuntu 12.04和gcc 4.7.7上尝试它时,它以某种方式工作。
有人可以解释一下问题是什么,我该如何解决?
谢谢, 吉尔。
答案 0 :(得分:4)
从手册:
-Wl,选项 传递选项作为链接器的选项。如果选项包含逗号,则会在逗号中将其拆分为多个选项。你可以用它 将参数传递给选项的语法。例如, -Wl,-Map,output.map将-Map output.map传递给链接器。使用GNU链接器时,您也可以获得相同的效果 -Wl,-Map = output.map。
所以,你错过了-Wl。
的选项