Boost on eclipse on windows - eclipse

I am using eclipse luna on win 7.
Here is my program.
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
int main(int argc, char* argv[]){
// All programs that use asio need to have at least one io_service object
boost::asio::io_service io;
// sets the timer to expire 5 seconds from now
boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
t.wait();
std::cout << "Hello, world!\n";
return 0;
}
Here is my command line code
g++ -I"C:\Users\Documents\Lib\boost_1_57_0\boost_1_57_0" -O0 -g3 -Wall -c -fmessage-length=0 -lboost_filesystem -lboost_system -lboost_libraryname -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Invoking: Cross G++ Linker
g++ -o "002_TimerSynchronously" ./main.o
Error
C:/Users/SulfredLee/Documents/Lib/boost_1_57_0/boost_1_57_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
C:/Users/SulfredLee/Documents/Lib/boost_1_57_0/boost_1_57_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
C:/Users/SulfredLee/Documents/Lib/boost_1_57_0/boost_1_57_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
Anyone knows how to fix it?
Thank you very much
Reference:
undefined reference to boost::system::system_category() when compiling
How do I troubleshoot boost library/header inclusion via autoconf/automake?

The libraries should be present in the second command line when the linking takes place. Please be also careful and list the libraries after the object file.

Related

Need some help in Fuzzing Mosquitto lib

Here comes a bug while fuzzing Mosquitto lib, I would like to know the solution.
Step1. compile the lib
#:~/fuzz/fuzzmqtt/mosquitto$ ls
about.html doc Makefile security
aclfile.example docker man SECURITY.md
appveyor.yml edl-v10 misc service
buildtest.py epl-v10 mosquitto.conf set-version.sh
ChangeLog.txt examples Mosquitto.podspec snap
client installer notice.html src
CMakeLists.txt lib pskfile.example test
compiling.txt libmosquitto.pc.in pwfile.example THANKS.txt
config.h libmosquittopp.pc.in readme.md travis-configure.sh
config.mk LICENSE.txt readme-tests.md travis-install.sh
CONTRIBUTING.md logo readme-windows.txt www
#:~/fuzz/fuzzmqtt/mosquitto$ sudo make install CC="clang -O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-gep,trace-div" -j2
Step2. compile the fuzzer
#:~/fuzz/fuzzmqtt/mosquitto/lib$ clang -g -O1 -fsanitize=fuzzer,address mos_fuzzer.cc -o mos_fuzzer -lmosquitto
Step3. Run the fuzzer and got the bug
#~/fuzz/fuzzmqtt/mosquitto/lib$ ./mos_fuzzer
INFO: Seed: 106983829
INFO: Loaded 1 modules (2337 guards): 2337 [0x7f157cd816b0, 0x7f157cd83b34),
INFO: Loaded 1 modules (1 inline 8-bit counters): 1 [0x787f80, 0x787f81),
INFO: Loaded 1 PC tables (1 PCs): 1 [0x565af8,0x565b08),
ERROR: The size of coverage PC tables does not match the
number of instrumented PCs. This might be a compiler bug,
please contact the libFuzzer developers.
Also check https://bugs.llvm.org/show_bug.cgi?id=34636
for possible workarounds (tl;dr: don't use the old GNU ld)
The code is as follow
#include "stdio.h"
#include "mosquitto.h"
#include "assert.h"
#include "stdint.h"
#include "stddef.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
bool clean_session = true;
struct mosquitto *mosq = NULL;
mosquitto_lib_init();
void *data_1=(void *)data;
mosq = mosquitto_new(NULL, clean_session, data_1);
mosquitto_destroy(mosq);
mosquitto_lib_cleanup();
return 0;
}
Thank you

Error including Kernel Header files in C, compiled using clang

I am writing an eBPF Code.
I need to use the function bpf_obj_pin, declared in kernel files:
tools/lib/bpf/bpf.c
tools/lib/bpf/bpf.h
Refer from here: https://elixir.bootlin.com/linux/latest/ident/bpf_obj_pin
So from the same files, I found out that I had to include this in my header.
#include <bpf/bpf.h>
But I get the following ERROR:
clang -O2 -target bpf -I/usr/include/x86_64-linux-gnu -c bpf1.c -o bpf1.o
bpf1.c:10:10: fatal error: 'bpf/bpf.h' file not found
#include <bpf/bpf.h>
^~~~~~~~~~~
1 error generated.
makefile:21: recipe for target 'bpf1.o' failed
make: *** [bpf1.o] Error 1
This is somewhat similar but doesn't solve my problem.

cuDNN code sample compile error

I'm trying to install NVIDIA's cuDNN library and run their code sample, but it's giving me these errors and I don't know what is wrong.
make all
Building target: cuDNNtest
Invoking: NVCC Linker
/usr/local/cuda-7.5/bin/nvcc --cudart static -L/usr/local/cuda-7.5/lib64 -L/usr/local/cuda-7.5/targets/x86_64-linux/lib/ -L".../cuda-workspace/cuDNNtest/FreeImage/lib/linux/x86_64" -L/usr/lib -L/usr/local/cuda/lib64 --relocatable-device-code=true -gencode arch=compute_52,code=compute_52 -gencode arch=compute_52,code=sm_52 -link -o "cuDNNtest" ./fp16_dev.o ./fp16_emu.o ./mnistCUDNN.o ./UtilNPP/StopWatchLinux.o -lcudnn -lFreeImage -lcublas
./mnistCUDNN.o: In function `npp::ImageAllocator<unsigned char, 1ul>::Malloc2D(unsigned int, unsigned int, unsigned int*, bool)':
.../cuda-workspace/cuDNNtest/UtilNPP/ImageAllocatorsNPP.h:76: undefined reference to `nppiMalloc_8u_C1'
./mnistCUDNN.o: In function `npp::ImageAllocator<unsigned char, 1ul>::Free2D(unsigned char*)':
.../cuda-workspace/cuDNNtest/UtilNPP/ImageAllocatorsNPP.h:87: undefined reference to `nppiFree'
collect2: ld returned 1 exit status
make: *** [cuDNNtest] Error 1
I'm using Nsight Eclipse Edition on Linux centOS, cuda toolkit 7.5 and Titan X (compute capability 5.2, I think).
Thank you in advance.
I solved this adding -lnppi to the libraries list in the project's properties.

MEX cuda code with dynamic parallelism - unable to compile

I have a code by name mexCodeCuda.cu which uses dynamic parallelism. In the matlab interface, when I try to execute the following commands, I get the following error :
system('nvcc --compile mexCodeCuda.cu -o mexCodeCuda.o --compiler-options -fPIC -m64 -rdc=true -gencode arch=compute_35,code=sm_35 -O3 -lineinfo -use_fast_math -lcudadevrt -I/cm/shared/apps/MATLAB/extern/include')
system('nvcc -arch=sm_35 -dlink mexCodeCuda.o -o dlink.o')
eval('mex mexCodeCuda.o dlink.o -L'CUDA_LIB_PATH '-lcudart')
It gives the following error :
Error using mex
/usr/bin/ld: dlink.o: relocation R_X86_64_32S against `__nv_module_id' can
not be used when making a shared object; recompile with -fPIC
dlink.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
Can anyone help me ?
Thanks in advance...
A few changes:
Add -fPIC to the second nvcc command (using --compiler-options, just as you did with the first nvcc).
Specify the cudadevrt runtime option on the mex command (-lcudadevrt), just as you have with the first nvcc call.
And you may need to add -fPIC to the mex linking via LDCXXFLAGS or LDFLAGS. Not sure.

Eclipse/C++ Configuration Issue

I am trying to configure Eclipse/Helios on a Win7/64 Professional with CDT and MinGW. When I try and compile:
#include <iostream>
using namespace std ;
int main() {
cout << "What a lovely day\n" ;
return(0) ;
}
I get the output/error:
make all
Building file: ../SeeProgram.cpp
Invoking: Cross G++ Compiler
C:\Tools\MinGW\bin\g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"SeeProgram.d" -MT"SeeProgram.d" -o"SeeProgram.o" "../SeeProgram.cpp"
/bin/sh: C:ToolsMinGWbing++: command not found
make: *** [SeeProgram.o] Error 127 .
In the next-to-last line, it should have read C:\Tools\MinGW\bin\g++, but it left out the back-slashes. I have not seen any other discussion of this, and have tried numerous approaches, but I am stumped at the moment. Any thoughts?
Many thanks.
Have you tried escaping the backslashes when you enter the location, e.g.:
C:\\Tools\\MingGW\\bin\\g++
This setup seems similar to yours, maybe it could provide a hint:
http://max.berger.name/howto/cdt/ar01s03.jsp#wincompiler