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

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

Related

mex file generation failed

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.

Why does gcc not allow undefined symbols in shared object on MSYS2?

I am trying to build Math::GSL on MSYS2 and got some problems with creating shared objects. Here is a simplified version of my problem, consider this C program sample.c:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
static void SWIG_croak_null()
{
SV *err = get_sv("#", GV_ADD);
croak("%s", SvPV_nolen(err));
}
On Ubuntu I can create a shared object sample.so like this using a run.sh shell script:
#! /bin/bash
perl_dir=$(perl -MConfig -e'print $Config{archlib}')"/CORE"
set -x
gcc -I"$perl_dir" -c -fPIC -g -o sample.o sample.c
gcc -o sample.so sample.o -shared -fPIC
The output is:
+ gcc -I/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE -c -fPIC -g -o sample.o sample.c
+ gcc -o sample.so sample.o -shared -fPIC
But if I run the same program on Windows 10 with MSYS2, perl version 5.32.0, I get this output:
+ gcc -I/usr/lib/perl5/core_perl/CORE -c -fPIC -g -o sample.o sample.c
+ gcc -o sample.so sample.o -shared -fPIC
/usr/lib/gcc/x86_64-pc-msys/9.3.0/../../../../x86_64-pc-msys/bin/ld: sample.o: in function `SWIG_croak_null':
/home/hakon/perl/test/perl_get_sv/sample.c:7: undefined reference to `Perl_get_sv'
/home/hakon/perl/test/perl_get_sv/sample.c:7:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Perl_get_sv'
/usr/lib/gcc/x86_64-pc-msys/9.3.0/../../../../x86_64-pc-msys/bin/ld: /home/hakon/perl/test/perl_get_sv/sample.c:8: undefined reference to `Perl_sv_2pv_flags'
/home/hakon/perl/test/perl_get_sv/sample.c:8:(.text+0x79): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Perl_sv_2pv_flags'
/usr/lib/gcc/x86_64-pc-msys/9.3.0/../../../../x86_64-pc-msys/bin/ld: /home/hakon/perl/test/perl_get_sv/sample.c:8: undefined reference to `Perl_croak_nocontext'
/home/hakon/perl/test/perl_get_sv/sample.c:8:(.text+0x88): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Perl_croak_nocontext'
/usr/lib/gcc/x86_64-pc-msys/9.3.0/../../../../x86_64-pc-msys/bin/ld: sample.o:sample.c:(.rdata$.refptr.PL_thr_key[.refptr.PL_thr_key]+0x0): undefined reference to `PL_thr_key'
collect2: error: ld returned 1 exit status
However, if I explicitly link with libperl.dll.a it works fine:
gcc -o sample.so sample.o -shared -L"$perl_dir" -lperl
Why is it not possible to create a shared object with undefined symbols in MSYS2?
According to this page:
Because of the explicit nature of the table of imported symbols, it is
not possible to leave a symbol in a PE DLL undefined at link time, to
be satisfied at runtime, as it is instead possible with most UNIX
shared objects.

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

Unable to compile / install Orange Data Mining on Raspberry Pi

I have been trying to compile and install Orange 2.7.8 on Raspberry Pi 2 but was unsuccessful. I tried compiling by hand and also used pip install orange as per suggestion from: How can I install python-Orange on ubuntu 12.10
The first warning I got this:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -I/usr/lib/pymodules/python2.7/numpy/core/include -Isource/include -Isource/orange/liblinear -Isource/orange/ppp -Isource/orange/px -I/usr/include/python2.7 -c source/orange/basstat.cpp -o build/temp.linux-armv7l-2.7/source/orange/basstat.o -fPIC -w -DLINUX -DORANGE_EXPORTS
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
But it kept going without an error. Then when it started compiling with g++, it started getting an error on multiple definition of TOrangeVector. There are many errors like the lines below:
build/temp.linux-armv7l-2.7/source/orange/distance.o:(.data.rel.ro+0x6c): multiple definition of `typeinfo for TOrangeVector<GCPtr<TVariable>, true>'
build/temp.linux-armv7l-2.7/source/orange/basstat.o:(.data.rel.ro+0x6c): first defined here
build/temp.linux-armv7l-2.7/source/orange/distance.o: In function `TExamplesDistance::classDescription() const':
/home/pi/build/orange/source/orange/ppp/distance.ppp:17: multiple definition of `typeinfo for TOrangeVector<bool, false>'
In the end it got kicked out:
/home/pi/build/orange/source/orange/vectortemplates.hpp:1075: multiple definition of `typeinfo name for TOrangeVector<GCPtr<TOrangeVector<GCPtr<TVariable>, true> >, true>'
build/temp.linux-armv7l-2.7/source/orange/basstat.o:/home/pi/build/orange/source/orange/ppp/../basstat.hpp:8: first defined here
collect2: ld returned 1 exit status
error: command 'g++' failed with exit status 1
Any guide on how to tweak this to make it compiled would be appreciated.

scipy install via macports fail after selfupdate

I am having some trouble getting py27-scipy to build & install after upgrading to the latest version of macports (MacPorts base version 2.0.3 installed).
The exact build error is:-
:info:build In file included from scipy/integrate/_quadpackmodule.c:6:
:info:build scipy/integrate/__quadpack.h:54: warning: function declaration isn't a prototype
:info:build scipy/integrate/__quadpack.h:55: warning: function declaration isn't a prototype
:info:build scipy/integrate/__quadpack.h:56: warning: function declaration isn't a prototype
:info:build scipy/integrate/__quadpack.h:57: warning: function declaration isn't a prototype
:info:build scipy/integrate/__quadpack.h:58: warning: function declaration isn't a prototype
:info:build scipy/integrate/__quadpack.h:59: warning: function declaration isn't a prototype
:info:build scipy/integrate/__quadpack.h:60: warning: function declaration isn't a prototype
:info:build scipy/integrate/__quadpack.h: In function 'quad_function':
:info:build scipy/integrate/__quadpack.h:74: warning: unused variable 'nb'
:info:build scipy/integrate/_quadpackmodule.c: At top level:
:info:build /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/npy_3kcompat.h:391: warning: 'simple_capsule_dtor' defined but not used
:info:build /opt/local/bin/gfortran-mp-4.4 -Wall -Wall -undefined dynamic_lookup -bundle build/temp.macosx-10.6-x86_64-2.7/scipy/integrate/_quadpackmodule.o -L/opt/local/lib/gcc44/gcc/x86_64-apple-darwin10/4.4.6 -Lbuild/temp.macosx-10.6-x86_64-2.7 -lquadpack -llinpack_lite -lmach -lgfortran -o build/lib.macosx-10.6-x86_64-2.7/scipy/integrate/_quadpack.so
:info:build building 'scipy.integrate._odepack' extension
:info:build compiling C sources
:info:build C compiler: /opt/local/bin/gcc-mp-4.4 -fno-strict-aliasing -fno-common -dynamic -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
:info:build
:info:build compile options: '-DNO_ATLAS_INFO=3 -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c'
:info:build extra options: '-faltivec -I/System/Library/Frameworks/vecLib.framework/Headers'
:info:build gcc-mp-4.4: scipy/integrate/_odepackmodule.c
:info:build cc1: error: unrecognized command line option "-faltivec"
:info:build cc1: error: unrecognized command line option "-faltivec"
:info:build error: Command "/opt/local/bin/gcc-mp-4.4 -fno-strict-aliasing -fno-common -dynamic -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DNO_ATLAS_INFO=3 -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c scipy/integrate/_odepackmodule.c -o build/temp.macosx-10.6-x86_64-2.7/scipy/integrate/_odepackmodule.o -faltivec -I/System/Library/Frameworks/vecLib.framework/Headers" failed with exit status 1
:info:build shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-scipy/py27-scipy/work/scipy-0.9.0" && /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 setup.py --no-user-cfg config_fc --fcompiler gnu95 --f77exec /opt/local/bin/gfortran-mp-4.4 --f90exec /opt/local/bin/gfortran-mp-4.4 config --cc /opt/local/bin/gcc-mp-4.4 --include-dirs /opt/local/include --library-dirs /opt/local/lib build " returned error 1
:error:build Target org.macports.build returned: shell command failed (see log for details)
:debug:build Backtrace: shell command failed (see log for details)
while executing
"command_exec build"
(procedure "portbuild::build_main" line 8)
invoked from within
"$procedure $targetname"
:info:build Warning: the following items did not execute (for py27-scipy): org.macports.activate org.macports.build org.macports.destroot org.macports.install
:notice:build Log for py27-scipy is at: /opt/local/var/macports
/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-scipy/py27-scipy/main.log
Any suggestions to point me in the right direction?
I had exactly the same issue. In my case it was caused by an old dev build of numpy on my systems that was confusing the build process. Removing the referenced .egg entirely worked for me. See the MacPorts ticket:
https://trac.macports.org/ticket/31833
This problem was a result of gfortran/gcc44 not compiling properly because I was using Lion/XCode 4.2.
Reference macports ticket that was resolved - https://trac.macports.org/ticket/31604