gpt4 book ai didi

c - 使用 mex 时出错 : Undefined symbols for architecture x86_64

转载 作者:行者123 更新时间:2023-11-30 16:35:53 25 4
gpt4 key购买 nike

我正在尝试在 Matlab 程序中使用 C 代码。 C 代码基本上解码数据矩阵代码并为您提供匹配的字符串。该代码大约有 17 个 c 文件。

在 Windows 机器上我可以编译 C 代码并且程序运行完美。当我在 Macbook Pro 上尝试相同的操作时,我总是收到此错误:

Error using mex
Undefined symbols for architecture x86_64:
"_square", referenced from:
_dist2_float in findBiggestEnclosedArea.o
_dist3_float in findBiggestEnclosedArea.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Error in make (line 76)
mex -g -DNDEBUG -DMATLAB decodeDatamatrix_mex.c...

这是我的编译命令:

mex -g -DNDEBUG -DMATLAB decodeDatamatrix_mex.c...
decode_datamatrix/decodeDatamatrix.c...
decode_datamatrix/imResize.c...
decode_datamatrix/otsu.c ...
decode_datamatrix/findBiggestEnclosedArea.c ...
decode_datamatrix/label.c ...
decode_datamatrix/floodfill.c...
decode_datamatrix/getRegion.c...
decode_datamatrix/edges.c...
decode_datamatrix/findParameters.c...
decode_datamatrix/firstHoughTransform.c ...
decode_datamatrix/secondHoughTransform.c ...
decode_datamatrix/getDatamatrixGrid.c ...
decode_datamatrix/CorrectErrs.c ...
decode_datamatrix/dmtxdecodescheme.c...
decode_datamatrix/placement.c...
decode_datamatrix/dmsize.c

这是完整的日志文件:

Verbose mode is on.
... Looking for compiler 'Xcode with Clang' ...
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('9.0').
... Executing command '
agreed=9.0
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('9.0').
... Executing command 'xcrun -sdk macosx --show-sdk-path' ...Yes ('/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk').
... Executing command 'xcrun -sdk macosx --show-sdk-version' ...Yes ('10.13').
Found installed compiler 'Xcode with Clang'.
Options file details
-------------------------------------------------------------------
Compiler location: /Applications/Xcode.app/Contents/Developer
Options file: /Users/fabian/Library/Application Support/MathWorks/MATLAB/R2017b/mex_C_maci64.xml
CMDLINE200 : /usr/bin/xcrun -sdk macosx10.13 clang -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/mexFunction.map" decodeDatamatrix_mex.o decodeDatamatrix.o imResize.o otsu.o findBiggestEnclosedArea.o label.o floodfill.o getRegion.o edges.o findParameters.o firstHoughTransform.o secondHoughTransform.o getDatamatrixGrid.o CorrectErrs.o dmtxdecodescheme.o placement.o dmsize.o c_mexapi_version.o -g -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/c_exportsmexfileversion.map" -L"/Applications/MATLAB_R2017b.app/bin/maci64" -lmx -lmex -lmat -lc++ -o decodeDatamatrix_mex.mexmaci64
CC : /usr/bin/xcrun -sdk macosx10.13 clang
CXX : /usr/bin/xcrun -sdk macosx10.13 clang++
DEFINES : -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
MACOSX_DEPLOYMENT_TARGET : 10.9
CFLAGS : -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk
INCLUDE : -I"/Applications/MATLAB_R2017b.app/extern/include" -I"/Applications/MATLAB_R2017b.app/simulink/include"
COPTIMFLAGS : -O2 -fwrapv -DNDEBUG
CDEBUGFLAGS : -g
LD : /usr/bin/xcrun -sdk macosx10.13 clang
LDXX : /usr/bin/xcrun -sdk macosx10.13 clang++
LDFLAGS : -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/mexFunction.map"
LDBUNDLE : -bundle
FUNCTIONMAP : "/Applications/MATLAB_R2017b.app/extern/lib/maci64/mexFunction.map"
VERSIONMAP : "/Applications/MATLAB_R2017b.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKEXPORT : -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/mexFunction.map"
LINKEXPORTVER : -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKLIBS : -L"/Applications/MATLAB_R2017b.app/bin/maci64" -lmx -lmex -lmat -lc++
LDOPTIMFLAGS : -O
LDDEBUGFLAGS : -g
OBJEXT : .o
LDEXT : .mexmaci64
SETENV : CC="/usr/bin/xcrun -sdk macosx10.13 clang"
CXX="/usr/bin/xcrun -sdk macosx10.13 clang++"
CFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE"
CXXFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -fobjc-arc -std=c++11 -stdlib=libc++ -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE"
COPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CXXOPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CDEBUGFLAGS="-g"
CXXDEBUGFLAGS="-g"
LD="/usr/bin/xcrun -sdk macosx10.13 clang"
LDXX="/usr/bin/xcrun -sdk macosx10.13 clang++"
LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/mexFunction.map" -L"/Applications/MATLAB_R2017b.app/bin/maci64" -lmx -lmex -lmat -lc++ -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/mexFunction.map""
LDDEBUGFLAGS="-g"
DEVELOPER_DIR_CHECK :
XCODE_DIR : /Applications/Xcode.app/Contents/Developer
XCRUN_DIR : /usr/bin
XCODE_AGREED_VERSION : 9.0
ISYSROOT : /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk
SDKVER : 10.13
MATLABROOT : /Applications/MATLAB_R2017b.app
ARCH : maci64
SRC : "/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decodeDatamatrix_mex.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/decodeDatamatrix.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/imResize.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/otsu.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/findBiggestEnclosedArea.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/label.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/floodfill.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/getRegion.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/edges.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/findParameters.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/firstHoughTransform.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/secondHoughTransform.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/getDatamatrixGrid.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/CorrectErrs.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/dmtxdecodescheme.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/placement.c";"/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/dmsize.c";"/Applications/MATLAB_R2017b.app/extern/version/c_mexapi_version.c"
OBJ : decodeDatamatrix_mex.o;decodeDatamatrix.o;imResize.o;otsu.o;findBiggestEnclosedArea.o;label.o;floodfill.o;getRegion.o;edges.o;findParameters.o;firstHoughTransform.o;secondHoughTransform.o;getDatamatrixGrid.o;CorrectErrs.o;dmtxdecodescheme.o;placement.o;dmsize.o;c_mexapi_version.o
OBJS : decodeDatamatrix_mex.o decodeDatamatrix.o imResize.o otsu.o findBiggestEnclosedArea.o label.o floodfill.o getRegion.o edges.o findParameters.o firstHoughTransform.o secondHoughTransform.o getDatamatrixGrid.o CorrectErrs.o dmtxdecodescheme.o placement.o dmsize.o c_mexapi_version.o
SRCROOT : /Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decodeDatamatrix_mex
DEF : /var/folders/xl/t0pk0jl56gj75637l3cq1h7h0000gn/T/mex_1191751144668386_17812/decodeDatamatrix_mex.def
EXP : decodeDatamatrix_mex.exp
LIB : decodeDatamatrix_mex.lib
EXE : decodeDatamatrix_mex.mexmaci64
ILK : decodeDatamatrix_mex.ilk
MANIFEST : decodeDatamatrix_mex.mexmaci64.manifest
TEMPNAME : decodeDatamatrix_mex
EXEDIR :
EXENAME : decodeDatamatrix_mex
OPTIM : -g
LINKOPTIM : -g
CMDLINE100_0 : /usr/bin/xcrun -sdk macosx10.13 clang -c -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017b.app/extern/include" -I"/Applications/MATLAB_R2017b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -g "/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decodeDatamatrix_mex.c" -o decodeDatamatrix_mex.o
CMDLINE100_1 : /usr/bin/xcrun -sdk macosx10.13 clang -c -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017b.app/extern/include" -I"/Applications/MATLAB_R2017b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -g "/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/decodeDatamatrix.c" -o decodeDatamatrix.o
CMDLINE100_2 : /usr/bin/xcrun -sdk macosx10.13 clang -c -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017b.app/extern/include" -I"/Applications/MATLAB_R2017b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -g "/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/imResize.c" -o imResize.o
.
.
.
CMDLINE100_17 : /usr/bin/xcrun -sdk macosx10.13 clang -c -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017b.app/extern/include" -I"/Applications/MATLAB_R2017b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -g "/Applications/MATLAB_R2017b.app/extern/version/c_mexapi_version.c" -o c_mexapi_version.o
-------------------------------------------------------------------
Building with 'Xcode with Clang'.
/usr/bin/xcrun -sdk macosx10.13 clang -c -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017b.app/extern/include" -I"/Applications/MATLAB_R2017b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -g "/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decodeDatamatrix_mex.c" -o decodeDatamatrix_mex.o
/usr/bin/xcrun -sdk macosx10.13 clang -c -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017b.app/extern/include" -I"/Applications/MATLAB_R2017b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -g "/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/decodeDatamatrix.c" -o decodeDatamatrix.o
.
.
.
/usr/bin/xcrun -sdk macosx10.13 clang -c -DNDEBUG -DMATLAB -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017b.app/extern/include" -I"/Applications/MATLAB_R2017b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -g "/Users/fabian/Documents/Diplomarbeit/BA_Tecan/Matlab-Code/Functions/Datamatrix_decoder/decode_datamatrix/findParameters.c" -o findParameters.o
/usr/bin/xcrun -sdk macosx10.13 clang -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/mexFunction.map" decodeDatamatrix_mex.o decodeDatamatrix.o imResize.o otsu.o findBiggestEnclosedArea.o label.o floodfill.o getRegion.o edges.o findParameters.o firstHoughTransform.o secondHoughTransform.o getDatamatrixGrid.o CorrectErrs.o dmtxdecodescheme.o placement.o dmsize.o c_mexapi_version.o -g -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017b.app/extern/lib/maci64/c_exportsmexfileversion.map" -L"/Applications/MATLAB_R2017b.app/bin/maci64" -lmx -lmex -lmat -lc++ -o decodeDatamatrix_mex.mexmaci64

知道错误可能出在哪里吗?

最佳答案

当我在没有 -g 参数的情况下编译时,它可以工作:

mex -DNDEBUG -DMATLAB decodeDatamatrix_mex.c...

知道为什么会这样吗?

关于c - 使用 mex 时出错 : Undefined symbols for architecture x86_64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48725584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com