Hi Dave,

I don't know and am not sure if it is safe to use c++11 flag. But I needed it, 
and so far I don't see any problems.


Regards,


Pranav Padalkar
Fraunhofer-Institut für Eingebettete Systeme und Kommunikationstechnik ESK
________________________________
From: Dave NotTelling <dmp250...@gmail.com>
Sent: Wednesday, August 31, 2016 1:59 PM
To: Pranav Padalkar
Cc: discuss-gnuradio@gnu.org
Subject: Re: [Discuss-gnuradio] Attribute error: and support with external 
class and header files

Is it safe to add the c++11 flag?  I was under the impression that the GNU 
Radio build system didn't use c++11 for a reason.  If that's not the case then 
I'll start using c++11 too :D

On Tue, Aug 30, 2016 at 4:25 AM, Pranav Padalkar 
<pranav.padal...@esk.fraunhofer.de<mailto:pranav.padal...@esk.fraunhofer.de>> 
wrote:

Good Morning everyone,


I figured out how to add my own source files in GNURadio and also how to add 
support for external libraries, in my case it was for Protobuf. I will just 
write a note here, hoping that it will help someone in the future.


1. I placed all of my own .h and .cpp files in the "lib" folder of my module, 
along with the "impl.cc" files.

2. I edited "CMakeLists.txt" of the "lib" folder; in that I added all of my own 
.cpp file names in "Setup library" section in the statement " list(APPEND ...) 
".


To add C++11 flag -

1. I edited "CMakeLists.txt" in the home folder of my module (i.e. 
gnuradio/gr-modulename/CMakeLists.txt); in that I added a command 
set(CMAKE_CXX_FLAGS "-std=c++11") in "Compiler specific setup" section after 
add_definitions().


To add external libraries, in my case Protobuf -

1. I edited "CMakeLists.txt" in the "lib" folder of my module.

2. In "Setup library" section, i added some commands to find the library I am 
looking for and then added them in "include_directories()" and in 
"link_directories()".


include(FindProtobuf)
find_package(Protobuf REQUIRED)

include_directories(${Boost_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS} ${Protobuf_LIBRARIES})

target_link_libraries(gnuradio-modulename ${Boost_LIBRARIES} 
${GNURADIO_ALL_LIBRARIES} ${Protobuf_LIBRARIES})


 After doing this it works for me now and I don't get attribute error which was 
happening because of my source files and libraries not being linked.


Regards,

Pranav Padalkar
Fraunhofer-Institut für Eingebettete Systeme und Kommunikationstechnik ESK

________________________________
From: Discuss-gnuradio 
<discuss-gnuradio-bounces+pranav.padalkar=esk.fraunhofer...@gnu.org<mailto:esk.fraunhofer...@gnu.org>>
 on behalf of Pranav Padalkar 
<pranav.padal...@esk.fraunhofer.de<mailto:pranav.padal...@esk.fraunhofer.de>>
Sent: Wednesday, August 24, 2016 9:19 AM
To: Dave NotTelling
Cc: discuss-gnuradio@gnu.org<mailto:discuss-gnuradio@gnu.org>
Subject: Re: [Discuss-gnuradio] Attribute error: and support with external 
class and header files

Hi Dave,

Thanks for your reply. Actually I figured out the problem. After going through 
the files of the already existing blocks, especially the CMakeLists.txt, I 
figured out where I need to add my own header files. I added entries of all the 
class files in the CMakeLists.txt inside “lib” folder. I am not sure if this 
has solved the problem, but at least it is compiling now. Currently I am facing 
the problem of how to make the GnuRadio compiler to get the C++11 flag. I know 
it has to be added to the CMake file, but I am not sure where exactly. If 
anyone knows about this, then kindly let me know. I also need to include other 
libraries like pthread, libboost_filesystem, etc.

Thanks and Regards,
Pranav

Von: Dave NotTelling [mailto:dmp250...@gmail.com<mailto:dmp250...@gmail.com>]
Gesendet: Dienstag, 23. August 2016 18:50
An: Pranav Padalkar
Cc: discuss-gnuradio@gnu.org<mailto:discuss-gnuradio@gnu.org>
Betreff: Re: [Discuss-gnuradio] Attribute error: and support with external 
class and header files

I've had bad luck just putting my own headers in OOT modules.  The way I do 
things now is to use gr_modtool add and select 'noblock'.  Then just remove the 
grc XML file created.  Seems that YourModuleName_API is needed before structs 
and classes or it doesn't get seen by Swig.  Could be wrong about that.  Might 
just work for me on a fluke =\

On Tue, Aug 23, 2016 at 6:47 AM, Pranav Padalkar 
<pranav.padal...@esk.fraunhofer.de<mailto:pranav.padal...@esk.fraunhofer.de>> 
wrote:

Hello all,



I have written a c++ code and I wish to implement as a block in GNURadio. I 
created a module (named "newblocks") and a block (named "my_client) and made 
appropriate changes. The thing is, I have many class and header files for my 
c++ code, for eg. Protobuf. I put those files in a folder called "client" 
inside "include" folder of my module (gr-newblocks/include/newblocks/client). 
It showed no error during cmake, make, make install and ldconfig. But when I 
put the block in the flowgraph and run it, it gives me following error.



File "/home/sdr/workspace/develop/Pranav/USRP_client/usrp_client.py", line 115, 
in __init__
    self.newblocks_my_client_0 = newblocks.my_client("123", "8080")
AttributeError: 'module' object has no attribute 'my_client'



I already had a working block in the same module, which I had created earlier. 
And now even that block gives me same error. If I don't use any of the two 
blocks, the flowgraph works fine.



I, then, also added a CMakeLists.txt file in that "client" folder and entered 
all the .h and .c files in the text file. I added the entry for "client" folder 
in the "Add subdirectories" part of the CMakeLists.txt in (gr-newblocks/ ). Is 
there anything else I need to do in order to use my own class and header files? 
Do I also need to put the .o files along with the header and class files? I 
tried with both, putting the .o files and not putting them, it still shows the 
same error.

I even created a new module and a new block and copy pasted my code and header 
and class files. I still get the same error. I kindly ask for help in this 
regard. I am using Ubuntu 14.04 LTS, GnuRadio 3.7.9.2, I am using a lot of 
Boost 1.61.



Thank you in advance.

Best Regards,
Pranav Padalkar
Fraunhofer-Institut für Eingebettete Systeme und Kommunikationstechnik ESK


_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org<mailto:Discuss-gnuradio@gnu.org>
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org<mailto:Discuss-gnuradio@gnu.org>
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to