thrift programming problem - sockets

hi
i just start programming with thrift api . i run a sample code but i dont know how to run thrift program. i just did following :
code;
{#!/usr/local/bin/thrift --gen cpp
namespace cpp Test
service Something {
i32 ping()
}
than run command
thrift --gen cpp your_thrift_file.thrift
it generate seven file in a folder name gen-cpp which are following:
Something.cpp
Something.h
Something_server.skeleton.cpp
your_thrift_file_constants.cpp
your_thrift_file_constants.h
your_thrift_file_types.cpp
your_thrift_file_types.h
now i compile them all together to get executable by following command
g++ -Wall -I/usr/local/include/thrift -c Something.cpp -o something.o
g++ -Wall -I/usr/local/include/thrift -c Something_server.cpp -o server.o
g++ -Wall -I/usr/local/include/thrift -c your_thrift_file_constants.cpp -o constants.o
g++ -Wall -I/usr/local/include/thrift -c your_thrift_file_types.cpp -o types.o
than i write a client code which is following
{ #include "Something.h" // As an example
#include <transport/TSocket.h>
#include <transport/TBufferTransports.h>
#include <protocol/TBinaryProtocol.h>
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace Test;
int main(int argc, char **argv) {
boost::shared_ptr<TSocket> socket(new TSocket("localhost", 9090));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
SomethingClient client(protocol);
transport->open();
client.ping();
transport->close();
return 0;
}
now than i compile it with command
g++ -Wall -I/usr/local/include/thrift -c something_client.cpp -o client.o
and than make the executable by following command
g++ -L/usr/local/lib -lthrift client.o Something.o constants.o types.o -o Something_client
But when i run it it shows following error
command: ./Somthing_client
result:Thrift: Fri May 20 10:49:17 2011 TSocket::open() connect() Connection refused
terminate called after throwing an instance of 'apache::thrift::transport::TTransportException'
what(): connect() failed: Connection refused
Aborted
now i don't understand what I'm doing wrong?
can anybody explain me thrift working ?
how to run this code properly ?
what is this code doing ?

Is your Thrift server running too? The client needs something to connect to. The error looks like there's no open socket on port 9090 (set in your code).

Related

SFML: Unable to run code because of soundbuffer error

I came across a problem that wouldn't let me play sounds on SFML. Whenever I call the sf::SoundBuffer buffer; object, the code would break and spit out an error.
I either think its a problem inside the makefile. Other than that, I'm completely lost in what to do
Sample of makefile:
all: compile link
compile:
g++ -I src/include -c main.cpp
link:
g++ main.o -o Sorter -L src/lib -l sfml-audio -l sfml-graphics -l sfml-window -l sfml-system
Picture of the error

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.

Issue with net-snmp build on Solaris 11

I am building net-snmp 5.7.3 on Solaris11 sparc. I am having my path set as:
/usr/local/lib:/bin:/usr/bin:/usr/dev_infra/platform/bin:/usr/dev_infra/generic/bin:/usr/local/bin:/usr/X11R6/bin:/usr/local/ade/bin:/usr/sfw/bin:/usr/ccs/bin:/opt/csw/bin:/opt/csw/gnu:/usr/sbin:/usr/bin:/usr/ccs/bin/ar
I run ./configure --prefix=/opt with default option and it was successful. After that when i do make, i am getting below error message, Any help is appreciated.
libtool: compile: gcc -I../include -I. -I../snmplib -fno-strict-aliasing -g -O2 -Usolaris2 -Dsolaris2=solaris2 -c keytools.c -fPIC -DPIC -o .libs/keytools.o
keytools.c: In function ‘generate_Ku’:
keytools.c:153:9: warning: assignment makes pointer from integer without a cast
keytools.c:161:9: error: invalid use of void expression
keytools.c:166:13: error: invalid use of void expression
*** Error code 1
make: Fatal error: Command failed for target `keytools.lo'
Current working directory /scratch/kkumsati/net-snmp/snmplib
*** Error code 1
The following command caused the error:
if test "snmplib agent apps man local mibs" != ""; then \
it="snmplib agent apps man local mibs" ; \
for i in $it ; do \
echo "making all in `pwd`/$i"; \
( cd $i ; make ) ; \
if test $? != 0 ; then \
exit 1 ; \
fi \
done \
fi
make: Fatal error: Command failed for target `subdirs'
Look for README.solaris file in source folder. It has 'Compiling net-snmp' section.
In README you could find the following:
You need to set your $PATH. This is extremely important
because otherwise there may be conflicts between the various
components of the development environment.
Wrong PATH is your problem.
The other possible problem are old openssl headers in your system.
You have an error about function EVP_MD_CTX_create() (error in keytools.c:153:9), this function is declared in Solaris file /usr/include/openssl/evp.h, this file is included in package pkg:/library/security/openssl. Version of this package on my OS is 1.0.1.18-0.175.3.5.0.5.0.
I recommend you to update OS, or package pkg:/library/security/openssl or try to run configure script with --with-openssl=internal option.
Also update gcc, I used this version
pkg install developer/gcc-48
export PATH=/usr/sbin:/usr/local/bin:/usr/ccs/bin:/usr/bin:
./configure --prefix=/opt --with-mib-modules="ucd-snmp/lmSensors \
ucd-snmp/diskio smux mibII/mta_sendmail" --with-cc=gcc
gmake
Here I received an error about:
/usr/include/sys/processor.h:188:45: error: unknown type name 'kthread_t'
extern boolean_t i_processor_affinity_check(kthread_t *, struct cpu *);
^
/usr/include/sys/processor.h:189:37: error: unknown type name 'kthread_t'
extern int i_processor_affinity_one(kthread_t *, id_t, boolean_t);
^
/usr/include/sys/processor.h:190:33: error: unknown type name 'kthread_t'
extern int i_processor_affinity(kthread_t *, uint_t *, id_t *, uint32_t *,
^
To solve this edit file agent/mibgroup/host/data_access/swrun_procfs_psinfo.c and add to its header at 26 line (before problem line):
#include <sys/processor.h>
#include <sys/procset.h>
#include <thread.h>
Link about this bug
then repeat
gmake
gmake test
gmake install; #this command with root permissons
I succeed on SPARC.

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.