我在 Windows 中工作,想将数据从 C++ 发送到 Matlab。我得到的印象是创建一个makefile最容易完成。因此我安装了 cygwin 来使用 make 命令。
我的makefile如下:
CXX = g++
CFLAGS = -O3 -I /cygdrive/c/Program\ Files/MATLAB/R2011a/extern/include
LIBS = -L /cygdrive/c/Program\ Files/MATLAB/R2011a/extern/lib/win64/microsoft/
LIBS2 = -L /cygdrive/c/Program\ Files/MATLAB/R2011a/extern/lib/win64/microsoft/libmx.lib
LDFLAGS = -leng -lmx
RKspace2d: RKspace2d.o
$(CXX) -o $@ $^ $(LDFLAGS) $(LIBS)
RKspace2d.o: RKspace2d.cpp
$(CXX) -c $(CFLAGS) $(LIBS) $<
# $@ name of the target
# $^ name of all prerequisites with duplicates removed
# $< name of the first prerequisite
当我在 cygwin 终端中输入“make”时,在正确的目录中,我收到以下错误:
$ make
g++ -o RKspace2d RKspace2d.o -leng -lmx -L /cygdrive/c/Program\ Files/MATLAB/R2011a/extern/lib/win64/microsoft/
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -leng
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmx
collect2: ld returnerede afslutningskoden 1
makefile:8: recipe for target `RKspace2d' failed
make: *** [RKspace2d] Error 1
我相信路径是正确的,因为 libeng.lib 和 libmx.lib 都包含在 microsoft 文件夹中。
希望你们能帮助托马斯