I have build the paho mqtt c and c++ with the following commands,
$ git clone https://github.com/eclipse/paho.mqtt.c.git
$ cd paho.mqtt.c
$ git checkout v1.3.1
$ cmake -Bbuild -H. -DPAHO_WITH_SSL=ON -DPAHO_ENABLE_TESTING=OFF
$ sudo cmake --build build/ --target install
$ sudo ldconfig
$ git clone https://github.com/eclipse/paho.mqtt.cpp
$ cd paho.mqtt.cpp
$ cmake -Bbuild -H. -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE
$ sudo cmake --build build/ --target install
$ sudo ldconfig
Now, When I include the paho headers to establish client connection in my target file, it says undefined reference to 'MQTTCLient_create'
g++ \
-m64 -Wno-write-strings \
-Iinclude \
speedway_embedded_example.cpp -lpaho-mqtt3c\
-Llib -lltkcpp_x86_64 -lltkcppimpinj_x86_64 -lxml2_x86_64 \
-L/usr/bin -ldl -lssl -lcrypto \
-o bin/speedwayr_x86_64
I have included the paho headers in my application as,
extern "C"{
#include <MQTTClient.h>
#include <MQTTClientPersistence.h>
}
Can anyone please help me to overcome this issue?
Related
When installing i386-elf-gcc using aur. Install goes smoothly and no errors when I build. I added /usr/local/i386elfgcc/bin to my path and I am able to run the command. When I run a simple command such as i386-elf-gcc -g "kernel.cpp" -o "kernel.o", I am getting errors:
/usr/local/i386elfgcc/lib/gcc/i386-elf/10.2.0/../../../../i386-elf/bin/ld: cannot find crt0.o: No such file or directory
/usr/local/i386elfgcc/lib/gcc/i386-elf/10.2.0/../../../../i386-elf/bin/ld: cannot find -lg
/usr/local/i386elfgcc/lib/gcc/i386-elf/10.2.0/../../../../i386-elf/bin/ld: cannot find -lc
Reinstalling has not worked. What can I do to fix this? I am using Arch.
The original command was i386-elf-gcc -ffreestanding -m32 -g "kernel.cpp" -o "kernel.o"
I needed to add -nostdlib
Final command:
i386-elf-gcc -nostdlib -ffreestanding -m32 -g "kernel.cpp" -o "kernel.o"
I'm trying to install rJava on MacOS Sierra. Have to tried the tips and guides elsewhere for other other version MacOS such as https://github.com/snowflakedb/dplyr-snowflakedb/wiki/Configuring-R-rJava-RJDBC-on-Mac-OS-X
and Install xlsx and rJava on Mac
but it does not work out. Much appreciate any help. Thanks.
My Mac version: macOS Sierra, version 10.12.15
My R version: 3.4.0 (2017-04-21)
My Rstudio version: Version 0.99.903
Java version:
bash-3.2$ /usr/libexec/java_home -V
bash-3.2$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
bash-3.2$ R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_131
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Non-system Java on macOS
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -fPIC -Wall -g -O2 -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /Library/Frameworks/R.framework/Resources
override rw-r--r-- root/admin for /Library/Frameworks/R.framework/Resources/etc/Makeconf? (y/n [n]) n
not overwritten
override rw-r--r-- root/admin for /Library/Frameworks/R.framework/Resources/etc/ldpaths? (y/n [n]) n
not overwritten
Done.
When I tried to install rJava, I ran
`R --quiet -e 'install.packages("rJava", type="source", repos="http://cran.us.r-project.org")`
I got the errors:
clang: error: unsupported option '-fopenmp'
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
The downloaded source packages are in
‘/private/var/folders/w8/ksbj8dh15bz2lkss7h2tpzk80000gn/T/Rtmp6r9HI0/downloaded_packages’
Warning message:
In install.packages("rJava", type = "source", repos = "http://cran.us.r-project.org") :
installation of package ‘rJava’ had non-zero exit status
I ran:
"curl -#ROL https://www.rforge.net/rJava/snapshot/rJava_0.9-8.tar.gz
R CMD INSTALL rJava_0.9-8.tar.gz"
and got the following error messages:
clang: error: unsupported option '-fopenmp'
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
I dont know what to do. Thanks for your help.
This article here solved this fopenmp issue for me on macOS Sierra 10.12.4. I outlined the solution here but also below. The problem is that forenmp option is not supported in macOS gcc so we have to compile a new version of the gcc.
Solution to forenmp problem
I have tested this with Homerew's r-app brew cask install r-app and Oracle's JDK. Then I did the following
brew install homebrew/versions/gcc49 --without-multilib #Long ~70min compiling...
sudo chown -R $(whoami):admin /usr/local
brew link --overwrite --force gcc49
brew unlink gcc49 && brew link gcc49
brew install llvm
mkdir ~/.R; touch ~/.R/Makevars
echo "VER=-4.9
CC=gcc$(VER)
CXX=g++$(VER)
CXX1X=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/4.9.3/lib/gcc/4.9" > ~/.R/Makevars
and now
sudo R CMD javareconf
Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
and now rJava is working!
Comments using OSX 10.12.6 with Java 1.8.0_181 and dealing with the above issue and another issue related to compiling rJava.
First:
Install rJava with these commands:
wget https://cran.r-project.org/src/contrib/rJava_0.9-10.tar.gz
tar xvfz rJava_0.9-10.tar.gz
cd rJava
R CMD INSTALL rJava
Why use R CMD INSTALL? This will keep the config.log file that will allow you to debug things; install.packages() does not and help you get might not be very helpful in that case (e.g. https://github.com/s-u/rJava/issues/111).
Second:
Make sure you run the following, if you've updated Java (remember you need the JDK, not JRE).
sudo R CMD javareconf
Error (checking JNI data types):
To fix this error:
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
do this:
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
sudo ln -f -s /usr/local/lib/libjvm.dylib /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/
Error (unsupported option '-fopenmp):
To fix this error:
clang: error: unsupported option '-fopenmp
do the following:
Note: The instructions may need to be modified for newer versions of gcc, but make sure you get a version greater than 7 (see notes that follow); the following command can be used to find out the available versions:
brew search gcc
Then install gcc:
brew install gcc#7
sudo chown -R $(whoami):admin /usr/local
brew link --overwrite --force gcc#7
brew unlink gcc#7 && brew link gcc#7
brew install llvm
mkdir -p ~/.R
## Check the versions and folder in FLIBS match what you install
echo "CC=gcc-7
CXX=g++-7
CXX1X=g++-7
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc\#7/7.3.0/lib/gcc/7" > ~/.R/Makevars
Notes: You need any version of gcc greater than 7; the without-multilib flag mentioned in the earlier answer may not be available, but it is important. Why the without-multilib flag?: https://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/ and OpenMP/gcc on macOS : gcc --without-multilib not available
Then install rJava
R CMD INSTALL rJava
Finally, test library (you should see your Java version):
library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
Take a look here:
http://www.owsiak.org/?p=3671
You can find quite detailed description of how to deal with rJava in macOS.
Make sure to install JDK that is provided by Oracle before you proceed.
When I try to compile GCC 4.8.0 as a part of a greater system, in a custom directory. I have no sudo rights on this server and therefore I'm building everything from source. However, I can't get the dependencies gmp, mpfr and mpc to work. When running configure it gives me:
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations.
config.log gives me:
configure:5619: checking for the correct version of the gmp/mpfr/mpc libraries
configure:5650: gcc -o conftest -g -O2 -Wno-error=unused-value -I$SRC/gmp/ -I$SRC/mpc/src/.libs -lmpc -lmpfr -lgmp >&5
/usr/bin/ld: cannot find -lmpc
collect2: ld returned 1 exit status
So I tried to get mpfr, gmp and mpc and build it manually from source, as I have no rights to install on the system itself. I ran ./contrib/download_prerequisites to get the libraries. I ran configure again, it gave me the same error. So I also compiled them and in my gcc dir I did:
cd mpfr; ./configure; make
cd ../gmp; ./configure; make
cd ../mpc; ./configure --with-mpfr-include=$SRC/mpfr --with-mpfr-lib=$SRC/mpfr/.libs/ --with-gmp=$SRC/gmp; make; cd ..
Note that just using --with-mpfr did not work for some reason.
cd $SRC/build
../configure \
--build=x86_64-linux-gnu \
CC=gcc \
CFLAGS='-g -O2 -Wno-error=unused-value' \
--disable-bootstrap --enable-checking=none \
--disable-multi-arch --disable-multilib \
--enable-languages=c,c++ \
--with-gmp-lib=$SRC/gmp/.libs \
--with-gmp-include=$SRC/gmp/ \
--with-mpc-include=$SRC/mpc/src \
--with-mpc=$SRC/mpc \
--with-mpfr-lib=$SRC/mpfr/.libs \
--with-mpfr-include=$SRC/mpfr \
--prefix=$SRC/prefix
where $SRC is my gcc directory. However, at the last command it gave me this error in the build/config.log:
gcc -o conftest -g -O2 -Wno-error=unused-value -I$SRC/gmp/ -I$SRC/mpfr -I$SRC/mpc/src conftest.c -L$SRC/gmp/.libs -L$SRC/mpfr/.libs -L$SRC/mpc/lib -lmpc -lmpfr -lgmp >&5
/usr/bin/ld: cannot find -lmpc
collect2: ld returned 1 exit status
It is obvious that after running make mpc does not have a lib directory, or anything containing shared object files. So I do not know how I have to link gcc with the mpc library.
Does anyone know what I should do?
This is my compile command
gcc msg_utils.o -o mtm -lm -L/openssl-1.0.0a -lssl -lcrypto
I get error :
/usr/bin/ld: cannot find -lssl
Please tell me what wrong with my command ,the path to openssl is correct ,I get openssl source from :
https://www.openssl.org/source/openssl-1.0.0a.tar.gz
(I guess you are on Linux)
You should probably install some OpenSSL package in your Linux distribution.
Perhaps aptitude install libssl-dev on Debian related distributions.
If you compile OpenSSL from source code, you probably need some make install step and you might need to run ldconfig after that.
You might want to use pkg-config during compilation of your code:
gcc -Wall -g $(pkg-config -cflags openssl) \
msg_utils.o -o mtm \
$(pkg-config -libs openssl)
See also this and that
When I try to install vowpal wabbit on CentOS (vmware image) I keep getting this error :
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-unused-local-typedef" [enabled by default]
make[1]: *** [lda_core.lo] Error 1
make[1]: Leaving directory `/home/tom/vowpal_wabbit/vowpalwabbit'
make: *** [install-recursive] Error 1
full error info :
Making install in vowpalwabbit
make[1]: Entering directory `/home/tom/vowpal_wabbit/vowpalwabbit'
depbase=`echo lda_core.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I/usr/include -I/include -Wall -Wno-unused-local-typedef -pedantic -ffast-math -O3 -fomit-frame-pointer -fno-strict-aliasing -DNDEBUG -std=gnu++11 -MT lda_core.lo -MD -MP -MF $depbase.Tpo -c -o lda_core.lo lda_core.cc &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I/usr/include -I/include -Wall -Wno-unused-local-typedef -pedantic -ffast-math -O3 -fomit-frame-pointer -fno-strict-aliasing -DNDEBUG -std=gnu++11 -MT lda_core.lo -MD -MP -MF .deps/lda_core.Tpo -c lda_core.cc -fPIC -DPIC -o .libs/lda_core.o
lda_core.cc: In function ‘T ldamath::lgamma(T)’:
lda_core.cc:361:94: error: there are no arguments to ‘BOOST_STATIC_ASSERT_MSG’ that depend on a template parameter, so a declaration of ‘BOOST_STATIC_ASSERT_MSG’ must be available [-fpermissive]
BOOST_STATIC_ASSERT_MSG(true, "ldamath::lgamma is not defined for this type and math mode.");
^
lda_core.cc:361:94: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
lda_core.cc: In function ‘T ldamath::digamma(T)’:
lda_core.cc:367:95: error: there are no arguments to ‘BOOST_STATIC_ASSERT_MSG’ that depend on a template parameter, so a declaration of ‘BOOST_STATIC_ASSERT_MSG’ must be available [-fpermissive]
BOOST_STATIC_ASSERT_MSG(true, "ldamath::digamma is not defined for this type and math mode.");
^
lda_core.cc: In function ‘T ldamath::exponential(T)’:
lda_core.cc:373:99: error: there are no arguments to ‘BOOST_STATIC_ASSERT_MSG’ that depend on a template parameter, so a declaration of ‘BOOST_STATIC_ASSERT_MSG’ must be available [-fpermissive]
BOOST_STATIC_ASSERT_MSG(true, "ldamath::exponential is not defined for this type and math mode.");
^
lda_core.cc: In function ‘T ldamath::powf(T, T)’:
lda_core.cc:379:92: error: there are no arguments to ‘BOOST_STATIC_ASSERT_MSG’ that depend on a template parameter, so a declaration of ‘BOOST_STATIC_ASSERT_MSG’ must be available [-fpermissive]
BOOST_STATIC_ASSERT_MSG(true, "ldamath::powf is not defined for this type and math mode.");
^
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-unused-local-typedef" [enabled by default]
make[1]: *** [lda_core.lo] Error 1
make[1]: Leaving directory `/home/tom/vowpal_wabbit/vowpalwabbit'
make: *** [install-recursive] Error 1
Please help. How can I solve it? I already have "g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)" version.
This is linking issue between files please run following commands
Testing run
# yum install devtoolset-2-gcc-4.8.2 devtoolset-2-gcc-c++-4.8.2
# /opt/rh/devtoolset-2/root/usr/bin/gcc --version
export
ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/
hash -r
gcc --version
for more info : http://www.computerhope.com/unix/uln.htm
This is what I do on CentOs 6.8 before running pip install vowpalwabbit both to conda or to main python distribution which builds native part and a python egg. Contains commented lines for a case of building a docker image. Pretty sure the same should help with just building the vowpal-wabbit library.
The original problem with BOOST_STATIC_ASSERT_MSG is being fixed by installing boost-devel:1.59.
yum -y install wget make python-devel zlib-devel
# Boost 1.59 required for vowpal wabbit, Boost 1.41 is going with CentOs 6.8 image and repo
wget http://repo.enetres.net/enetres.repo -O /etc/yum.repos.d/enetres.repo
yum -y install boost-devel
# This step is done for the original author, but will be needed if you didn't install updated gcc/g++ yet.
# GCC and G++ 4.8.2 for vowpal wabbit build, 4.4.x is going with CentOs 6.8 image by default.
# Don't go with too new gcc versions like gcc 5.x, it will not work
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum -y install devtoolset-2-gcc devtoolset-2-gcc-c++ devtoolset-2-binutils devtoolset-2-runtime devtoolset-2-libstdc++-devel
scl enable devtoolset-2 bash
# Set PATH, because "scl enable" does not have any effects inside "docker build"
#-docker- PATH /opt/rh/devtoolset-2/root/usr/bin:$PATH
# Set CC, CXX, LD variables for make, because "scl enable" does not have any effects inside "docker build"
#-docker- ENV CC /opt/rh/devtoolset-2/root/usr/bin/gcc
#-docker- ENV CXX /opt/rh/devtoolset-2/root/usr/bin/g++
#-docker- ENV LD /opt/rh/devtoolset-2/root/usr/bin/ld
# Python 2.7 for vowpal wabbit, CentOs 6.8 comes with python 2.6
# --enable-shared flag is important for the vowpal wabbit build
cd /opt &&\
wget --no-check-certificate https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz &&\
tar xf Python-2.7.6.tar.xz &&\
cd Python-2.7.6 &&\
./configure --enable-shared --prefix=/usr/local &&\
make && make altinstall
ln -s /usr/local/bin/python2.7 /usr/bin/python2.7
echo "/usr/local/lib/python2.7" > /etc/ld.so.conf.d/python27.conf
echo "/usr/local/lib" >> /etc/ld.so.conf.d/python27.conf
ldconfig
After this steps pip install vowpalwabbit or make for the original native library should work.
Related discussion in vowpal-wabbit issues tracker.