问题描述
我的代码( https://github.com/fangq/mmc , https://github.com/fangq/mcxcl )已在Linux& Mac,Windows上的cygwin-gcc或msys2-gcc,但不适用于MinGW编译器(用于cygwin64,msys2,mingw64或TDM-GCC的x86-64-mingw64-*
编译器,或 matlab mingw64支持(mingw64 gcc 4.9.6)),因为它抱怨错过了一套头文件(sys/ioctl.h
,ieee754.h
等),因此我在源代码中包含了这些头文件的副本,并添加了-I./mingw64/include
以便使大多数文件都可以编译
My codes (https://github.com/fangq/mmc, https://github.com/fangq/mcxcl) have been compiled out-of-box using gcc on Linux & Mac, cygwin-gcc or msys2-gcc on Windows, but not with MinGW compilers (x86-64-mingw64-*
compilers for cygwin64, msys2, mingw64 or TDM-GCC, or matlab mingw64 support (mingw64 gcc 4.9.6)) because it complains that it misses a set of header files (sys/ioctl.h
, ieee754.h
etc), so I included a copy of these header files in my source code, and added -I./mingw64/include
to make most of them compile
https://github.com/fangq/mmc/tree/master/src/mingw64/include
但是,当使用此脚本编译matlab mex文件时,在MATLAB R2016/2018上,我收到以下错误
however, when compiling the matlab mex file using this script on MATLAB R2016/2018, I received the below error
Error using mex
mcx_utils.o: In function `mcx_progressbar':
D:/Users/fangq/Gitroot/Project/mmc/src/mcx_utils.c:1054: undefined reference to `ioctl'
collect2.exe: error: ld returned 1 exit status
我想知道为什么内部matlab和外部matlab的编译方式不同.有我可以链接的库来修复undefined reference to "ioctl"
错误吗?
I am wondering why compiling inside matlab and outside matlab are different. Is there a library that I can link to fix the undefined reference to "ioctl"
error?
这是在msys2上使用gcc进行编译时的日志:
Here is the log when compiling using gcc on msys2:
fangq@zen:~/space/git/Project/mmc/src$ make mex
Building built/xorshift128p_rand.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/xorshift128p_rand.o xorshift128p_rand.c
Building built/simpmesh.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/simpmesh.o simpmesh.c
Building built/tettracing.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/tettracing.o tettracing.c
Building built/mcx_utils.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/mcx_utils.o mcx_utils.c
Building built/tictoc.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/tictoc.o tictoc.c
Building built/mmc.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/mmc.o mmc.c
Building built/cjson/cJSON.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/cjson/cJSON.o cjson/cJSON.c
Building built/mmc_host.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/mmc_host.o mmc_host.c
Building built/highordermesh.o
g++ -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/highordermesh.o highordermesh.cpp
Building built/mmc_cl_utils.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/mmc_cl_utils.o mmc_cl_utils.c
Building built/mmc_cl_host.o
cc -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -I../src -I"./mingw64/include" -o built/mmc_cl_host.o mmc_cl_host.c
Building bin/mmc
cmd //c mex.bat -v -f mexopts_msys2_gcc.xml COMPFLAGS='$COMPFLAGS -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT' LDFLAGS='$LDFLAGS -static -fopenmp "c:\Windows\System32\OpenCL.dll" -fopenmp' -outdir ../mmclab mmclab.cpp -I../src -I"./mingw64/include" -output bin/mmc built/xorshift128p_rand.o built/simpmesh.o built/tettracing.o built/mcx_utils.o built/tictoc.o built/mmc.o built/cjson/cJSON.o built/mmc_host.o built/highordermesh.o built/mmc_cl_utils.o built/mmc_cl_host.o
Verbose mode is on.
... Looking for compiler 'MinGW64 Compiler (C++)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:/msys64/usr/').
... Looking for file 'C:\msys64\usr\bin\g++.exe' ...Yes.
... Looking for folder 'C:\msys64\usr' ...Yes.
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:/msys64/usr/').
... Executing command 'C:\msys64\usr\bin\g++ -dumpmachine' ...Yes ('x86_64-pc-msys').
Found installed compiler 'MinGW64 Compiler (C++)'.
Set PATH = C:\msys64\usr\bin;C:\Program Files\MATLAB\R2018a\extern\include\win64;C:\Program Files\MATLAB\R2018a\extern\include;C:\Program Files\MATLAB\R2018a\simulink\include;C:\Program Files\MATLAB\R2018a\lib\win64;.;C:\msys64\opt\local\bin;C:\msys64\usr\local\cuda\bin\;.;C:\msys64\pub\bin;C:\msys64\pub\pgi\linux86-64\18.4\bin;C:\msys64\mingw64\bin;C:\msys64\usr\local\bin;C:\msys64\usr\bin;C:\msys64\usr\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\msys64\usr\bin\site_perl;C:\msys64\usr\bin\vendor_perl;C:\msys64\usr\bin\core_perl;C:\msys64\usr\local\bin;C:\msys64\home\users\fangq\space\Download\MCXStudio;C;C:\Program Files\MATLAB\R2018a\bin;C:\msys64\usr\lib\gcc\x86_64-pc-msys\9.3.0\
Set INCLUDE = C:\msys64\usr\include;C:\msys64\usr\x86_64-pc-msys\include\c++;C:\msys64\usr\x86_64-pc-msys\include;C:\msys64\usr\x86_64-pc-msys\include\c++\x86_64-pc-msys;C:\msys64\usr\x86_64-pc-msys\include\c++\backward;
Set LIB = C:\msys64\usr\lib;;
Set MW_TARGET_ARCH = win64;
Set LIBPATH = C:\Program Files\MATLAB\R2018a\extern\lib\win64;
Options file details
-------------------------------------------------------------------
Compiler location: C:\msys64\usr
Options file: C:\msys64\home\fangq\space\git\Project\mmc\src\mexopts_msys2_gcc.xml
CMDLINE2 : C:\msys64\usr\bin\g++ -m64 -Wl,--no-undefined -static -fopenmp "c:\Windows\System32\OpenCL.dll" -fopenmp -shared -static -s -Wl,"C:\Program Files\MATLAB\R2018a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\msys64\tmp\mex_1481040925092289_7396\mmclab.obj C:\msys64\tmp\mex_1481040925092289_7396\cpp_mexapi_version.obj "built/xorshift128p_rand.o" "built/simpmesh.o" "built/tettracing.o" "built/mcx_utils.o" "built/tictoc.o" "built/mmc.o" "built/cjson/cJSON.o" "built/mmc_host.o" "built/highordermesh.o" "built/mmc_cl_utils.o" "built/mmc_cl_host.o" -L"C:\Program Files\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -o C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc.mexw64
CXX : C:\msys64\usr\bin\g++
COMPILER : C:\msys64\usr\bin\g++
DEFINES : -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
CFLAGS : -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -fexceptions -fno-omit-frame-pointer
CXXFLAGS : -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -fexceptions -fno-omit-frame-pointer
INCLUDE : -I"..\src" -I".\mingw64\include" -I"C:\msys64\usr\usr\include" -I"C:\Program Files\MATLAB\R2018a/extern/include" -I"C:\Program Files\MATLAB\R2018a/simulink/include"
CXXOPTIMFLAGS : -O -DNDEBUG
CXXDEBUGFLAGS : -g
LDXX : C:\msys64\usr\bin\g++
LINKER : C:\msys64\usr\bin\g++
LDFLAGS : -m64 -Wl,--no-undefined -static -fopenmp "c:\Windows\System32\OpenCL.dll" -fopenmp
LDTYPE : -shared -static
LINKEXPORT : -Wl,"C:\Program Files\MATLAB\R2018a/extern/lib/win64/mingw64/mexFunction.def"
LINKEXPORTVER : -Wl,"C:\Program Files\MATLAB\R2018a/extern/lib/win64/mingw64/exportsmexfileversion.def"
LIBLOC : C:\Program Files\MATLAB\R2018a\extern\lib\win64\mingw64
LINKLIBS : -L"C:\Program Files\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat
LDOPTIMFLAGS : -s
LDDEBUGFLAGS : -g
OBJEXT : .obj
LDEXT : .mexw64
SETENV : set COMPILER=C:\msys64\usr\bin\gcc
set CXXCOMPILER=C:\msys64\usr\bin\g++
set COMPFLAGS=-c -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -fexceptions -fno-omit-frame-pointer -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE
set CXXCOMPFLAGS=-c -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE
set OPTIMFLAGS=-O -DNDEBUG
set DEBUGFLAGS=-g
set LINKER=C:\msys64\usr\bin\gcc
set CXXLINKER=C:\msys64\usr\bin\g++
set LINKFLAGS=-m64 -Wl,--no-undefined -static -fopenmp "c:\Windows\System32\OpenCL.dll" -fopenmp -shared -static -L"C:\Program Files\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -Wl,"C:\Program Files\MATLAB\R2018a/extern/lib/win64/mingw64/mexFunction.def"
set LINKDEBUGFLAGS=-g
set NAME_OUTPUT= -o "%OUTDIR%%MEX_NAME%%MEX_EXT%"
MINGWROOT : C:\msys64\usr
MINGWTARGET : x86_64-pc-msys
MATLABROOT : C:\Program Files\MATLAB\R2018a
ARCH : win64
SRC : "C:\msys64\home\fangq\space\git\Project\mmc\src\mmclab.cpp";"C:\Program Files\MATLAB\R2018a\extern\version\cpp_mexapi_version.cpp"
OBJ : C:\msys64\tmp\mex_1481040925092289_7396\mmclab.obj;C:\msys64\tmp\mex_1481040925092289_7396\cpp_mexapi_version.obj
OBJS : C:\msys64\tmp\mex_1481040925092289_7396\mmclab.obj C:\msys64\tmp\mex_1481040925092289_7396\cpp_mexapi_version.obj "built/xorshift128p_rand.o" "built/simpmesh.o" "built/tettracing.o" "built/mcx_utils.o" "built/tictoc.o" "built/mmc.o" "built/cjson/cJSON.o" "built/mmc_host.o" "built/highordermesh.o" "built/mmc_cl_utils.o" "built/mmc_cl_host.o"
SRCROOT : C:\msys64\home\fangq\space\git\Project\mmc\src\mmclab
DEF : C:\msys64\tmp\mex_1481040925092289_7396\mmc.def
EXP : "C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc.exp"
LIB : "C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc.lib"
EXE : C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc.mexw64
ILK : "C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc.ilk"
MANIFEST : "C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc.mexw64.manifest"
TEMPNAME : C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc
EXEDIR : C:\msys64\home\fangq\space\git\Project\mmc\mmclab\
EXENAME : mmc
COMPFLAGS : -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT
OPTIM : -O -DNDEBUG
LINKOPTIM : -s
CMDLINE1_0 : C:\msys64\usr\bin\g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"..\src" -I".\mingw64\include" -I"C:\msys64\usr\usr\include" -I"C:\Program Files\MATLAB\R2018a/extern/include" -I"C:\Program Files\MATLAB\R2018a/simulink/include" -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\msys64\home\fangq\space\git\Project\mmc\src\mmclab.cpp" -o C:\msys64\tmp\mex_1481040925092289_7396\mmclab.obj
CMDLINE1_1 : C:\msys64\usr\bin\g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"..\src" -I".\mingw64\include" -I"C:\msys64\usr\usr\include" -I"C:\Program Files\MATLAB\R2018a/extern/include" -I"C:\Program Files\MATLAB\R2018a/simulink/include" -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\Program Files\MATLAB\R2018a\extern\version\cpp_mexapi_version.cpp" -o C:\msys64\tmp\mex_1481040925092289_7396\cpp_mexapi_version.obj
-------------------------------------------------------------------
Building with 'MinGW64 Compiler (C++)'.
Warning: You are using an unsupported version of MinGW Compiler. To install the supported version of MinGW compiler, visit https://www.mathworks.com/help/matlab/matlab_external/install-mingw-support-package.html.
For a list of currently supported compilers see: https://www.mathworks.com/support/compilers.
C:\msys64\usr\bin\g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"..\src" -I".\mingw64\include" -I"C:\msys64\usr\usr\include" -I"C:\Program Files\MATLAB\R2018a/extern/include" -I"C:\Program Files\MATLAB\R2018a/simulink/include" -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\msys64\home\fangq\space\git\Project\mmc\src\mmclab.cpp" -o C:\msys64\tmp\mex_1481040925092289_7396\mmclab.obj
C:\msys64\usr\bin\g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"..\src" -I".\mingw64\include" -I"C:\msys64\usr\usr\include" -I"C:\Program Files\MATLAB\R2018a/extern/include" -I"C:\Program Files\MATLAB\R2018a/simulink/include" -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\Program Files\MATLAB\R2018a\extern\version\cpp_mexapi_version.cpp" -o C:\msys64\tmp\mex_1481040925092289_7396\cpp_mexapi_version.obj
C:\msys64\usr\bin\g++ -m64 -Wl,--no-undefined -static -fopenmp "c:\Windows\System32\OpenCL.dll" -fopenmp -shared -static -s -Wl,"C:\Program Files\MATLAB\R2018a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\msys64\tmp\mex_1481040925092289_7396\mmclab.obj C:\msys64\tmp\mex_1481040925092289_7396\cpp_mexapi_version.obj "built/xorshift128p_rand.o" "built/simpmesh.o" "built/tettracing.o" "built/mcx_utils.o" "built/tictoc.o" "built/mmc.o" "built/cjson/cJSON.o" "built/mmc_host.o" "built/highordermesh.o" "built/mmc_cl_utils.o" "built/mmc_cl_host.o" -L"C:\Program Files\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -o C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc.mexw64
Recompile embedded version with '-DMATLAB_MEXCMD_RELEASE=R2017b'
C:\msys64\usr\bin\g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"..\src" -I".\mingw64\include" -I"C:\msys64\usr\usr\include" -I"C:\Program Files\MATLAB\R2018a/extern/include" -I"C:\Program Files\MATLAB\R2018a/simulink/include" -c -Wall -g -DMCX_EMBED_CL -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp -DMCX_CONTAINER -DUSE_OS_TIMER -DUSE_OPENCL -DMMC_XORSHIFT -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\Program Files\MATLAB\R2018a\extern\version\cpp_mexapi_version.cpp" -o C:\msys64\tmp\mex_1481040925092289_7396\cpp_mexapi_version.obj -DMATLAB_MEXCMD_RELEASE=R2017b
C:\msys64\usr\bin\g++ -m64 -Wl,--no-undefined -static -fopenmp "c:\Windows\System32\OpenCL.dll" -fopenmp -shared -static -s -Wl,"C:\Program Files\MATLAB\R2018a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\msys64\tmp\mex_1481040925092289_7396\mmclab.obj C:\msys64\tmp\mex_1481040925092289_7396\cpp_mexapi_version.obj "built/xorshift128p_rand.o" "built/simpmesh.o" "built/tettracing.o" "built/mcx_utils.o" "built/tictoc.o" "built/mmc.o" "built/cjson/cJSON.o" "built/mmc_host.o" "built/highordermesh.o" "built/mmc_cl_utils.o" "built/mmc_cl_host.o" -L"C:\Program Files\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -o C:\msys64\home\fangq\space\git\Project\mmc\mmclab\mmc.mexw64
MEX completed successfully.
fangq@zen:~/space/git/Project/mmc/src$ which gcc
/usr/bin/gcc
fangq@zen:~/space/git/Project/mmc/src$ which g++
/usr/bin/g++
fangq@zen:~/space/git/Project/mmc/src$ which cc
/usr/bin/cc
fangq@zen:~/space/git/Project/mmc/src$ gcc --version
gcc (GCC) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
推荐答案
您加入ioctl.h
的原因是什么?
从其他地方复制该标头是一个坏主意.充其量,它将定义不存在导致链接器错误的库的函数.
Copying that header from somewhere else is a bad idea. At best it will define functions for which libraries don't exist causing linker errors.
通常,您需要在其他平台上执行的所有IOCTL工作都使用Windows替代方法.
Typically you would need to use Windows alternatives for whatever IOCTL stuff you do on other platforms.
我尝试在Windows上使用MSYS2删除此包含内容来编译MMC,并且构建成功:
I tried to compile MMC on Windows with MSYS2 removing this include and the build succeeded:
patch -ulbf src/mcx_utils.c << EOF
@@ -35,3 +35,5 @@
#include <time.h>
+#ifndef _WIN32
#include <sys/ioctl.h>
+#endif
#include "mcx_utils.h"
EOF
sed -i.bak -e "s/^EXTRALIB\s*+*=.*$/& -Wl,--as-needed -lwinmm/" commons/Makefile_common.mk
~/buildstatus.sh build &&
make -Csrc CC=gcc PLATFORM=MINGW32 &&
echo Success
这篇关于如何使用sys/ioctl.h将代码移植到MinGW gcc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!