# \#include "vector.hpp"

**URL:** <https://www.ruby-forum.com/t/include-vector-hpp/242410>\
**Category:** GNU Radio\
**Created:** [June 22, 2015, 6:40pm UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410 "2015-06-22T18:40:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 22, 2015, 6:40pm UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/1 "2015-06-22T18:40:41Z")

</div>

Hello

I’m trying to create a block which C++ code needs to use include  
“vector.hpp”. But I;m getting this error: fatal error: vector.hpp: No  
such  
file or directory.

Is there a way to do this?

Thank you very much.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344.html](http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 22, 2015, 6:51pm UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/2 "2015-06-22T18:51:12Z")

</div>

Hi,

Try dropping the “.hpp” portion of your include. This file does not  
have  
any extension and is usually included as follows:

#include

Hope this helps,

Michael

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 23, 2015, 12:59am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/3 "2015-06-23T00:59:49Z")

</div>

Hi

Yes, I tried to use only #include , but it gives me an error for  
each vector a I use.

Vector f (at the beginning the following code) is one of the vectors  
which  
needs the #include “vector.hpp”.

intentooptimizar.cpp  
[http://gnuradio.4.n7.nabble.com/file/n54350/intentooptimizar.cpp](http://gnuradio.4.n7.nabble.com/file/n54350/intentooptimizar.cpp)

Thank you.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54350.html](http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54350.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 23, 2015, 1:48am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/4 "2015-06-23T01:48:19Z")

</div>

It looks like you are trying to create your own vector class named  
Vector  
(keeping notice of the capitalized ‘V’).

These Vector method definitions need a definition for the Vector class,  
which is presumably in your Vector.hpp. I would like to note that the  
.hpp  
extension indicates a template header library, and all of the method  
definitions should be inline in the template class definition, or in an  
include file; not in a compiled object file.

It appears (at least from this lone file) that you are not using  
std::vector at all, and you may wish to remove the '#include ’  
line  
to keep things clean in your code and not include not used pieces of  
code.

Back to your example not working, your #include “Vector.hpp” must point  
to  
the file that presumably contains the class definition. for this  
include  
to work as stated, the Vector.hpp file will have to be in the same  
directory as the file that you posted; otherwise you will have to give a  
relative (or absolute) path to this file in the include statement.

I hope this helps you some!

Michael

P.S. Why are you not using std::vector?

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 22, 2015, 6:52pm UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/5 "2015-06-22T18:52:57Z")

</div>

Hi!  
Um, there’s no vector.hpp in GNU Radio; are you maybe referring to the  
header that contains std::vector?

You would normally include that as

#include

and let your compiler figure out the file name suffix.

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 23, 2015, 2:36am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/6 "2015-06-23T02:36:13Z")

</div>

Yes Tom, you are absolutely right. I’m sorry and thank you.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54356.html](http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54356.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 23, 2015, 2:31am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/7 "2015-06-23T02:31:32Z")

</div>

On Mon, Jun 22, 2015 at 7:40 PM, Michael B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> std::vector at all, and you may wish to remove the ‘#include ’ line
> 
> Michael
> 
> P.S. Why are you not using std::vector?

David,  
While I’m kind of curious about you making your own vector class, too,  
this  
is not about GNU Radio but generally C++ coding issues. Please move this  
conversation to a more appropriate forum about programming.

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 24, 2015, 2:39am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/8 "2015-06-24T02:39:48Z")

</div>

Hello!

I think I already found a way to do this, but now I’m getting this  
error:  
“error: a function-definition is not allowed here before ‘{’ token”  
In these parts of the code :

Vector txyz(4);  
void initialize()  
{  
txyz[0] = 0.0;  
txyz[1] = 0.0;  
txyz[2] = 1.0;  
txyz[3] = 0.0;  
}

void PrimercruceenB()  
{  
char B;  
char Bi;  
double w = sqrt(b \* (r - 1));  
while (txyz[1] \< w){ // Cruce con plano B en x

```
    RK4Step(txyz, dt);

```

}  
// Aqui ya tengo el primer valor de x cruzando al plano B

```
    if (txyz[2] >= w) { // Cruce con plano B en y
            Bi = '3';
    }
    else {
            while ( txyz[2] < w) {
                    RK4Step(txyz, dt);
            }
            if (txyz[1] >= w) {
              Bi = '3';
            }
    }

```

}

Vector f(Vector txyz)  
{  
double t = txyz[0];  
double x = txyz[1];  
double y = txyz[2];  
double z = txyz[3];  
Vector f(4);  
f[0] = 1;  
f[1] = - sigma \* x + sigma \* y;  
f[2] = - x \* z + r \* x - y;  
f[3] = x \* y - b \* z;  
return f;  
}

I don’t know why I’m getting this error. Doesn’t these functions can be  
recognize by GNU Radio?

Thank you.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54388.html](http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54388.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 24, 2015, 3:00am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/9 "2015-06-24T03:00:50Z")

</div>

I’m getting this error while I’m trying to create a new block.  
I don’t get any error when I compile it in a C++ compiler.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54390.html](http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54390.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 24, 2015, 3:11am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/10 "2015-06-24T03:11:56Z")

</div>

On Tue, Jun 23, 2015 at 8:36 PM, dcardona [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’m getting this error while I’m trying to create a new block.  
> I don’t get any error when I compile it in a C++ compiler.

I’m sorry, but there is no indication of that in your original email  
about  
the code. It was just what looked like your own code; not inside a GNU  
Radio block. Most likely, you have not properly added your class files  
to  
the build processing CMakeLists.txt.

Also, where is your original post? Please keep the thread readable when  
replying by keeping the relevant parts of the conversation in the replay  
and bottom-posting like this.

Tom

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 24, 2015, 2:53am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/11 "2015-06-24T02:53:49Z")

</div>

On Tue, Jun 23, 2015 at 8:15 PM, dcardona [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> txyz[1] = 0.0;
> 
> }
> double y = txyz[2];
> 
> ```
> 
> recognize by GNU Radio?
> 
> Thank you.

Once again, this is a C++ coding issue. I don’t even see any GNU Radio  
code  
in here.

Tom

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 24, 2015, 9:17am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/12 "2015-06-24T09:17:39Z")

</div>

I’m sorry. You are right, I will try to keep that in mind next time I  
write  
asking for help.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54398.html](http://gnuradio.4.n7.nabble.com/include-vector-hpp-tp54344p54398.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 24, 2015, 8:08am UTC](https://www.ruby-forum.com/t/include-vector-hpp/242410/13 "2015-06-24T08:08:43Z")

</div>

Hi David,

GNU Radio block or not, what you’re seeing is C++ error, and your code  
is not really related to GNU Radio.  
Since GNU Radio is written in “normal” C++, you must have made some  
syntax mistake when integrating your code into the template that you get  
when creating a new block.  
However, that template is just a bunch of normal C++ files containing  
normal classes (that’s what GNU Radio is – C++ files containing  
classes); we’re typically pretty resource- and helpful when it comes to  
solving issues that arise when dealing with GNU Radio code, but what  
you’re giving us has no indication of where things go wrong, and how you  
use that code in your C++ class. All we can tell you is that a) you seem  
to have done it wrong and b) you might really need to learn how to read  
and communicate compiler errors, so that you might yourself understand  
better what goes wrong and how to ask for help in a manner that allows  
people to see what’s wrong.

So: Make sure you find out where you didn’t write correct C++. Best  
option is always to have someone who is a bit more used to that sit next  
to you, and tell her/him “I wrote this code, and when I try to compile  
it, I get this error”, and then let that person explain to you how they  
approach figuring out where the problem lies. Even if the two of you  
don’t really figure out the problem, that will lead to the both of you  
learning about debugging – which is really invaluable!  
If you can’t solve the problem, it’s really O.K. to ask somewhere, but  
please make sure to offer all information one might need to understand  
the problem; in your case that mail would have looked something like:

“I have wrote a couple of C++ \<methods/classes/functions/…\> to  
. Now, \<link to [gist.github.com/pastebin.com/](http://gist.github.com/pastebin.com/)… or inline  
code\> compiles fine, but when I insert these  
\<methods/classes/functions/…\> into my newly created block (gr\_modtool  
add \<options you’ve used\>), the following \<link to full file or even  
better complete OOT on [gist.github.com/pastebin.com/](http://gist.github.com/pastebin.com/)… or inline code\>  
doesn’t compile. I get the error \<full error, especially including line  
number\>.”

Then, it would have been easy for us to understand the connection to GNU  
Radio, to actually see where things went wrong, and to analyze the error  
– all things that you might have already guessed were important to the  
solution.

But I have to agree with Tom quite a bit: what you’re having are mainly  
C++ problems, and they don’t seem to be very GNU Radio-specific. So  
probably sitting with someone who knows C++ (but doesn’t know GNU Radio)  
makes much more sense than asking us, who know GNU Radio (and a bit of  
C++) but don’t have the chance to sit next to you and talk to you about  
what your code does/should do and interactively explore what you do.

Best regards,  
Marcus
