Unable to use GMP with Omnet++ - omnet++

I have installed GMP on ubuntu. I download GMP-6.1.2 from "https://gmplib.org".Then I extracted it in Home folder and installed like:
1. cd gmp-6.1.2
2../configure
3. make
4. sudo make install
5. make check
I checked,gmp was installed in "/usr/local" and I opened omnet and I change these paths:
I entered Properties project:
1. in (c/c++ build | environment | path ), I added :
(/usr/local/include:/usr/local/lib) then I applied.
2. in (c/c++ General | paths and symbols | includes),I added
(/usr/local/include) in assembly, GNU c, GNU C++.then I applied.
At ( (c/c++ General | paths and symbols | Library paths). I added (/usr/local/lib). Then I applied.
Also ( (c/c++ General | paths and symbols | libraries). I wrote "gmpxx" and "gmp". Then I applied.
3. in (omnet++ | Makemake | select "src" folder | select Options |
custom | makefrag ) I added "EXTRA_OBJS=-lgmp". Then I applied them
and OK.
After that,I built my project and I received these errors :
Description Resource Path Location Type
Error refreshing Makefiles: /home/mar/Desktop/omnet_proj/id_2/test_independent/mixim-2.3/src/EXTRA_OBJS=-lgmp (No such file or directory) mixim-2.3 Unknown Makefile Problem
Description Resource Path Location Type
Program "gcc" not found in PATH mixim-2.3 [Discovery Options] page in project properties C/C++ Problem
Description Resource Path Location Type
Program "make" not found in PATH mixim-2.3 C/C++ Problem
I must say I am using MIXIM in Omnet++.
I don't know what is going on?
Could you please help me?
Thank you in advance of your help.

Assuming that you have installed libgmp using sudo apt-get install libgmp3-dev in your OMNeT++ project you have to do:
In header file (*.h) of simple module where you want to use gmp add:
#include <gmp.h>
Go to Project Properties, choose OMNeT++ | Makemake | select src | Options | Custom | Makefrag and write:
EXTRA_OBJS=-lgmp
To check you can add the following code somewhere in your source file, for example in initialize():
mpz_t a, b, c;
mpz_init_set_str(a, "123", 10);
mpz_init_set_str(b, "458", 10);
mpz_init(c);
mpz_add(c, a, b);
char * ctxt = mpz_get_str(NULL, 10, c);
EV << "c=" << ctxt << std::endl; // print the result
mpz_clear(a);
mpz_clear(b);
mpz_clear(c);

I think I can do that.
I have installed gmp in ubuntu. Then I added "gmp.h" and "gmpXX.h" to my project.
After that,I went to project properties | omnet++ | select SRC | Options | link | Additional libraries to link with:(-l option) and I inserted these two Option:
gmpxx , gmp .
Also,I added "/usr/local/include" in "paths and symbols(in project properties) | includes " and "/usr/local/lib" in " paths and symbols | library paths ".
After that,I added "/usr/include" in "paths and symbols(in project properties) | includes " and "/usr/lib/i386-linux-gnu" in " paths and symbols | library paths ".
And I built my project without any error.
At last,I run dear Jurzy D's example without any error.
I did not change any thing else.

Related

Building .dtbo overlay for BBB using bitbake

I built a yocto distro (rocko) for my BBB using kernel linux-ti-staging-4.14 with a custom device tree. Since I need to port an old project from Debian to Yocto, I also needed to enable the UIO features in the kernel, which works fine too.
Now I need to also create an additonal device-tree-overlay for the UIO PRUSS. I use a dts file from here and extended the kernel recipe via bbappend:
inherit kernel-devicetree
FILESEXTRAPATHS_prepend := "${THISDIR}/files/dts:${THISDIR}/files/beaglebone:"
# Make custom kernel with PRU enabled
SRC_URI += " \
file://bbb-pru-minimal.dts;subdir=git/arch/${ARCH}/boot/dts \
file://AM335X-PRU-UIO-00A0-overlay.dts;subdir=git/arch/${ARCH}/boot/dts/overlays \
file://0001-add-UIO-dtbo.patch \
file://defconfig \
"
KERNEL_DEVICETREE = " \
AM335X-PRU-UIO-00A0.dtbo \
bbb-pru-minimal.dtb \
"
The above listed patch file contains:
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 7949c213a434..fe2513074893 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
## -610,6 +610,7 ## dtb-$(CONFIG_SOC_TI81XX) += \
dm8168-evm.dtb \
dra62x-j5eco-evm.dtb
dtb-$(CONFIG_SOC_AM33XX) += \
+ AM335X-PRU-UIO-00A0.dtbo \
am335x-baltos-ir2110.dtb \
am335x-baltos-ir3220.dtb \
am335x-baltos-ir5221.dtb \
However, the kernel build fails as it seems there is no rule for .dtbo targets:
| CC scripts/mod/empty.o
| CC scripts/mod/devicetable-offsets.s
| MKELF scripts/mod/elfconfig.h
| HOSTCC scripts/mod/modpost.o
| HOSTCC scripts/mod/sumversion.o
| CHK scripts/mod/devicetable-offsets.h
| HOSTCC scripts/mod/file2alias.o
| HOSTLD scripts/mod/modpost
| NOTE: make -j 24 HOSTCC=gcc -isystem[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/include -O2 -pipe -L[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -L[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-rpath-link,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -Wl,-rpath-link,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-rpath,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -Wl,-rpath,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=[TOPDIR]/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 HOSTCPP=gcc -E AM335X-PRU-UIO-00A0.dtbo
| CHK scripts/mod/devicetable-offsets.h
| make[3]: *** No rule to make target 'arch/arm/boot/dts/AM335X-PRU-UIO-00A0.dtbo'. Stop.
| arch/arm/Makefile:345: recipe for target 'AM335X-PRU-UIO-00A0.dtbo' failed
| make[2]: *** [AM335X-PRU-UIO-00A0.dtbo] Error 2
| Makefile:146: recipe for target 'sub-make' failed
| make[1]: *** [sub-make] Error 2
| Makefile:24: recipe for target '__sub-make' failed
| make: *** [__sub-make] Error 2
| ERROR: oe_runmake failed
Please note, I replaced the absolute paths in the error message with [TOPDIR] due to privacy reasons.
Since I am fairly new to overlay creation I don't really know what I am missing or how to fix it. Any hints?
Thank you in advance!
Update: Added patch file to description above.
Here is what I found after analyzing Toradex's git projects that can inspire you for a solution:
They have a custom class that handles their device tree files and device tree overlays, here.
The class inherits devicetree that is an official poky class here.
The devicetree class tests if a device tree is an overlay or normal and then it compiles all of them.
So, you can basically use devicetree class in a custom recipe to compile device tree overlays and deploy them manually into your rootfs.
Toradex also has a simple recipe like that here. They have a git project that holds all of their device tree overlays.
That being said, I think Toradex doesn't use the custom recipe, rather they use the custom toradex-devicetree class which inherits from devicetree, compiles all device tree overlays from their device tree overlays git project and then deploy them all into the rootfs.
In that custom class, they append to do_deploy of devicetree class to install the .dtbo files and add them to overlays.txt file under the boot partition.
So finally, you can create a bbappend file for you kernel recipe if you don't have one, and try to follow these steps:
Inherit from devicetree
Add your dts files that are overlays to SRC_URI via local files or URL
Add the path for your overlays to DT_FILES_PATH of the devicetree class
In the kernel recipe, append to do_deploy to add them to rootfs.
Now, here is my advice to achieve this step by step:
Create a custom recipe that uses devicetree class with dts overlay example file
Check if it compiles it correctly
If you understand that, you can then apply the 4 steps above.
Thanks to the hints from #BelHadjSalem I was able to manage the dtbo build.
The class file devicetree.bbclass was introduced in Yocto with release "thud", therefore I updated my whole workspace to the latest Yocto release (dunfell). Afterwards I created a new recipe just to build my dtbo overlay:
inherit devicetree
FILESEXTRAPATHS_prepend := "${THISDIR}/files/dts:"
SRC_URI = " \
file://AM335X-PRU-UIO-00A0.dts;subdir=git/overlays \
"
S = "${WORKDIR}/git/overlays"
COMPATIBLE_MACHINE = ".*(ti33x|beaglebone).*"
The recipe is pretty simple and works in my project as required.
However, one important note: Inheriting the devicetree.bbclass in any kernel recipe or kernel bbappend file, will NOT work! Not sure what exactly happens, but the inheritance of devicetree.bbclass will invalidate the kernel recipe configuration and fail with ERROR: Nothing PROVIDES 'virtual/kernel'

Try to create new project with INET reference, got : "unexpected NAME, expecting $end" in .msg file

I created a project which contains my linklayer and simulation source code.
This project has INET as the project reference.
At build time, I got this error:
Error: syntax error, unexpected NAME, expecting $end
It comes from the message file (which contains types of messages):
import inet.common.INETDefs;
My message file is very similar to the Bmac message file (also tried with Bmac, got the same error).
Any idea please?
INET 4.X uses a new version of message compiler. But OMNeT++ by default sets in new project the old one.
In your project go to Properties, select OMNeT++ | Makemake | src folder | Options... | Custom and add the following line:
MSGC:=$(MSGC) --msg6

Failing to build Boost components locally with Bazel build

I am trying to build Boost library locally and want to use it as a local_repository in my own project. I am referring to this (https://github.com/nelhage/rules_boost) for help.
I have a directory tree like this:
boost/ // root of the boost project
|
bazel/
| |
| boost.bzl // contains "boost_library" function from https://github.com/nelhage/rules_boost/blob/master/boost/boost.bzl
| |
| BUILD // empty
boost/ // the original boost headers folder from original boost dist
|
lib/ // the original boost sources folder from original boost dist
|
BUILD
|
WORKSPACE
The BUILD file looks like this one:
https://github.com/nelhage/rules_boost/blob/master/BUILD.boost
with properly loading boost.bzl
The WORKSPACE is just:
workspace( name = "boost" )
The issue:
Now I am trying to build individual components (bazel build //:<component>).
Some of the components (Boost.Container, Boost.Test) are failing to build for a similar reason (not finding header files).
bazel build //:container 1 ↵
INFO: Found 1 target...
ERROR: /home/spyder/codebase/boost/BUILD:103:1: C++ compilation of rule '//:container' failed: Process exited with status 1 [sandboxed].
libs/container/src/global_resource.cpp:12:51: fatal error: boost/container/pmr/memory_resource.hpp: No such file or directory
compilation terminated.
Use --strategy=CppCompile=standalone to disable sandboxing for the failing actions.
Target //:container failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.519s, Critical Path: 0.18s
bazel build //:test 1 ↵
INFO: Found 1 target...
ERROR: /home/spyder/codebase/boost/BUILD:581:1: C++ compilation of rule '//:test' failed: Process exited with status 1 [sandboxed].
libs/test/src/junit_log_formatter.cpp:11:51: fatal error: boost/test/impl/junit_log_formatter.ipp: No such file or directory
compilation terminated.
Use --strategy=CppCompile=standalone to disable sandboxing for the failing actions.
Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.027s, Critical Path: 0.82s
Can anyone guide me on fixing it ?
EDIT:
I also tried to query the expanded cc_library rule by bazel query --output=build //:container and got this
cc_library(
name = "container",
visibility = ["//visibility:public"],
generator_name = "container",
generator_function = "boost_library",
generator_location = "/home/spyder/codebase/boost/BUILD:103",
licenses = ["notice"],
deps = ["//:config", "//:core", "//:intrusive", "//:move"],
defines = [],
includes = ["boost/container/"],
copts = ["-Wno-unused-value"],
srcs = ["//:libs/container/src/alloc_lib.c", "//:libs/container/src/dlmalloc.cpp", "//:libs/container/src/dlmalloc_2_8_6.c", "//:libs/container/src/dlmalloc_ext_2_8_6.c", "//:libs/container/src/global_resource.cpp", "//:libs/container/src/monotonic_buffer_resource.cpp", "//:libs/container/src/pool_resource.cpp", "//:libs/container/src/synchronized_pool_resource.cpp", "//:libs/container/src/unsynchronized_pool_resource.cpp"],
hdrs = [ ....... , "//:boost/container/pmr/map.hpp", "//:boost/container/pmr/memory_resource.hpp", "//:boost/container/pmr/monotonic_buffer_resource.hpp", "//:boost/container/pmr/polymorphic_allocator.hpp", ........ ],
)
Very shockingly, the source file which is complaining (libs/container/src/global_resource.cpp) and the header that it is complaining about (boost/container/pmr/memory_resource.hpp) are both correctly included in the srcs and hdrs list.
I played with your rules a bit and the biggest problem I see is incomplete dependencies. For example I tried :algorithm component, and that needs to depend on :tuple. I guess you just needs to make sure all dependencies are set correctly.
I played more with container, and the problem I encountered was incorrect include dirs. If you run your build with -s flag, bazel will output all the command lines so you can inspect them and check that -isystem flags contain the directory that contains boost/container/... . What can also help you is the bazel flag --sandbox_debug, which will prevent the sandbox directory from being deleted so you can see which files are where and also you can reproduce the compiler invocation without running through bazel.
Last, bazel does not understand .ipp header extension yet (tbh I've never heard of it, but I also know next to nothing about boost). I have a change in flight that will introduce this.

error: use of deleted function ‘std::basic_ofstream<char>& std::basic_ofstream<char>::operator=(const std::basic_ofstream<char>&)’ofstream deleted

std::map<std::string, std::ofstream> Map;
std::string name="name";
std::ofstream ofs(name,std::ios::app);
Map[name] = std::move(ofs);
I run the code above but it failed.
I compiled it by g++ 4.9 on Ubuntu12.04 and g++-5 (gcc version 5.4.1 20160904 (Ubuntu 5.4.1-2ubuntu1~12.04) ) using -std=c++11, which induces the same error message below.
error: use of deleted function ‘std::basic_ofstream&
std::basic_ofstream::operator=(const
std::basic_ofstream&)’ Map[name] = std::move(ofs);
/usr/include/c++/4.9/fstream:602:11: note: ‘std::basic_ofstream&
std::basic_ofstream::operator=(const
std::basic_ofstream&)’ is implicitly deleted because the default
definition would be ill-formed:
class basic_ofstream : public basic_ostream<_CharT,_Traits>
Support for moving iostreams was added to GCC 5.1, so you can't do it with GCC 4.9. This is documented in the libstdc++ manual for version 4.9: https://gcc.gnu.org/onlinedocs/gcc-4.9.4/libstdc++/manual/manual/status.html#status.iso.2011
27.5 | Iostreams base classes | Partial | Missing move and swap operations on basic_ios. Missing io_errc and iostream_category. ios_base::failure is not derived from system_error. Missing ios_base::hexfloat.
27.6 | Stream buffers | Y |
27.7 | Formatting and manipulators | Partial | Missing move and swap operations Missing get_time and put_time manipulators.
27.8 | String-based streams | Partial | Missing move and swap operations
27.9 | File-based streams | Partial | Missing move and swap operations
It is supported in GCC 5.x and works fine, so you must be doing something wrong (probably forgetting to use -std=c++11, or pointing it to the 4.9 headers which definitely won't work).

How do I install RODBC on Mac with unixodbc and freetds?

After a fairly extensive search, I noticed that a number of people are having a hard time finding a start-to-finish guide that answers this question. (At least one question notes that a solution exists, but the proposed solution does not get around the fact that, by default, RODBC attempts to compile against iODBC, which is not included with Yosemite.) I just went through this process, so I thought I would document it here in the hope that it will benefit others. I am connecting to a SQL Server database.
Using Homebrew as my OS X package manager, I can install RODBC with the following steps (assuming I have already installed R).
Install unixodbc:
$ brew install unixodbc
Install freetds (replacing /usr/local/Cellar/unixodbc/2.3.2_1 with your unixodbc directory, if necessary):
$ brew install --with-tdsver=8.0 --with-msdblib --with-unixodbc=/usr/local/Cellar/unixodbc/2.3.2_1 freetds
Configure your freetds installation (the following is a minimal configuration file):
freetds.conf
# server specific section
[global]
; tds version = 8.0
; dump file = /tmp/freetds.log
; debug flags = 0xffff
; timeout = 10
; connect timeout = 10
text size = 64512
[TESTSQL]
# insert the actual host below
host = <xxx.xx.x.xx>
port = 1433
tds version = 8.0
Test the freetds config:
$ tsql -H `<xxx.xx.x.xx>` -p 1433 -U `<username>` -P `<password>`
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> exit
Configure your unixodbc installation (the following is a minimal configuration file):
$ sudo vim /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbcinst.ini
odbcinst.ini
[MSSQL]
Description = Microsoft SQL Server driver
Driver = /usr/local/Cellar/freetds/0.95.18/lib/libtdsodbc.so
(and another minimal installation file):
$ sudo vim /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbc.ini
odbc.ini
[ODBC Data Sources]
TESTSQL = Test database
[TESTSQL]
Driver = MSSQL
Servername = TESTSQL
Port = 1433
Database = TMSEPRD
TDS_Version = 8.0
Test the new configuration with isql:
$ isql TESTSQL `<username>` `<password>`
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> quit
Create a symbolic link to the files in your home directory:
$ ln -vs /usr/local/Cellar/freetds/0.95.18/etc/freetds.conf ~/.freetds.conf
$ ln -vs /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbc.ini ~/.odbc.ini
$ ln -vs /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbcinst.ini ~/.odbcinst.ini
Find and modify your RProfile file by appending the following line(s) of code to the file (replacing /usr/local/include with the include directory that contains your sql.h and sqlext.h files; the second line may be unnecessary if the directory does not exist):
$ vim /Library/Frameworks/R.framework/Versions/3.2/Resources/library/base/R/Rprofile
Sys.setenv(ODBC_INCLUDE="/usr/local/include")
Sys.setenv(ODBC_LIBS="/usr/local/lib")
Now download the RODBC package source (which you an download here) to your Downloads folder.
Open a new R console session and install the package (replacing RODBC_1.3-12.tar.gz with the name of your package source):
install.packages("~/Downloads/RODBC_1.3-12.tar.gz", repos=NULL, type="source")
The package should now work:
> library(RODBC)
> myconn <- odbcConnect("TESTSQL", uid="<userid>", pwd="<password>")
Thanks to Jared Folkins and Gabi Huiber for help with figuring out what directories R looks in by default for the requisite files for RODBC.

Resources