Skip to content

Commit 852a3d5

Browse files
committed
ROUTING-1182: adding information for cross-compilations where missing
1 parent a0bd5c2 commit 852a3d5

File tree

14 files changed

+274
-33
lines changed

14 files changed

+274
-33
lines changed

examples/cloud_discovery_service/library_api/c++11/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,30 @@ you want to link against. For example:
112112
cmake -DCONNEXTDDS_ARCH=x64Linux3gcc5.4.0 ..
113113
```
114114

115+
### Cross-compilation
116+
117+
When you need to cross-compile the example, the above
118+
command will not work, the assigned compiler won't be the cross-compiler and
119+
errors may happen when linking against the cross-compiled Connext binaries.
120+
To fix this, you have to create a file with the architecture name and call
121+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
122+
An example of the file to create with the toolchain settings (e.g. for an
123+
ARM architectures):
124+
125+
```cmake
126+
set(CMAKE_SYSTEM_NAME Linux)
127+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
128+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
129+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
130+
```
131+
132+
Then you can call CMake like this:
133+
134+
```bash
135+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
136+
-DCONNEXTDDS_ARCH=<connext architecture> ..
137+
```
138+
115139
### CMake Build Infrastructure
116140

117141
The `CMakeListst.txt` script that builds this example uses a generic CMake

examples/cloud_discovery_service/library_api/c/README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,33 @@ you want to link against. For example:
112112
cmake -DCONNEXTDDS_ARCH=x64Linux3gcc5.4.0 ..
113113
```
114114

115+
### Cross-compilation
116+
117+
When you need to cross-compile the example, the above
118+
command will not work, the assigned compiler won't be the cross-compiler and
119+
errors may happen when linking against the cross-compiled Connext binaries.
120+
To fix this, you have to create a file with the architecture name and call
121+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
122+
An example of the file to create with the toolchain settings (e.g. for an
123+
ARM architectures):
124+
125+
```cmake
126+
set(CMAKE_SYSTEM_NAME Linux)
127+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
128+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
129+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
130+
```
131+
132+
Then you can call CMake like this:
133+
134+
```bash
135+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
136+
-DCONNEXTDDS_ARCH=<connext architecture> ..
137+
```
138+
115139
### CMake Build Infrastructure
116140

117-
The `CMakeListst.txt` script that builds this example uses a generic CMake
141+
The `CMakeLists.txt` script that builds this example uses a generic CMake
118142
function called `connextdds_add_example` that defines all the necessary constructs
119143
to:
120144

examples/persistence_service/library_api/c/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ you want to link against. For example:
117117
cmake -DCONNEXTDDS_ARCH=x64Linux3gcc5.4.0 ..
118118
```
119119

120+
### Cross-compilation
121+
122+
When you need to cross-compile the example, the above
123+
command will not work, the assigned compiler won't be the cross-compiler and
124+
errors may happen when linking against the cross-compiled Connext binaries.
125+
To fix this, you have to create a file with the architecture name and call
126+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
127+
An example of the file to create with the toolchain settings (e.g. for an
128+
ARM architectures):
129+
130+
```cmake
131+
set(CMAKE_SYSTEM_NAME Linux)
132+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
133+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
134+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
135+
```
136+
137+
Then you can call CMake like this:
138+
139+
```bash
140+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
141+
-DCONNEXTDDS_ARCH=<connext architecture> ..
142+
```
143+
120144
### CMake Build Infrastructure
121145
122146
The `CMakeListst.txt` script that builds this example uses a generic CMake

examples/persistence_service/persistent_storage/c++11/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,30 @@ you want to link against. For example:
226226
cmake -DCONNEXTDDS_ARCH=x64Linux3gcc5.4.0 ..
227227
```
228228

229+
### Cross-compilation
230+
231+
When you need to cross-compile the example, the above
232+
command will not work, the assigned compiler won't be the cross-compiler and
233+
errors may happen when linking against the cross-compiled Connext binaries.
234+
To fix this, you have to create a file with the architecture name and call
235+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
236+
An example of the file to create with the toolchain settings (e.g. for an
237+
ARM architectures):
238+
239+
```cmake
240+
set(CMAKE_SYSTEM_NAME Linux)
241+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
242+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
243+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
244+
```
245+
246+
Then you can call CMake like this:
247+
248+
```bash
249+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
250+
-DCONNEXTDDS_ARCH=<connext architecture> ..
251+
```
252+
229253
### CMake Build Infrastructure
230254
231255
The `CMakeListst.txt` script that builds this example uses a generic CMake

examples/recording_service/pluggable_storage/c/FileStorageReader.c

+6-30
Original file line numberDiff line numberDiff line change
@@ -442,23 +442,9 @@ void FileStorageStreamReader_read(
442442
struct FileStorageStreamReader *stream_reader =
443443
(struct FileStorageStreamReader *) stream_reader_data;
444444
int i = 0;
445-
/*
446-
* If the last sample was already provided and we are at the end of the file
447-
* we will skip the read operation in order to finalize the execution.
448-
*/
449-
if (stream_reader->current_timestamp == INT64_MAX
450-
&& feof(stream_reader->file_record.file)) {
451-
*count = 0;
452-
return;
453-
}
454-
DDS_LongLong timestamp_limit;
455-
if (selector->time_range_end.sec == DDS_TIME_MAX.sec
456-
&& selector->time_range_end.nanosec == DDS_TIME_MAX.nanosec) {
457-
timestamp_limit = selector->time_range_end.sec;
458-
} else {
459-
timestamp_limit = selector->time_range_end.sec * NANOSECS_PER_SEC;
460-
timestamp_limit += selector->time_range_end.nanosec;
461-
}
445+
long long timestamp_limit =
446+
(long long) selector->time_range_end.sec * NANOSECS_PER_SEC
447+
+ selector->time_range_end.nanosec;
462448
int read_samples = 0;
463449
/*
464450
* The value of the sample selector's max samples could be
@@ -475,21 +461,12 @@ void FileStorageStreamReader_read(
475461
*count = 0;
476462
return;
477463
}
478-
/*
479-
* Add the currently read sample and sample info values to the taken data
480-
* and info collections (sequences)
481-
*/
464+
/* Add the currently read sample and sample info values to the taken data
465+
* and info collections (sequences) */
482466
do {
483467
FileStorageStreamReader_addSampleToData(stream_reader);
468+
FileStorageStreamReader_readSample(stream_reader);
484469
read_samples++;
485-
/*
486-
* if we reach the end of the file or we cant read a proper sample,
487-
* we dont add that sample on this iteration but we should send the
488-
* previous samples
489-
*/
490-
if (FileStorageStreamReader_readSample(stream_reader) == FALSE) {
491-
break;
492-
}
493470
} while (stream_reader->current_timestamp <= timestamp_limit
494471
&& read_samples < max_samples);
495472
/* The number of taken samples is the current length of the data sequence */
@@ -606,7 +583,6 @@ int FileStorageStreamReader_initialize(
606583
/* Bootstrap the take loop: read the first sample */
607584
if (!FileStorageStreamReader_readSample(stream_reader)) {
608585
printf("Failed to get first sample from file, maybe EOF was reached\n");
609-
return FALSE;
610586
}
611587

612588
RTI_RecordingServiceStorageStreamReader_initialize(

examples/routing_service/file_adapter/c++11/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
3939
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
4040

4141
target_link_libraries(${PROJECT_NAME}
42+
RTIConnextDDS::routing_service_cpp2
4243
RTIConnextDDS::routing_service_infrastructure
4344
RTIConnextDDS::cpp2_api
4445
)

examples/routing_service/file_adapter/c++11/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,29 @@ supports static linking of adapters. To use this functionality you would need to
6666
create an application that uses Routing Service as a library component and
6767
statically links to this `FileAdapter` library.
6868

69+
### Cross-compilation
70+
When you need to cross-compile the example, the above
71+
command will not work, the assigned compiler won't be the cross-compiler and
72+
errors may happen when linking against the cross-compiled Connext binaries.
73+
To fix this, you have to create a file with the architecture name and call
74+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
75+
An example of the file to create with the toolchain settings (e.g. for an
76+
ARM architectures):
77+
78+
```cmake
79+
set(CMAKE_SYSTEM_NAME Linux)
80+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
81+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
82+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
83+
```
84+
85+
Then you can call CMake like this:
86+
87+
```bash
88+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
89+
-DCONNEXTDDS_ARCH=<connext architecture> ..
90+
```
91+
6992
## Running C++ example
7093

7194
To run the example, you just need to run the following command from the `build`

examples/routing_service/file_adapter/c/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ supports static linking of adapters. To use this functionality you would need to
4343
create an application that uses Routing Service as a library component and
4444
statically links to this `FileAdapter` library.
4545

46+
### Cross-compilation
47+
When you need to cross-compile the example, the above
48+
command will not work, the assigned compiler won't be the cross-compiler and
49+
errors may happen when linking against the cross-compiled Connext binaries.
50+
To fix this, you have to create a file with the architecture name and call
51+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
52+
An example of the file to create with the toolchain settings (e.g. for an
53+
ARM architectures):
54+
55+
```cmake
56+
set(CMAKE_SYSTEM_NAME Linux)
57+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
58+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
59+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
60+
```
61+
62+
Then you can call CMake like this:
63+
64+
```bash
65+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
66+
-DCONNEXTDDS_ARCH=<connext architecture> ..
67+
```
68+
4669
## Running C Example
4770

4871
Before running the example, take a look at file_bridge.xml. It defines the

examples/routing_service/mongo_db/c++11/README.rst

+27
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,33 @@ Here is more information about generating
5050
create an application that uses Routing Service as a library component and
5151
statically link to this adapter.
5252

53+
Cross-compilation
54+
-----------------
55+
56+
When you need to cross-compile the example, the above
57+
command will not work, the assigned compiler won't be the cross-compiler and
58+
errors may happen when linking against the cross-compiled Connext binaries.
59+
To fix this, you have to create a file with the architecture name and call
60+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
61+
An example of the file to create with the toolchain settings (e.g. for an
62+
ARM architectures):
63+
64+
.. code::
65+
66+
set(CMAKE_SYSTEM_NAME Linux)
67+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
68+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
69+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
70+
71+
72+
Then you can call CMake like this:
73+
74+
.. code::
75+
76+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
77+
-DCONNEXTDDS_ARCH=<connext architecture> ..
78+
79+
5380
Running
5481
-------
5582

examples/routing_service/monitoring/c++11/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ If you generated Makefiles in the configuration process, run make to build the
2626
example. Likewise, if you generated a Visual Studio solution, open the solution
2727
and follow the regular build process.
2828

29+
### Cross-compilation
30+
31+
When you need to cross-compile the example, the above
32+
command will not work, the assigned compiler won't be the cross-compiler and
33+
errors may happen when linking against the cross-compiled Connext binaries.
34+
To fix this, you have to create a file with the architecture name and call
35+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
36+
An example of the file to create with the toolchain settings (e.g. for an
37+
ARM architectures):
38+
39+
```cmake
40+
set(CMAKE_SYSTEM_NAME Linux)
41+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
42+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
43+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
44+
```
45+
46+
Then you can call CMake like this:
47+
48+
```bash
49+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
50+
-DCONNEXTDDS_ARCH=<connext architecture> ..
51+
```
52+
2953
## Running the Example
3054

3155
In two separate command prompt windows for the publisher and subscriber. Run the

examples/routing_service/shapes_processor/c++11/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@ regular build process.
4545

4646
Upon success it will create a shared library file in the build directory.
4747

48+
### Cross-compilation
49+
50+
When you need to cross-compile the example, the above
51+
command will not work, the assigned compiler won't be the cross-compiler and
52+
errors may happen when linking against the cross-compiled Connext binaries.
53+
To fix this, you have to create a file with the architecture name and call
54+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
55+
An example of the file to create with the toolchain settings (e.g. for an
56+
ARM architectures):
57+
58+
```cmake
59+
set(CMAKE_SYSTEM_NAME Linux)
60+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
61+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
62+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
63+
```
64+
65+
Then you can call CMake like this:
66+
67+
```bash
68+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
69+
-DCONNEXTDDS_ARCH=<connext architecture> ..
70+
```
71+
4872
## Running the Example
4973

5074
To run this example you will need two instances of *RTI Shapes Demo* and a

examples/routing_service/struct_array_transf/c++11/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ Upon success it will create in the build directory:
5656

5757
- A subscriber application executable with name `SensorDataSubscriber`.
5858

59+
### Cross-compilation
60+
61+
When you need to cross-compile the example, the above
62+
command will not work, the assigned compiler won't be the cross-compiler and
63+
errors may happen when linking against the cross-compiled Connext binaries.
64+
To fix this, you have to create a file with the architecture name and call
65+
CMake with a specific flag called ``-DCMAKE_TOOLCHAIN_FILE``.
66+
An example of the file to create with the toolchain settings (e.g. for an
67+
ARM architectures):
68+
69+
```cmake
70+
set(CMAKE_SYSTEM_NAME Linux)
71+
set(toolchain_path "<path to>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian")
72+
set(CMAKE_C_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-gcc")
73+
set(CMAKE_CXX_COMPILER "${toolchain_path}/bin/arm-linux-gnueabihf-g++")
74+
```
75+
76+
Then you can call CMake like this:
77+
78+
```bash
79+
cmake -DCONNEXTDDS_DIR=<connext dir> -DCMAKE_TOOLCHAIN_FILE=<toolchain file created above>
80+
-DCONNEXTDDS_ARCH=<connext architecture> ..
81+
```
82+
5983
## Running the Example
6084

6185
To run this example you will need an instance of the publisher application, and

0 commit comments

Comments
 (0)