# Mytx.cpp

**URL:** <https://www.ruby-forum.com/t/mytx-cpp/241098>\
**Category:** GNU Radio\
**Created:** [May 13, 2014, 9:36am UTC](https://www.ruby-forum.com/t/mytx-cpp/241098 "2014-05-13T09:36:34Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 13, 2014, 9:36am UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/1 "2014-05-13T09:36:34Z")

</div>

Hello all  
I write a c++ document mytx.cpp and i place it into the  
uhd/host/build/examples.And then what should i do to let it run?Should i  
type the “make” command in the shell or do other things?Thank you.  
Best regards,  
Xianda

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 10:04am UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/2 "2014-05-13T10:04:17Z")

</div>

On 13.05.2014 09:35, 王先达 wrote:

> Hello all  
> I write a c++ document mytx.cpp and i place it into the  
> uhd/host/build/examples.And then what should i do to let it run?Should i  
> type the “make” command in the shell or do other things?Thank you.  
> Best regards,  
> Xianda

You don’t have to put it in examples, but you can use the CMakeLists.txt  
file in this directory to figure out how to set up a build environment.

The usual flow of cmake, make will compile your program then.

Martin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 3:31pm UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/3 "2014-05-13T15:31:44Z")

</div>

Hello  
Thank you for your reply.  
1.Because i just know a little about the cmake.If i put my  
document into another folder,maybe i should write the CMakeLists.txt.But  
if i put my document into the uhd/host/examples,maybe i change a little  
of the CMakeLists.txt.Is it right?  
2.Can you give me some advices about my new transmit  
document,namely,mytx.cpp?  
3.What is the difference between gr-uhd and uhd?Gr-uhd is just  
a part of UHD?Is it right?  
Thank you very much.  
Best regards  
在 2014-05-13 16:02:57，“Martin B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 写道：

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 3:26pm UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/4 "2014-05-13T15:26:12Z")

</div>

Hello  
Thank you for your reply.  
1.Because i just know a little about the cmake.If i put my  
document into another folder,maybe i should write the CMakeLists.txt.But  
if i put my document into the uhd/host/examples,maybe i change a little  
of the CMakeLists.txt.Is it right?  
2.Can you give me some advices about my new transmit  
document,namely,mytx.cpp?  
3.What is the difference between gr-uhd and uhd?Gr-uhd is just  
a part of UHD?Is it right?  
Thank you very much.  
Best regards  
在 2014-05-13 16:02:57，“Martin B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 写道：

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 3:34pm UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/5 "2014-05-13T15:34:12Z")

</div>

Hello  
Thank you for your reply.  
1.Because i just know a little about the cmake.If i put my  
document into another folder,maybe i should write the CMakeLists.txt.But  
if i put my document into the uhd/host/examples,maybe i change a little  
of the CMakeLists.txt.Is it right?  
2.Can you give me some advices about my new transmit  
document,namely,mytx.cpp?  
3.What is the difference between gr-uhd and uhd?Gr-uhd is just  
a part of UHD?Is it right?  
Thank you very much.  
Best regards  
在 2014-05-13 16:02:57，“Martin B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 写道：

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 5:48pm UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/6 "2014-05-13T17:48:31Z")

</div>

Hello  
Thank you a lot.  
1.But now the header document in my tx.cpp is same as the  
tx\_waveforms.cpp.Now what should i do?How to change the CMakeList.txt?  
2.I try to test.I copy the tx\_waveforms.cpp to other catalogue.I try to  
use the g++ to test,but it go wrong?Must i use the cmake?  
Thank you.  
Best regards

在 2014-05-13 22:47:34，“Tom R.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 写道：

On Tue, May 13, 2014 at 9:24 AM, xianda [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:  
Hello  
Thank you for your reply.  
1.Because i just know a little about the cmake.If i put my  
document into another folder,maybe i should write the CMakeLists.txt.But  
if i put my document into the uhd/host/examples,maybe i change a little  
of the CMakeLists.txt.Is it right?

Yes, cribbing from an existing file is an easy way to get started. But  
this is really now a cmake issue, not a GNU Radio one. If modifying an  
existing cmake file doesn’t work or you need more help, you’ll have to  
study cmake a bit to work with it.

```
      2.Can you give me some advices about my new transmit 

```

document,namely,mytx.cpp?  
3.What is the difference between gr-uhd and uhd?Gr-uhd is just  
a part of UHD?Is it right?  
Thank you very much.

gr-uhd is the wrapper around the library that allows it to fit into and  
be used by GNU Radio. UHD is the external driver for the OS to talk to  
USRP devices.

Tom

Best regards  
在 2014-05-13 16:02:57，“Martin B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 写道：

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 4:49pm UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/7 "2014-05-13T16:49:21Z")

</div>

On Tue, May 13, 2014 at 9:24 AM, xianda [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hello  
> Thank you for your reply.  
> 1.Because i just know a little about the cmake.If i put my  
> document into another folder,maybe i should write the CMakeLists.txt.But if  
> i put my document into the uhd/host/examples,maybe i change a little of the  
> CMakeLists.txt.Is it right?

Yes, cribbing from an existing file is an easy way to get started. But  
this  
is really now a cmake issue, not a GNU Radio one. If modifying an  
existing  
cmake file doesn’t work or you need more help, you’ll have to study  
cmake a  
bit to work with it.

> ```
> 2.Can you give me some advices about my new transmit
> 
> ```
> 
> document,namely,mytx.cpp?  
> 3.What is the difference between gr-uhd and uhd?Gr-uhd is just a  
> part of UHD?Is it right?  
> Thank you very much.

gr-uhd is the wrapper around the library that allows it to fit into and  
be  
used by GNU Radio. UHD is the external driver for the OS to talk to USRP  
devices.

Tom

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 7:17pm UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/8 "2014-05-13T19:17:44Z")

</div>

Hello  
Thank you for your patience.  
And i run 3 steps:  
1.copy mytx.cpp to the uhd/host/example  
2.change the CMakeLists.txt on the uhd/host/example,and just:  
SET(example\_sources  
benchmark\_rate.cpp  
network\_relay.cpp  
rx\_multi\_samples.cpp  
rx\_samples\_to\_file.cpp  
rx\_samples\_to\_udp.cpp  
rx\_timed\_samples.cpp  
test\_dboard\_coercion.cpp  
test\_messages.cpp  
test\_pps\_input.cpp  
test\_timed\_commands.cpp  
transport\_hammer.cpp  
tx\_bursts.cpp  
tx\_samples\_from\_file.cpp  
tx\_timed\_samples.cpp  
tx\_waveforms.cpp  
txrx\_loopback\_to\_file.cpp  
latency\_test.cpp  
fpgpio.cpp  
mytx.cpp  
)  
3. cd build  
cmake …  
make  
This is right?

Another question:  
If i just write a cpp,what is the most convenient to run my  
.cpp document?To do something like up examples or by other ways?  
Thank you very much.You help me a lot.  
Best regards

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 6:34pm UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/9 "2014-05-13T18:34:03Z")

</div>

On 13.05.2014 17:31, xianda wrote:

> Hello  
> Thank you a lot.  
> 1.But now the header document in my tx.cpp is same as the  
> tx\_waveforms.cpp.Now what should i do?How to change the CMakeList.txt?

It’s just a text file. Add your own file in there.

> 2.I try to test.I copy the tx\_waveforms.cpp to other catalogue.I try to  
> use the g++ to test,but it go wrong?Must i use the cmake?

It definitely helps. If you manually compile, you might forget a -L or  
-I or whatever.

M

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 19, 2014, 4:56am UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/10 "2014-05-19T04:56:34Z")

</div>

Hello  
I try to use the g++ to compile my code for example :tx.cpp.But where  
can i find the static library and dynamic library?  
And the header :  
#include \<uhd/types/tune\_request.hpp\>  
#include \<uhd/utils/thread\_priority.hpp\>  
#include \<uhd/utils/safe\_main.hpp\>  
#include \<uhd/usrp/multi\_usrp.hpp\>  
#include \<boost/program\_options.hpp\>  
#include \<boost/format.hpp\>  
#include \<boost/thread.hpp\>  
#include \<gnuradio/fft/fft.h\>  
#include   
#include   
#include   
#include   
#include   
Can someone help me to compile tx.cpp?Thank you very much.  
g++ tx.cpp -I what -L what…???What command should i type into the  
shell?  
Thank you.  
Best regards

在 2014-05-14 02:01:40，“Tom R.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 写道：

On Tue, May 13, 2014 at 1:00 PM, xianda [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:  
Hello  
Thank you for your patience.  
And i run 3 steps:  
1.copy mytx.cpp to the uhd/host/example  
2.change the CMakeLists.txt on the uhd/host/example,and just:  
SET(example\_sources  
benchmark\_rate.cpp  
network\_relay.cpp  
rx\_multi\_samples.cpp  
rx\_samples\_to\_file.cpp  
rx\_samples\_to\_udp.cpp  
rx\_timed\_samples.cpp  
test\_dboard\_coercion.cpp  
test\_messages.cpp  
test\_pps\_input.cpp  
test\_timed\_commands.cpp  
transport\_hammer.cpp  
tx\_bursts.cpp  
tx\_samples\_from\_file.cpp  
tx\_timed\_samples.cpp  
tx\_waveforms.cpp  
txrx\_loopback\_to\_file.cpp  
latency\_test.cpp  
fpgpio.cpp  
mytx.cpp  
)  
3. cd build  
cmake …  
make  
This is right?

Another question:  
If i just write a cpp,what is the most convenient to run my  
.cpp document?To do something like up examples or by other ways?  
Thank you very much.You help me a lot.  
Best regards

Glad we could help, but you’re really asking questions about compiling,  
code management, and cmake, which are not specific to GNU Radio. If  
someone here can help you and has the time to, great, but there’s a ton  
of resources on the internet to help you understand these things.

Tom

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 19, 2014, 9:37am UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/11 "2014-05-19T09:37:12Z")

</div>

Xianda,

aside from using gnuradio/fft/fft.h (which you most probably could  
easily replace with directly using FFTW), your problem has nothing to do  
with GNU Radio – so this is the wrong list, sorry.

As the others already said, let your build system (e.g. CMake) deal with  
building your software, and find out where that places your files.

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 13, 2014, 8:03pm UTC](https://www.ruby-forum.com/t/mytx-cpp/241098/12 "2014-05-13T20:03:14Z")

</div>

On Tue, May 13, 2014 at 1:00 PM, xianda [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> rx_samples_to_udp.cpp
> txrx_loopback_to_file.cpp
> If i just write a cpp,what is the most convenient to run my
> 
> ```
> 
> .cpp document?To do something like up examples or by other ways?  
> Thank you very much.You help me a lot.  
> Best regards

Glad we could help, but you’re really asking questions about compiling,  
code management, and cmake, which are not specific to GNU Radio. If  
someone  
here can help you and has the time to, great, but there’s a ton of  
resources on the internet to help you understand these things.

Tom
