mex file generation failed - matlab

i'm trying to generate mex file for my project. I'm always getting the following error and i don't understand it well and also how to fix it:
[11/11] /usr/bin/xcrun -sdk macosx12.1 clang build/maci64/simulation.o build/maci64/simulation_test_data.o build/maci64/rt_nonfinite.o build/maci64/simulation_test_initialize.o build/maci64/simulation_test_terminate.o build/maci64/simulation_test.o build/maci64/_coder_simulation_test_api.o build/maci64/_coder_simulation_test_mex.o build/maci64/_coder_simulation_test_info.o build/maci64/c_mexapi_version.o -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.14 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -bundle -L"/Applications/MATLAB_R2020b.app/bin/maci64" -lmx -lmex -lmat -lc++ -Wl,-rpath,#loader_path -o simulation_test_mex.mexmaci64 -lemlrt -lcovrt -lut -lmwmathutil -Wl,-exported_symbols_list,simulation_test_mex.map
FAILED: simulation_test_mex.mexmaci64
/usr/bin/xcrun -sdk macosx12.1 clang build/maci64/simulation.o build/maci64/simulation_test_data.o build/maci64/rt_nonfinite.o build/maci64/simulation_test_initialize.o build/maci64/simulation_test_terminate.o build/maci64/simulation_test.o build/maci64/_coder_simulation_test_api.o build/maci64/_coder_simulation_test_mex.o build/maci64/_coder_simulation_test_info.o build/maci64/c_mexapi_version.o -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.14 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -bundle -L"/Applications/MATLAB_R2020b.app/bin/maci64" -lmx -lmex -lmat -lc++ -Wl,-rpath,#loader_path -o simulation_test_mex.mexmaci64 -lemlrt -lcovrt -lut -lmwmathutil -Wl,-exported_symbols_list,simulation_test_mex.map
Undefined symbols for architecture x86_64:
"_speed_control_M", referenced from:
_simulate in simulation.o
"_speed_control_initialize", referenced from:
_simulate in simulation.o
"_speed_control_step", referenced from:
_simulate in simulation.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 command i used to build and generate the mex file is shown as follow:
codegen simulation_test -args {1,2} simulation.c -report
I have been looking for a solution to my problem for 2 days and don't know how to move on. I tried things from Internet without success. I will appreciate your help very much.

Related

Unable to run C++ kafka-serdes-avro-console-producer

When I try to run the console producer getting following. Looks like some type of C++ linking issue need help to debug etc.
Error Detail
/libserdes/examples/kafka-serdes-avro-console-producer.cpp:331: undefined reference to RdKafka::Producer::create(RdKafka::Conf const*, std::string&)' /remote/vgrnd104/rachana/081222/libserdes/examples/kafka-serdes-avro-console-producer.cpp:363: undefined reference to RdKafka::err2str(RdKafka::ErrorCode)’
collect2: error: ld returned 1 exit status
make: *** [kafka-serdes-avro-console-producer] Error 1
Make Detail
/libserdes/examples % make kafka-serdes-avro-console-producer
g++ -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I…/src -Wno-non-virtual-dtor --std=c++11 -I…/src -I…/src-cpp -D_GLIBCXX_USE_CXX11_ABI=0 -I…/output/include …/output/lib/libserdes.a …/output/lib/libserdes++.a …/output/lib/librdkafka++.a kafka-serdes-avro-console-producer.cpp
-o kafka-serdes-avro-console-producer …/output/lib/libserdes++.a …/output/lib/librdkafka++.a …/output/lib/libserdes.a -L…/output/lib -lrt -lpthread -lcurl -ljansson -lavrocpp -lavro -lrdkafka++ -lrdkafka

Swift compiler error at the time of compiling

Trying to compile a .swift file using the swift compiler in Ubuntu 19.10 but facing this error at the time of compilation.
$ swiftc swift.swift
/usr/bin/ld.gold: fatal error: swift: open: Is a directory
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
I have also tried it with -v parameter and it shows this:
$ swiftc -v swift.swift
Swift version 5.1 (swift-5.1.2-RELEASE)
Target: x86_64-unknown-linux-gnu
/home/takshaksh/swift/usr/bin/swift -frontend -c -primary-file swift.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name swift -o /tmp/swift-2339bd.o
/home/takshaksh/swift/usr/bin/swift-autolink-extract /tmp/swift-2339bd.o -o /tmp/swift-0db3ba.autolink
/home/takshaksh/swift/usr/bin/clang++ -fuse-ld=gold -pie -target x86_64-unknown-linux-gnu -Xlinker -rpath -Xlinker /home/takshaksh/swift/usr/lib/swift/linux /home/takshaksh/swift/usr/lib/swift/linux/x86_64/swiftrt.o /tmp/swift-2339bd.o #/tmp/swift-0db3ba.autolink -L /home/takshaksh/swift/usr/lib/swift/linux -lswiftCore --target=x86_64-unknown-linux-gnu -v -o swift
clang version 7.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/takshaksh/swift/usr/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;#m64
Selected multilib: .;#m64
"/usr/bin/ld.gold" -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o swift /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/home/takshaksh/swift/usr/lib/swift/linux -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. -L/home/takshaksh/swift/usr/bin/../lib -L/lib -L/usr/lib -rpath /home/takshaksh/swift/usr/lib/swift/linux /home/takshaksh/swift/usr/lib/swift/linux/x86_64/swiftrt.o /tmp/swift-2339bd.o -lswiftSwiftOnoneSupport -lswiftCore -lswiftCore -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld.gold: fatal error: swift: open: Is a directory
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
:0: error: link command failed with exit code 1 (use -v to see invocation)

Boost.Python Link Error with Python3 and virtualenv

I got the following error when I tried to compile .cpp file with clang++.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I set up Python and boost-python as follows.
Python
I installed Python 3.6.0 using pyenv-virtualenv (via homebrew)
Boost-Python
I used homebrew in Python 3 environment.
$ source activate py36
$ brew install boost-python --with-python3 --without-python
~/.bash_profile
My ~/.bash_profile looks like this:
export PYENV_ROOT="/usr/local/var/pyenv"
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/var/pyenv/versions/3.6.0/include/python3.6m/"
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)" ; fi
Test cpp
This is the file I tried to compile and failed (saved as test.cpp).
#define BOOST_PYTHON_STATIC_LIB
#include <boost/python.hpp>
using namespace boost::python;
char const* say(){
return "hello, world";
}
BOOST_PYTHON_MODULE( hello ){
boost::python::def( "say", say );
}
makefile
CC = clang++
INCLUDE = -I`python -c 'from distutils.sysconfig import *; print(get_python_inc())’`
BOOST = -lboost_python3.6 -lboost_serialization
FMATH = -fomit-frame-pointer -fno-operator-names -msse2 -mfpmath=sse -march=native
CFLAGS = -std=c++11 -L/usr/local/lib -O3
CFLAGS_SO = -shared -fPIC -std=c++11 -L/usr/local/lib -O3
LINK = -L/usr/local/Cellar/boost-python/1.64.0/lib/
install:
$(CC) test.cpp -o hello.so $(INCLUDE) $(BOOST) $(LINK) $(FMATH) $(CFLAGS_SO)
Error
make install returns this error.
clang++ test.cpp -o hello.so -I`python -c 'from distutils.sysconfig import *; print(get_python_inc())’` -lboost_python3.6 -lboost_serialization -L/usr/local/Cellar/boost-python/1.64.0/lib/ -fomit-frame-pointer -fno-operator-names -msse2 -mfpmath=sse -march=native -shared -fPIC -std=c++11 -L/usr/local/lib -O3 -v
/bin/sh: command substitution: line 0: unexpected EOF while looking for matching `''
/bin/sh: command substitution: line 1: syntax error: unexpected end of file
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang -cc1 version 8.1.0 (clang-802.0.42) default target x86_64-apple-darwin16.6.0
ignoring nonexistent directory "-lboost_python3.6"
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
.
/usr/local/var/pyenv/versions/3.6.0/include/python3.6m
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -dylib -arch x86_64 -macosx_version_min 10.12.0 -o hello.so -L/usr/local/Cellar/boost-python/1.64.0/lib/ -L/usr/local/lib /var/folders/rm/qv81g4ss29j_gv1b366rl2080000gp/T/test-16790a.o -lboost_serialization -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
<LINES ARE OMITTED>
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [install] Error 1

Building MongoDB with SSL RedHat fails: collect2: ld returned 1 exit status

Trying to build MongoDB with SSL on RHEL 6.4, I get the error
collect2: ld returned 1 exit status
Tried running the failed line with -v for g++ verbosity, in order to get some usefule information, but got no further information. All I get is:
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'build/linux2/ssl/mongo/mongotop' '-fPIC' '-pthread' '-rdynamic' '-L/usr/lib64' '-L/lib64' '-shared-libgcc' '-mtune=generic'
...
...
build/linux2/ssl/third_party/yaml-cpp-0.5.1/src/singledocparser.o build/linux2/ssl/third_party/yaml-cpp-0.5.1/src/stream.o build/linux2/ssl/third_party/yaml-cpp-0.5.1/src/tag.o --end-group -lpthread -lssl -lcrypto -lrt -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crtn.o
(This one last "line" fills up ~2 screens, so I omitted most of it, leaving the beginning and end of it.
Next line is just the error: collect2: ld returned 1 exit status. Nothing more.
Any idea how to figure out this error?
Figures out package boost-devel was missing.

xcodebuild not finding gcc 4.2

I am trying to run xcodebuild and I am getting the following error:
2011-12-11 04:42:22.834 xcodebuild[9155:4203] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 127 returned from shell command: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x objective-c -c /dev/null 2>&1" UserInfo=0x4001a61a0 {NSLocalizedDescription=Non-zero exit code 127 returned from shell command: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x objective-c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
2011-12-11 04:42:22.835 xcodebuild[9155:4203] Warning: Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'objective-c'.
Compiler: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2
Reason: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x objective-c -c /dev/null 2>&1
2011-12-11 04:42:22.895 xcodebuild[9155:4203] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 127 returned from shell command: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x c -c /dev/null 2>&1" UserInfo=0x4013cbb80 {NSLocalizedDescription=Non-zero exit code 127 returned from shell command: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
2011-12-11 04:42:22.900 xcodebuild[9155:4203] Warning: Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'c'.
Compiler: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2
Reason: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x c -c /dev/null 2>&1
Any idea why this is? I am guessing that it is because I don't have gcc-4.2 in the following path:
/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2
as of right now gcc-4.2 is located at usr/bin. The question is how do I redirect it?
This could be be related to your $CC variable in your shell ( it keeps track of your compiler ) you can find more information from jMoody on github
Essentially you need to remove $CC
How did you select the compiler? Go to the Xcode navigator, click on the upmost item, then in the right window on your project (not the target), then Build Settings. U and in the section Build Options you can select the compiler. Usually you can choose between LLVM gcc-4.x and some Apple LLVM x.
Have you used xcode-select to select the version of Xcode you want to use?
Manpage.