Error using mex Undefined symbols for architecture x86_64 - macos

Hello I'm trying to compile a code in c using mex command in a Mac 10.12.3 Sierra:
mex -v foldin.c -lmwlapack -lmwblas
However, I 've obtained in the vervose mode the next error:
Verbose mode is on.
Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require the use of
-largeArrayDims and remove the -compatibleArrayDims option.
For more information:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
... 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 ('8.2.1').
... Executing command '
agreed=8.2.1
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 ('8.2.1').
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk' ...Yes.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk' ...Yes.
... Executing command 'echo /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk | rev | cut -c1-10 | rev | egrep -oh '[0-9]+\.[0-9]+'' ...Yes ('10.12').
Found installed compiler 'Xcode with Clang'.
Options file details
-------------------------------------------------------------------
Compiler location: /Applications/Xcode.app/Contents/Developer
Options file: /Applications/MATLAB_R2016b.app/bin/maci64/mexopts/clang_maci64.xml
CMDLINE200 : /usr/bin/xcrun -sdk macosx10.12 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.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map" /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o -O -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map" -lmwlapack -lmwblas -L"/Applications/MATLAB_R2016b.app/bin/maci64" -lmx -lmex -lmat -lc++ -o foldin.mexmaci64
CC : /usr/bin/xcrun -sdk macosx10.12 clang
DEFINES : -DMX_COMPAT_32 -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.12.sdk
INCLUDE : -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.app/simulink/include"
COPTIMFLAGS : -O2 -fwrapv -DNDEBUG
CDEBUGFLAGS : -g
LD : /usr/bin/xcrun -sdk macosx10.12 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.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map"
LDBUNDLE : -bundle
FUNCTIONMAP : "/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map"
VERSIONMAP : "/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKEXPORT : -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map"
LINKEXPORTVER : -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKLIBS : -lmwlapack -lmwblas -L"/Applications/MATLAB_R2016b.app/bin/maci64" -lmx -lmex -lmat -lc++
LDOPTIMFLAGS : -O
LDDEBUGFLAGS : -g
OBJEXT : .o
LDEXT : .mexmaci64
SETENV : CC="/usr/bin/xcrun -sdk macosx10.12 clang"
CXX="/usr/bin/xcrun -sdk macosx10.12 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.12.sdk -DMX_COMPAT_32 -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.12.sdk -DMX_COMPAT_32 -DMATLAB_MEX_FILE"
COPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CXXOPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CDEBUGFLAGS="-g"
CXXDEBUGFLAGS="-g"
LD="/usr/bin/xcrun -sdk macosx10.12 clang"
LDXX="/usr/bin/xcrun -sdk macosx10.12 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.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map" -lmwlapack -lmwblas -L"/Applications/MATLAB_R2016b.app/bin/maci64" -lmx -lmex -lmat -lc++ -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.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 : 8.2.1
ISYSROOT : /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
SDKVER : 10.12
MATLABROOT : /Applications/MATLAB_R2016b.app
ARCH : maci64
SRC : /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin.c;/Applications/MATLAB_R2016b.app/extern/version/c_mexapi_version.c
OBJ : /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o;/var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o
OBJS : /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o
SRCROOT : /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin
DEF : /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.def
EXP : foldin.exp
LIB : foldin.lib
EXE : foldin.mexmaci64
ILK : foldin.ilk
MANIFEST : foldin.mexmaci64.manifest
TEMPNAME : foldin
EXEDIR :
EXENAME : foldin
OPTIM : -O2 -fwrapv -DNDEBUG
LINKOPTIM : -O
CMDLINE100_0 : /usr/bin/xcrun -sdk macosx10.12 clang -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.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.12.sdk -O2 -fwrapv -DNDEBUG /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin.c -o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o
CMDLINE100_1 : /usr/bin/xcrun -sdk macosx10.12 clang -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.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.12.sdk -O2 -fwrapv -DNDEBUG /Applications/MATLAB_R2016b.app/extern/version/c_mexapi_version.c -o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o
-------------------------------------------------------------------
Building with 'Xcode with Clang'.
/usr/bin/xcrun -sdk macosx10.12 clang -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.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.12.sdk -O2 -fwrapv -DNDEBUG /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin.c -o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o
In file included from /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin.c:2:
/Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/fold.c:101:6: warning: implicit declaration of function 'dgemm_' is invalid in C99 [-Wimplicit-function-declaration]
DGEMM(&transa, &transb, &i_len, &m_len, &l_len, &alpha,
^
/Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/fold.c:84:16: note: expanded from macro 'DGEMM'
# define DGEMM dgemm_
^
/Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/fold.c:279:2: warning: implicit declaration of function 'mxErrMsgTxt' is invalid in C99 [-Wimplicit-function-declaration]
mxErrMsgTxt("Sizes of folded indices do not match");
^
2 warnings generated.
/usr/bin/xcrun -sdk macosx10.12 clang -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.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.12.sdk -O2 -fwrapv -DNDEBUG /Applications/MATLAB_R2016b.app/extern/version/c_mexapi_version.c -o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o
/usr/bin/xcrun -sdk macosx10.12 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.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map" /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o -O -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map" -lmwlapack -lmwblas -L"/Applications/MATLAB_R2016b.app/bin/maci64" -lmx -lmex -lmat -lc++ -o foldin.mexmaci64
Error using mex
Undefined symbols for architecture x86_64:
"_mxErrMsgTxt", referenced from:
_mexFunction in foldin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The _mexFunction is the following one:
void
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
double *ndx1, *ndx1max, *ndx2, *ndx2max;
if (nrhs != 6) {
mexErrMsgTxt("Wrong number of arguments");
}
if (nlhs > 1) {
mexErrMsgTxt("Too many output arguments expected");
}
ndx1 = mxGetPr(prhs[2]);
if (mxGetNumberOfElements(prhs[2]) > 1) {
ndx1max = ndx1 + 1;
} else {
ndx1max = ndx1;
}
ndx2 = mxGetPr(prhs[5]);
if (mxGetNumberOfElements(prhs[5]) > 1) {
ndx2max = ndx2 + 1;
} else {
ndx2max = ndx2;
}
plhs[0] = fold(prhs[0], mxGetScalar(prhs[1]), *ndx1, *ndx1max,
prhs[3], mxGetScalar(prhs[4]), *ndx2, *ndx2max);
}
The problem is that the program fold.c is not mine and I don't know if there is a problem with the program itself or I have not use mex command appropriately. On the other hand I'm using Xcode 8 as compiler. Could anyone help me please?

I just had the same problem compiling code that wasn't mine. Just replace the occurences of mxErrMsgTxt("bliblablu") with mexErrMsgIdAndTxt("xxx","bliblablu").
(see https://www.mathworks.com/help/matlab/apiref/mexerrmsgtxt.html eg. https://www.mathworks.com/help/matlab/apiref/mexerrmsgidandtxt.html)

Related

meson setting proper kinker flag in static library

in my project I need to compile a static library, the meson.build for it is the following
# libcustomLog library project.
#
project(
'customLog',
'c',
version : '1.0.0',
default_options : ['warning_level=3']
)
project_description = 'An example shared library'
project_headers = [
'libcustomLog.h'
]
project_source_files = [
'libcustomLog.c',
'libcustomLogGet.c',
'libcustomLogStripe.c'
]
build_args = [
]
# ===================================================================
# ======
# Target
# ======
public_headers = include_directories('../',
'../public'
)
build_args = [
'-DQNXNTO',
'-DQNX_VER=7',
'-DfwPLATFORM_NTO',
'-Wall',
'-Werror',
'-fsigned-char',
'-Wno-char-subscripts',
'-Wno-switch',
'-Wno-parentheses',
'-Wno-pointer-sign',
'-Wredundant-decls',
'-Wmissing-declarations',
'-Wmissing-prototypes',
'-O3',
'-fno-strict-aliasing',
'-std=gnu99',
'-g',
]
project_target = static_library(
meson.project_name(),
project_source_files,
install : true,
c_args : build_args,
gnu_symbol_visibility : 'hidden',
include_directories : public_headers,
)
# =======
# Project
# =======
# Make this library usable as a Meson subproject.
project_dep = declare_dependency(
include_directories: public_headers,
link_with : project_target
)
set_variable(meson.project_name() + '_dep', project_dep)
# Make this library usable from the system's
# package manager.
install_headers(project_headers, subdir : meson.project_name())
pkg_mod = import('pkgconfig')
pkg_mod.generate(
name : meson.project_name(),
filebase : meson.project_name(),
description : project_description,
subdirs : meson.project_name(),
libraries : project_target,
)
the compilation output is
$ meson compile --verbose
Found runner: ['/usr/bin/ninja']
ninja: Entering directory `.'
[1/4] /opt/qnx700/host/linux/x86_64/usr/bin/ntox86_64-gcc -Isrc/mon/libcustomLog.a.p -Isrc/mon -I../../src/mon -Isrc -I../../src -I../../src/public -fvisibility=hidden -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -fPIC -DQNXNTO -DQNX_VER=7 -DfwPLATFORM_NTO -Wall -Werror -fsigned-char -Wno-char-subscripts -Wno-switch -Wno-parentheses -Wno-pointer-sign -Wredundant-decls -Wmissing-declarations -Wmissing-prototypes -O3 -fno-strict-aliasing -std=gnu99 -g -MD -MQ src/mon/libcustomLog.a.p/libcustomLogStripe.c.o -MF src/mon/libcustomLog.a.p/libcustomLogStripe.c.o.d -o src/mon/libcustomLog.a.p/libcustomLogStripe.c.o -c ../../src/mon/libcustomLogStripe.c
[2/4] /opt/qnx700/host/linux/x86_64/usr/bin/ntox86_64-gcc -Isrc/mon/libcustomLog.a.p -Isrc/mon -I../../src/mon -Isrc -I../../src -I../../src/public -fvisibility=hidden -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -fPIC -DQNXNTO -DQNX_VER=7 -DfwPLATFORM_NTO -Wall -Werror -fsigned-char -Wno-char-subscripts -Wno-switch -Wno-parentheses -Wno-pointer-sign -Wredundant-decls -Wmissing-declarations -Wmissing-prototypes -O3 -fno-strict-aliasing -std=gnu99 -g -MD -MQ src/mon/libcustomLog.a.p/libcustomLogGetCode.c.o -MF src/mon/libcustomLog.a.p/libcustomLogGetCode.c.o.d -o src/mon/libcustomLog.a.p/libcustomLogGetCode.c.o -c ../../src/mon/libcustomLogGetCode.c
[3/4] /opt/qnx700/host/linux/x86_64/usr/bin/ntox86_64-gcc -Isrc/mon/libcustomLog.a.p -Isrc/mon -I../../src/mon -Isrc -I../../src -I../../src/public -fvisibility=hidden -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -fPIC -DQNXNTO -DQNX_VER=7 -DfwPLATFORM_NTO -Wall -Werror -fsigned-char -Wno-char-subscripts -Wno-switch -Wno-parentheses -Wno-pointer-sign -Wredundant-decls -Wmissing-declarations -Wmissing-prototypes -O3 -fno-strict-aliasing -std=gnu99 -g -MD -MQ src/mon/libcustomLog.a.p/libcustomLog.c.o -MF src/mon/libcustomLog.a.p/libcustomLog.c.o.d -o src/mon/libcustomLog.a.p/libcustomLog.c.o -c ../../src/mon/libcustomLog.c
[4/4] rm -f src/mon/libcustomLog.a && /opt/qnx700/host/linux/x86_64/usr/bin/ntox86_64-ar csrD src/mon/libcustomLog.a src/mon/libcustomLog.a.p/libcustomLog.c.o src/mon/libcustomLog.a.p/libcustomLogGetCode.c.o src/mon/libcustomLog.a.p/libcustomLogStripe.c.o
now I would change the archive flags
...ntox86_64-ar csrD .....
in
...ntox86_64-ar -ru .....
how can I ovverride the default ones and add the "-ru"
I've tried to modify the meson.build
build_ar_args = [
'-ru'
]
project_target = static_library(
meson.project_name(),
project_source_files,
install : true,
c_args : build_args,
gnu_symbol_visibility : 'hidden',
include_directories : public_headers,
link_args: build_ar_args
)
but the output is the same.

Can't install VisualSFM macOS High Sierra because it requires cairo-x11 which is no longer supported

I am trying to install VisualSFM on my MacBook Pro mid-2015 running High Sierra for a photogrammetry project I am currently working on with a professor. To do the install I am using Dan Monaghan's installer along with this video to do the install;however, when I run the installer, I get this error:
==> make install
Last 15 lines from /Users/Steven/Library/Logs/Homebrew/gtk+/02.make:
libtool: compile: clang -DHAVE_CONFIG_H -I. -I../.. - DG_LOG_DOMAIN=\"Gdk\" -DGDK_COMPILATION -I../.. -I../../gdk -I../../gdk -DG_DISABLE_CAST_CHECKS -DDISABLE_VISIBILITY -D_REENTRANT -I/usr/local/Cellar/pcre/8.42/include -I/usr/local/Cellar/glib/2.56.1/include/gio-unix-2.0/ -I/usr/local/Cellar/glib/2.56.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/libpng/1.6.34/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.36.12/include/gdk-pixbuf-2.0 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.13.0/include -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/Cellar/cairo/1.14.12/include/cairo -I/usr/local/Cellar/fribidi/1.0.4/include/fribidi -I/usr/local/Cellar/graphite2/1.3.11/include -I/usr/local/Cellar/harfbuzz/1.8.0/include/harfbuzz -I/usr/local/Cellar/pango/1.42.1/include/pango-1.0 -I/opt/X11/include -I/opt/X11/include/cairo -I/opt/X11/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -I/opt/X11/include -g -O2 -Wall -c gdkcursor-x11.c -fno-common -DPIC -o .libs/gdkcursor-x11.o
libtool: compile: clang -DHAVE_CONFIG_H -I. -I../.. -DG_LOG_DOMAIN=\"Gdk\" -DGDK_COMPILATION -I../.. -I../../gdk -I../../gdk -DG_DISABLE_CAST_CHECKS -DDISABLE_VISIBILITY -D_REENTRANT -I/usr/local/Cellar/pcre/8.42/include -I/usr/local/Cellar/glib/2.56.1/include/gio-unix-2.0/ -I/usr/local/Cellar/glib/2.56.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/libpng/1.6.34/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.36.12/include/gdk-pixbuf-2.0 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.13.0/include -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/Cellar/cairo/1.14.12/include/cairo -I/usr/local/Cellar/fribidi/1.0.4/include/fribidi -I/usr/local/Cellar/graphite2/1.3.11/include -I/usr/local/Cellar/harfbuzz/1.8.0/include/harfbuzz -I/usr/local/Cellar/pango/1.42.1/include/pango-1.0 -I/opt/X11/include -I/opt/X11/include/cairo -I/opt/X11/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -I/opt/X11/include -g -O2 -Wall -c gdkapplaunchcontext-x11.c -fno-common -DPIC -o .libs/gdkapplaunchcontext-x11.o
libtool: compile: clang -DHAVE_CONFIG_H -I. -I../.. -DG_LOG_DOMAIN=\"Gdk\" -DGDK_COMPILATION -I../.. -I../../gdk -I../../gdk -DG_DISABLE_CAST_CHECKS -DDISABLE_VISIBILITY -D_REENTRANT -I/usr/local/Cellar/pcre/8.42/include -I/usr/local/Cellar/glib/2.56.1/include/gio-unix-2.0/ -I/usr/local/Cellar/glib/2.56.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/libpng/1.6.34/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.36.12/include/gdk-pixbuf-2.0 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.13.0/include -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/Cellar/cairo/1.14.12/include/cairo -I/usr/local/Cellar/fribidi/1.0.4/include/fribidi -I/usr/local/Cellar/graphite2/1.3.11/include -I/usr/local/Cellar/harfbuzz/1.8.0/include/harfbuzz -I/usr/local/Cellar/pango/1.42.1/include/pango-1.0 -I/opt/X11/include -I/opt/X11/include/cairo -I/opt/X11/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -I/opt/X11/include -g -O2 -Wall -c gdkdisplay-x11.c -fno-common -DPIC -o .libs/gdkdisplay-x11.o
libtool: compile: clang -DHAVE_CONFIG_H -I. -I../.. -DG_LOG_DOMAIN=\"Gdk\" -DGDK_COMPILATION -I../.. -I../../gdk -I../../gdk -DG_DISABLE_CAST_CHECKS -DDISABLE_VISIBILITY -D_REENTRANT -I/usr/local/Cellar/pcre/8.42/include -I/usr/local/Cellar/glib/2.56.1/include/gio-unix-2.0/ -I/usr/local/Cellar/glib/2.56.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/libpng/1.6.34/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.36.12/include/gdk-pixbuf-2.0 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.13.0/include -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/Cellar/cairo/1.14.12/include/cairo -I/usr/local/Cellar/fribidi/1.0.4/include/fribidi -I/usr/local/Cellar/graphite2/1.3.11/include -I/usr/local/Cellar/harfbuzz/1.8.0/include/harfbuzz -I/usr/local/Cellar/pango/1.42.1/include/pango-1.0 -I/opt/X11/include -I/opt/X11/include/cairo -I/opt/X11/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -I/opt/X11/include -g -O2 -Wall -c gdkdrawable-x11.c -fno-common -DPIC -o .libs/gdkdrawable-x11.o
libtool: compile: clang -DHAVE_CONFIG_H -I. -I../.. -DG_LOG_DOMAIN=\"Gdk\" -DGDK_COMPILATION -I../.. -I../../gdk -I../../gdk -DG_DISABLE_CAST_CHECKS -DDISABLE_VISIBILITY -D_REENTRANT -I/usr/local/Cellar/pcre/8.42/include -I/usr/local/Cellar/glib/2.56.1/include/gio-unix-2.0/ -I/usr/local/Cellar/glib/2.56.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/libpng/1.6.34/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.36.12/include/gdk-pixbuf-2.0 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.13.0/include -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/Cellar/cairo/1.14.12/include/cairo -I/usr/local/Cellar/fribidi/1.0.4/include/fribidi -I/usr/local/Cellar/graphite2/1.3.11/include -I/usr/local/Cellar/harfbuzz/1.8.0/include/harfbuzz -I/usr/local/Cellar/pango/1.42.1/include/pango-1.0 -I/opt/X11/include -I/opt/X11/include/cairo -I/opt/X11/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -I/opt/X11/include -g -O2 -Wall -c gdkdnd-x11.c -fno-common -DPIC -o .libs/gdkdnd-x11.o
libtool: compile: clang -DHAVE_CONFIG_H -I. -I../.. -DG_LOG_DOMAIN=\"Gdk\" -DGDK_COMPILATION -I../.. -I../../gdk -I../../gdk -DG_DISABLE_CAST_CHECKS -DDISABLE_VISIBILITY -D_REENTRANT -I/usr/local/Cellar/pcre/8.42/include -I/usr/local/Cellar/glib/2.56.1/include/gio-unix-2.0/ -I/usr/local/Cellar/glib/2.56.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/libpng/1.6.34/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.36.12/include/gdk-pixbuf-2.0 -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/fontconfig/2.13.0/include -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/Cellar/cairo/1.14.12/include/cairo -I/usr/local/Cellar/fribidi/1.0.4/include/fribidi -I/usr/local/Cellar/graphite2/1.3.11/include -I/usr/local/Cellar/harfbuzz/1.8.0/include/harfbuzz -I/usr/local/Cellar/pango/1.42.1/include/pango-1.0 -I/opt/X11/include -I/opt/X11/include/cairo -I/opt/X11/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -I/opt/X11/include -g -O2 -Wall -c gdkevents-x11.c -fno-common -DPIC -o .libs/gdkevents-x11.o
gdkdrawable-x11.c:32:10: fatal error: 'cairo-xlib.h' file not found
#include <cairo-xlib.h>
^~~~~~~~~~~~~~
1 error generated.
make[3]: *** [gdkdrawable-x11.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [install-recursive] Error 1
make[1]: *** [install] Error 2
make: *** [install-recursive] Error 1
Do not report this issue to Homebrew/brew or Homebrew/core!
...
cd build; ar -x ../lib/VisualSFM.a; cd ..;
Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
g++-4.9 -w -o bin/VisualSFM build/*.* -L/usr/local/lib -L/opt/X11/lib -pthread -lGL -lGLU -lX11 -ldl lib/lapack.a lib/blas.a lib/libf2c.a lib/libjpeg.a
Undefined symbols for architecture x86_64:
"_g_cclosure_new", referenced from:
RegisterWin::GetOpenFilePreview(char const*, char const*, int, int) in RegisterGUI.o
"_g_free", referenced from:
RegisterWin::__FileChooserPreview(_GtkFileChooser*, void*) in RegisterGUI.o
RegisterWin::__ComboBoxChanged(_GtkComboBox*, void*) in RegisterGUI.o
...
"_gtk_window_set_type_hint", referenced from:
GlobalTasks::InitLogWindow(char const*, int) in GlobalTasks.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [VisualSFM] Error 1
VSFM application failed to build, halting.
The problem seems to be do to the fact that it requires cairo with x11;however Apple no longer supports cairo with x11 because of XQuartz. I tried brew install --with-x11 cairo but got Warning: cairo: this formula has no --with-x11 option so it will be ignored! I am not sure if it would solve my problem with installing VisualSFM, but is there anyway to install an old version of Cairo with X11?

linker could not found object files from different directory with scons

Currently, I make a project with scons.
I compiled source codes and it is time to link them.
However, I got an error that ld cannot find object files.
The SConscript is located in src/kernel32, and
import os, sys
# Compile CPP
env_gpp_options = {
'CXX' : 'x86_64-pc-linux-g++',
'CXXFLAGS' : '-std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti',
'LINK' : 'x86_64-pc-linux-ld',
'LINKFLAGS' : '-melf_i386 -T scripts/elf_i386.x -nostdlib -e main -Ttext 0x10200',
}
env_gpp = Environment(**env_gpp_options)
env_gpp.Append(ENV = {'PATH' : os.environ['PATH']})
object_cpp_list = Glob('*.cpp')
for object_cpp in object_cpp_list:
env_gpp.Object(object_cpp)
# Find all object file
object_target_list = Glob('*.o')
# Linking
env_link_target = 'kernel32.elf'
env_gpp.Program(env_link_target, object_target_list)
and message I got is
x86_64-pc-linux-g++ -o build/kernel32/cpu.o -c -std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti src/kernel32/cpu.cpp
x86_64-pc-linux-g++ -o build/kernel32/main.o -c -std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti src/kernel32/main.cpp
x86_64-pc-linux-g++ -o build/kernel32/memory.o -c -std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti src/kernel32/memory.cpp
x86_64-pc-linux-g++ -o build/kernel32/pageManager.o -c -std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti src/kernel32/pageManager.cpp
x86_64-pc-linux-g++ -o build/kernel32/utils.o -c -std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti src/kernel32/utils.cpp
x86_64-pc-linux-ld -o build/kernel32/kernel32.elf -melf_i386 -T scripts/elf_i386.x -nostdlib -e main -Ttext 0x10200 build/kernel32/asmUtils.o build/kernel32/cpu.o build/kernel32/main.o build/kernel32/memory.o build/kernel32/pageManager.o build/kernel32/utils.o
x86_64-pc-linux-ld: cannot find main.o
scons: *** [build/kernel32/kernel32.elf] Error 1
scons: building terminated because of errors.
I checked the directory, build/kernel32/, and I found main.o file.
What is my mistake?
Is there an way to change working directory for scons?
Please let me know what I missed.
You can try this:
import os, sys
# Compile CPP
env_gpp_options = {
'CXX' : 'x86_64-pc-linux-g++',
'CXXFLAGS' : '-std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti',
'LINK' : 'x86_64-pc-linux-ld',
'LINKFLAGS' : '-melf_i386 -T scripts/elf_i386.x -nostdlib -e main -Ttext 0x10200',
}
env_gpp = Environment(**env_gpp_options)
env_gpp.Append(ENV = {'PATH' : os.environ['PATH']})
object_cpp_list = Glob('*.cpp')
object_target_list = []
for object_cpp in object_cpp_list:
object_target_list.extend(env_gpp.Object(object_cpp))
# Linking
env_link_target = 'kernel32.elf'
env_gpp.Program(env_link_target, object_target_list)
Or
import os, sys
# Compile CPP
env_gpp_options = {
'CXX' : 'x86_64-pc-linux-g++',
'CXXFLAGS' : '-std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti',
'LINK' : 'x86_64-pc-linux-ld',
'LINKFLAGS' : '-melf_i386 -T scripts/elf_i386.x -nostdlib -e main -Ttext 0x10200',
}
env_gpp = Environment(**env_gpp_options)
env_gpp.Append(ENV = {'PATH' : os.environ['PATH']})
object_cpp_list = Glob('*.cpp')
# Linking
env_link_target = 'kernel32.elf'
env_gpp.Program(env_link_target, object_cpp_list)
This is full scons scripts.
In project root directory,
#SConstruct
build_dir = 'build'
# Build
SConscript(['src/SConscript'], variant_dir = build_dir, duplicate = 0)
# Clean
Clean('.', build_dir)
In src directory
#SConscript for src
SConscript(['bootloader/SConscript',
'kernel32/SConscript'])
In kernel32 directory
#SConscript for kernel32
import os, sys
# Build entry
env_entry = Environment(tools=['default', 'nasm'])
target_entry = 'entry.bin'
object_entry = 'entry.s'
output_entry = env_entry.Object(target_entry, object_entry)
# Compile CPP
env_gpp_options = {
'CXX' : 'x86_64-pc-linux-g++',
'CXXFLAGS' : '-std=c++11 -g -m32 -ffreestanding -fno-exceptions -fno-rtti',
'LINK' : 'x86_64-pc-linux-ld',
'LINKFLAGS' : '-melf_i386 -T scripts/elf_i386.x -nostdlib -e main -Ttext 0x10200',
}
env_gpp = Environment(**env_gpp_options)
env_gpp.Append(ENV = {'PATH' : os.environ['PATH']})
object_cpp_list = Glob('*.cpp')
for object_cpp in object_cpp_list:
env_gpp.Object(object_cpp)
# Compile ASM
env_nasm = Environment(tools=['default', 'nasm'])
env_nasm.Append(ASFLAGS='-f elf32')
object_nasm_list = Glob('*.asm')
for object_nasm in object_nasm_list:
env_nasm.Object(object_nasm)
# Find all object file
object_target_list = Glob('*.o')
object_target_list.append('entry.bin')
# Linking
env_link_target = 'kernel32.elf'
env_gpp.Program(env_link_target, object_target_list)
Thank you for your attention.

OpenCV 2.4.7 build on MacOS (Maverick + Xcode 5.01 + CUDA 5.5)

I couldn't build opencv with cuda support on Mavericks:
When using cmake -G "Unix Makefiles" -DWITH_CUDA=ON ..
i got error:
-- Configuring incomplete, errors occurred!
Any workaround on this?
(Similar error when using macport too)
CMakeError.log
Determining size of off64_t failed with the following output:
Change Dir: /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp
Run Build Command:/opt/local/bin/gmake "cmTryCompileExec3929617441/fast"
/opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec3929617441.dir/build.make CMakeFiles/cmTryCompileExec3929617441.dir/build
gmake[1]: Entering directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
/opt/local/bin/cmake -E cmake_progress_report /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3929617441.dir/OFF64_T.c.o
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -o CMakeFiles/cmTryCompileExec3929617441.dir/OFF64_T.c.o -c /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:19:12: error: use of undeclared identifier 'off64_t'; did you mean 'off_t'?
('0' + ((SIZE / 10000)%10)),
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:17:22: note: expanded from macro 'SIZE'
#define SIZE (sizeof(off64_t))
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:20:12: error: use of undeclared identifier 'off64_t'; did you mean 'off_t'?
('0' + ((SIZE / 1000)%10)),
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:17:22: note: expanded from macro 'SIZE'
#define SIZE (sizeof(off64_t))
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:21:12: error: use of undeclared identifier 'off64_t'; did you mean 'off_t'?
('0' + ((SIZE / 100)%10)),
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:17:22: note: expanded from macro 'SIZE'
#define SIZE (sizeof(off64_t))
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:22:12: error: use of undeclared identifier 'off64_t'; did you mean 'off_t'?
('0' + ((SIZE / 10)%10)),
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:17:22: note: expanded from macro 'SIZE'
#define SIZE (sizeof(off64_t))
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:23:12: error: use of undeclared identifier 'off64_t'; did you mean 'off_t'?
('0' + (SIZE % 10)),
^
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:17:22: note: expanded from macro 'SIZE'
#define SIZE (sizeof(off64_t))
^
5 errors generated.
gmake[1]: *** [CMakeFiles/cmTryCompileExec3929617441.dir/OFF64_T.c.o] Error 1
gmake[1]: Leaving directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec3929617441/fast] Error 2
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CheckTypeSize/OFF64_T.c:
#include <sys/types.h>
#include <stdint.h>
#include <stddef.h>
#undef KEY
#if defined(__i386)
# define KEY '_','_','i','3','8','6'
#elif defined(__x86_64)
# define KEY '_','_','x','8','6','_','6','4'
#elif defined(__ppc__)
# define KEY '_','_','p','p','c','_','_'
#elif defined(__ppc64__)
# define KEY '_','_','p','p','c','6','4','_','_'
#endif
#define SIZE (sizeof(off64_t))
char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[',
('0' + ((SIZE / 10000)%10)),
('0' + ((SIZE / 1000)%10)),
('0' + ((SIZE / 100)%10)),
('0' + ((SIZE / 10)%10)),
('0' + (SIZE % 10)),
']',
#ifdef KEY
' ','k','e','y','[', KEY, ']',
#endif
'\0'};
#ifdef __CLASSIC_C__
int main(argc, argv) int argc; char *argv[];
#else
int main(int argc, char *argv[])
#endif
{
int require = 0;
require += info_size[argc];
(void)argv;
return require;
}
Determining if the include file io.h exists failed with the following output:
Change Dir: /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp
Run Build Command:/opt/local/bin/gmake "cmTryCompileExec647810530/fast"
/opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec647810530.dir/build.make CMakeFiles/cmTryCompileExec647810530.dir/build
gmake[1]: Entering directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
/opt/local/bin/cmake -E cmake_progress_report /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec647810530.dir/CheckIncludeFile.c.o
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -o CMakeFiles/cmTryCompileExec647810530.dir/CheckIncludeFile.c.o -c /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: 'io.h' file not found
#include <io.h>
^
1 error generated.
gmake[1]: *** [CMakeFiles/cmTryCompileExec647810530.dir/CheckIncludeFile.c.o] Error 1
gmake[1]: Leaving directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec647810530/fast] Error 2
Determining if the function jbg_newlen exists failed with the following output:
Change Dir: /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp
Run Build Command:/opt/local/bin/gmake "cmTryCompileExec4172827471/fast"
/opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec4172827471.dir/build.make CMakeFiles/cmTryCompileExec4172827471.dir/build
gmake[1]: Entering directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
/opt/local/bin/cmake -E cmake_progress_report /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec4172827471.dir/CheckFunctionExists.c.o
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -DCHECK_FUNCTION_EXISTS=jbg_newlen -O3 -DNDEBUG -o CMakeFiles/cmTryCompileExec4172827471.dir/CheckFunctionExists.c.o -c /opt/local/share/cmake-2.8/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec4172827471
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec4172827471.dir/link.txt --verbose=1
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -DCHECK_FUNCTION_EXISTS=jbg_newlen -O3 -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTryCompileExec4172827471.dir/CheckFunctionExists.c.o -o cmTryCompileExec4172827471
Undefined symbols for architecture x86_64:
"_jbg_newlen", referenced from:
_main in CheckFunctionExists.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [cmTryCompileExec4172827471] Error 1
gmake[1]: Leaving directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec4172827471/fast] Error 2
Determining if the include file linux/videodev.h exists failed with the following output:
Change Dir: /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp
Run Build Command:/opt/local/bin/gmake "cmTryCompileExec70111243/fast"
/opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec70111243.dir/build.make CMakeFiles/cmTryCompileExec70111243.dir/build
gmake[1]: Entering directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
/opt/local/bin/cmake -E cmake_progress_report /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec70111243.dir/CheckIncludeFile.c.o
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -o CMakeFiles/cmTryCompileExec70111243.dir/CheckIncludeFile.c.o -c /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: 'linux/videodev.h' file not found
#include <linux/videodev.h>
^
1 error generated.
gmake[1]: *** [CMakeFiles/cmTryCompileExec70111243.dir/CheckIncludeFile.c.o] Error 1
gmake[1]: Leaving directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec70111243/fast] Error 2
Determining if the include file linux/videodev2.h exists failed with the following output:
Change Dir: /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp
Run Build Command:/opt/local/bin/gmake "cmTryCompileExec661389614/fast"
/opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec661389614.dir/build.make CMakeFiles/cmTryCompileExec661389614.dir/build
gmake[1]: Entering directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
/opt/local/bin/cmake -E cmake_progress_report /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec661389614.dir/CheckIncludeFile.c.o
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -o CMakeFiles/cmTryCompileExec661389614.dir/CheckIncludeFile.c.o -c /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: 'linux/videodev2.h' file not found
#include <linux/videodev2.h>
^
1 error generated.
gmake[1]: *** [CMakeFiles/cmTryCompileExec661389614.dir/CheckIncludeFile.c.o] Error 1
gmake[1]: Leaving directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec661389614/fast] Error 2
Determining if the include file sys/videoio.h exists failed with the following output:
Change Dir: /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp
Run Build Command:/opt/local/bin/gmake "cmTryCompileExec741892054/fast"
/opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec741892054.dir/build.make CMakeFiles/cmTryCompileExec741892054.dir/build
gmake[1]: Entering directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
/opt/local/bin/cmake -E cmake_progress_report /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec741892054.dir/CheckIncludeFile.c.o
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -o CMakeFiles/cmTryCompileExec741892054.dir/CheckIncludeFile.c.o -c /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: 'sys/videoio.h' file not found
#include <sys/videoio.h>
^
1 error generated.
gmake[1]: *** [CMakeFiles/cmTryCompileExec741892054.dir/CheckIncludeFile.c.o] Error 1
gmake[1]: Leaving directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec741892054/fast] Error 2
Determining if the include file libavformat/avformat.h exists failed with the following output:
Change Dir: /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp
Run Build Command:/opt/local/bin/gmake "cmTryCompileExec2161613468/fast"
/opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec2161613468.dir/build.make CMakeFiles/cmTryCompileExec2161613468.dir/build
gmake[1]: Entering directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
/opt/local/bin/cmake -E cmake_progress_report /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec2161613468.dir/CheckIncludeFile.c.o
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -o CMakeFiles/cmTryCompileExec2161613468.dir/CheckIncludeFile.c.o -c /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: 'libavformat/avformat.h' file not found
#include <libavformat/avformat.h>
^
1 error generated.
gmake[1]: *** [CMakeFiles/cmTryCompileExec2161613468.dir/CheckIncludeFile.c.o] Error 1
gmake[1]: Leaving directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec2161613468/fast] Error 2
Determining if the include file ffmpeg/avformat.h exists failed with the following output:
Change Dir: /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp
Run Build Command:/opt/local/bin/gmake "cmTryCompileExec188285781/fast"
/opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec188285781.dir/build.make CMakeFiles/cmTryCompileExec188285781.dir/build
gmake[1]: Entering directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
/opt/local/bin/cmake -E cmake_progress_report /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec188285781.dir/CheckIncludeFile.c.o
/usr/bin/cc -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -o CMakeFiles/cmTryCompileExec188285781.dir/CheckIncludeFile.c.o -c /Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: 'ffmpeg/avformat.h' file not found
#include <ffmpeg/avformat.h>
^
1 error generated.
gmake[1]: *** [CMakeFiles/cmTryCompileExec188285781.dir/CheckIncludeFile.c.o] Error 1
gmake[1]: Leaving directory `/Users/caominhvu/Downloads/opencv-2.4.7/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec188285781/fast] Error 2
Here's how I compiled OpenCV 2.4.8 on OSX Mavericks 10.9.1 using Xcode 5.0.2 and CUDA 5.5:
open CMake to set the project, and to the basic configuration
in latest Xcode (I think >= 5) there's no more the gcc compiler, deprecated in favor of clang, so go to the CUDA options of the CMAKE project and change CUDA_HOST_COMPILER to use "/usr/bin/clang". Luckily CUDA 5.5 supports clang and not only gcc
Apparently CUDA 5.5 supports only the older libstdc++ library and not the more modern libc++, so update CUDA_NVCC_FLAGS to tell mvcc to pass tell the nativa compilar to use this older library. Add "-Xcompiler -stdlib=libstdc++; -Xlinker -stdlib=libstdc++"
Tell also the C++ compiler that compiles the rest of the library to use libstdc++: show the advanced options of CMAKE and go to CMAKE to add "-stdlib=libstdc++" to both CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS
For anyone coming here later who may be trying to install from this tutorial. I ran into this problem because my OPENCV_EXTRA_MODULES_PATH was pointing to the wrong directory. I had mine in ~/src/, and not just ~/

Matlab MEX slowdown without code change

I have been developing a bit of code for the last few weeks. The Code is wrapped within a MEX file in MATLAB. Until yesterday my usual test took about 1 second. Suddenly after recompiling the code without changing anything, the same code takes more than 4 seconds.
The only changes happened in a function totally unrelated to the function I am calling. It seems as all compiler optimization has vanished from one second to the other.
Maybe one of you experienced similar happenings in the past and knows how to deal with that?
Thank you for your suggestions.
Edit 1:
As I assume it is something compiler dependent, here the output of the compilation command (using verbose mode)
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2010b.app
-> CC = gcc-4.0
-> CC flags:
CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2010b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = g++-4.0
-> CXX flags:
CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB_R2010b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
FFLAGS = -fexceptions -m64 -fbackslash
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -L/Applications/MATLAB_R2010b.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = gcc-4.0
-> Link flags:
LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2010b.app/extern/lib/maci64/mexFunction.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmaci64
arguments = /usr/lib/libarmadillo.dylib /usr/lib/liblapack.dylib /usr/lib/libblas.dylib
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments = /usr/lib/libarmadillo.dylib /usr/lib/liblapack.dylib /usr/lib/libblas.dylib
----------------------------------------------------------------
-> g++-4.0 -c -I/usr/include -I/Applications/MATLAB_R2010b.app/extern/include -I/Applications/MATLAB_R2010b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -DMX_COMPAT_32 -O2 -DNDEBUG "file1.cpp"
-> g++-4.0 -c -I/usr/include -I/Applications/MATLAB_R2010b.app/extern/include -I/Applications/MATLAB_R2010b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -DMX_COMPAT_32 -O2 -DNDEBUG "file2.cpp"
-> g++-4.0 -c -I/usr/include -I/Applications/MATLAB_R2010b.app/extern/include -I/Applications/MATLAB_R2010b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -DMX_COMPAT_32 -O2 -DNDEBUG "file3.cpp"
-> gcc-4.0 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2010b.app/extern/lib/maci64/mexFunction.map -o "distanceSplinePoint.mexmaci64" file1.o file2.o file3.o /usr/lib/libarmadillo.dylib /usr/lib/liblapack.dylib /usr/lib/libblas.dylib -L/Applications/MATLAB_R2010b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
As it sometimes is with asking questions: You can spend hours searching for the answer, but once you decided to ask somebody for help you miraculously get the answer in your head.
Clearing the MATLAB-Workspace solved all my problems...
Still, thanks for reading ;)

Resources