Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QUdpSocket readyRead() is not emitted
Qt 6.12 LTS is out! See what's new in the release blog

QUdpSocket readyRead() is not emitted

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 5 Posters 8.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James Mark Chan
    wrote on last edited by
    #5

    Thank you! I just happen to stumble by dumb luck across the answer as you were posting. Appreciate your time.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      James Mark Chan
      wrote on last edited by
      #6

      Hi Dheerendra,

      If you have a moment for a follow up question. We have a non qmake build and I'm noticing that we get this error when I try to compile with the Q_OBJECT macro.

      obj/udp_server.o: In function `udp_server::udp_server(QObject*)':
      udp_server.cpp:(.text+0xc): undefined reference to `vtable for udp_server'
      

      Can I substitute come command line build commands and have the Q_OBJECT macro removed? Can you advise on how to inherit a class from qobject to use signal slots without needing to port our make file to a qmake pro format?

      Am I just calling moc <myfile.h>; moc <myfile.cpp> and then compiling with the two newly generated files from moc? Or is there more to it than that?

      jsulmJ 1 Reply Last reply
      0
      • J James Mark Chan

        Hi Dheerendra,

        If you have a moment for a follow up question. We have a non qmake build and I'm noticing that we get this error when I try to compile with the Q_OBJECT macro.

        obj/udp_server.o: In function `udp_server::udp_server(QObject*)':
        udp_server.cpp:(.text+0xc): undefined reference to `vtable for udp_server'
        

        Can I substitute come command line build commands and have the Q_OBJECT macro removed? Can you advise on how to inherit a class from qobject to use signal slots without needing to port our make file to a qmake pro format?

        Am I just calling moc <myfile.h>; moc <myfile.cpp> and then compiling with the two newly generated files from moc? Or is there more to it than that?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @James-Mark-Chan Do you also compile and link generated moc_*.cpp files?
        You can do an

        #include <moc_myfile.cpp>
        

        at the end of you myfile.cpp

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        J 1 Reply Last reply
        0
        • J Offline
          J Offline
          James Mark Chan
          wrote on last edited by
          #8

          Hi, a quick update. After I added these lines
          https://stackoverflow.com/questions/54263057/processing-of-q-object-in-legacy-non-qmake-build/
          I was able to build on my system locally but when I try and build on the remote build server I am getting these errors:

          18-Jan-2019 17:42:57	In file included from udp_server.cpp:2:0:
          18-Jan-2019 17:42:57	db.h:45:2: error: ‘uint32_t’ does not name a type
          18-Jan-2019 17:42:57	  uint32_t cont_type;
          18-Jan-2019 17:42:57	  ^
          18-Jan-2019 17:42:57	db.h:46:2: error: ‘uint32_t’ does not name a type
          18-Jan-2019 17:42:57	  uint32_t valve;
          18-Jan-2019 17:42:57	  ^
          18-Jan-2019 17:42:57	db.h:47:2: error: ‘uint32_t’ does not name a type
          18-Jan-2019 17:42:57	  uint32_t head;
          18-Jan-2019 17:42:57	  ^
          18-Jan-2019 17:42:57	db.h:48:2: error: ‘uint32_t’ does not name a type
          18-Jan-2019 17:42:57	  uint32_t fill_level;
          18-Jan-2019 17:42:57	  ^
          18-Jan-2019 17:42:57	udp_server.cpp: In member function ‘void udp_server::processPendingDatagrams()’:
          18-Jan-2019 17:42:57	udp_server.cpp:53:15: error: ‘struct fms_data_t’ has no member named ‘cont_type’
          18-Jan-2019 17:42:57	           fms.cont_type = jmap["cont_type"].toInt();
          18-Jan-2019 17:42:57	               ^
          18-Jan-2019 17:42:57	udp_server.cpp:54:15: error: ‘struct fms_data_t’ has no member named ‘valve’
          18-Jan-2019 17:42:57	           fms.valve = jmap["valve"].toInt();
          18-Jan-2019 17:42:57	               ^
          18-Jan-2019 17:42:57	udp_server.cpp:55:15: error: ‘struct fms_data_t’ has no member named ‘head’
          18-Jan-2019 17:42:57	           fms.head = jmap["head"].toInt();
          18-Jan-2019 17:42:57	               ^
          18-Jan-2019 17:42:57	udp_server.cpp:56:15: error: ‘struct fms_data_t’ has no member named ‘fill_level’
          18-Jan-2019 17:42:57	           fms.fill_level = jmap["fill_level"].toInt();
          18-Jan-2019 17:42:57	               ^
          

          I was wondering what the issue could be. I'm a far more experienced java developer so am not that familiar with qt troubleshooting. The remote system is Ubuntu 16.04 with:

          QMake version 3.0
          Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu
          

          And my local development environment is ubuntu 18.04

          QMake version 3.1
          Using Qt version 5.9.5 in /usr/lib/x86_64-linux-gnu
          

          Is this because of the version mismatch? I'm not actually using qmake so the version of make on both the build server and my local workstation is:

          GNU Make 4.1
          Built for x86_64-pc-linux-gnu
          

          Any advice is really appreciated!!!

          aha_1980A 1 Reply Last reply
          0
          • J James Mark Chan

            Hi, a quick update. After I added these lines
            https://stackoverflow.com/questions/54263057/processing-of-q-object-in-legacy-non-qmake-build/
            I was able to build on my system locally but when I try and build on the remote build server I am getting these errors:

            18-Jan-2019 17:42:57	In file included from udp_server.cpp:2:0:
            18-Jan-2019 17:42:57	db.h:45:2: error: ‘uint32_t’ does not name a type
            18-Jan-2019 17:42:57	  uint32_t cont_type;
            18-Jan-2019 17:42:57	  ^
            18-Jan-2019 17:42:57	db.h:46:2: error: ‘uint32_t’ does not name a type
            18-Jan-2019 17:42:57	  uint32_t valve;
            18-Jan-2019 17:42:57	  ^
            18-Jan-2019 17:42:57	db.h:47:2: error: ‘uint32_t’ does not name a type
            18-Jan-2019 17:42:57	  uint32_t head;
            18-Jan-2019 17:42:57	  ^
            18-Jan-2019 17:42:57	db.h:48:2: error: ‘uint32_t’ does not name a type
            18-Jan-2019 17:42:57	  uint32_t fill_level;
            18-Jan-2019 17:42:57	  ^
            18-Jan-2019 17:42:57	udp_server.cpp: In member function ‘void udp_server::processPendingDatagrams()’:
            18-Jan-2019 17:42:57	udp_server.cpp:53:15: error: ‘struct fms_data_t’ has no member named ‘cont_type’
            18-Jan-2019 17:42:57	           fms.cont_type = jmap["cont_type"].toInt();
            18-Jan-2019 17:42:57	               ^
            18-Jan-2019 17:42:57	udp_server.cpp:54:15: error: ‘struct fms_data_t’ has no member named ‘valve’
            18-Jan-2019 17:42:57	           fms.valve = jmap["valve"].toInt();
            18-Jan-2019 17:42:57	               ^
            18-Jan-2019 17:42:57	udp_server.cpp:55:15: error: ‘struct fms_data_t’ has no member named ‘head’
            18-Jan-2019 17:42:57	           fms.head = jmap["head"].toInt();
            18-Jan-2019 17:42:57	               ^
            18-Jan-2019 17:42:57	udp_server.cpp:56:15: error: ‘struct fms_data_t’ has no member named ‘fill_level’
            18-Jan-2019 17:42:57	           fms.fill_level = jmap["fill_level"].toInt();
            18-Jan-2019 17:42:57	               ^
            

            I was wondering what the issue could be. I'm a far more experienced java developer so am not that familiar with qt troubleshooting. The remote system is Ubuntu 16.04 with:

            QMake version 3.0
            Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu
            

            And my local development environment is ubuntu 18.04

            QMake version 3.1
            Using Qt version 5.9.5 in /usr/lib/x86_64-linux-gnu
            

            Is this because of the version mismatch? I'm not actually using qmake so the version of make on both the build server and my local workstation is:

            GNU Make 4.1
            Built for x86_64-pc-linux-gnu
            

            Any advice is really appreciated!!!

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by aha_1980
            #9

            @James-Mark-Chan uint32_t is in stdint.h. you probably miss an include which on your system is implicitely given.

            Qt has to stay free or it will die.

            jsulmJ 1 Reply Last reply
            0
            • aha_1980A aha_1980

              @James-Mark-Chan uint32_t is in stdint.h. you probably miss an include which on your system is implicitely given.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #10

              @aha_1980 @James-Mark-Chan Since C++11 it is <cstdint>
              https://en.cppreference.com/w/cpp/types/integer

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              aha_1980A 1 Reply Last reply
              2
              • jsulmJ jsulm

                @aha_1980 @James-Mark-Chan Since C++11 it is <cstdint>
                https://en.cppreference.com/w/cpp/types/integer

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #11

                @jsulm You're right. I'm just coding too much in C ;)

                Qt has to stay free or it will die.

                JonBJ 1 Reply Last reply
                0
                • aha_1980A aha_1980

                  @jsulm You're right. I'm just coding too much in C ;)

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #12

                  @aha_1980 If you're still coding in C rather than C++, can you give me a job, please ;-)

                  aha_1980A 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @aha_1980 If you're still coding in C rather than C++, can you give me a job, please ;-)

                    aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by aha_1980
                    #13

                    @JonB

                    If you can handle 12 kB RAM (no dynamic allocation!) and 128 kB Flash... ;)

                    Qt has to stay free or it will die.

                    JonBJ 1 Reply Last reply
                    0
                    • aha_1980A aha_1980

                      @JonB

                      If you can handle 12 kB RAM (no dynamic allocation!) and 128 kB Flash... ;)

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #14

                      @aha_1980 Sounds excellent --- I started on 1K RAM, no flash mem, and a cassette recorder.... :)

                      1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @James-Mark-Chan Do you also compile and link generated moc_*.cpp files?
                        You can do an

                        #include <moc_myfile.cpp>
                        

                        at the end of you myfile.cpp

                        J Offline
                        J Offline
                        James Mark Chan
                        wrote on last edited by
                        #15

                        @jsulm I'm curious if added:

                        #include <moc_myfile.cpp>
                        

                        Is the benefit that I don't need to compile an independent moc_myfile.o or would that step still be necessary?

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          James Mark Chan
                          wrote on last edited by
                          #16

                          It seems that another solution could be to do an install of the 5.9 or 5.12 into the target environment. This environment does not have a desktop, does anyone know if the silent installer feature works now? I was thinking of using:

                          sudo ./qt-opensource-linux-x64-5.12.0.run --platform minimal
                          

                          Will that work or is the script command also necessary?

                          aha_1980A 1 Reply Last reply
                          0
                          • J James Mark Chan

                            It seems that another solution could be to do an install of the 5.9 or 5.12 into the target environment. This environment does not have a desktop, does anyone know if the silent installer feature works now? I was thinking of using:

                            sudo ./qt-opensource-linux-x64-5.12.0.run --platform minimal
                            

                            Will that work or is the script command also necessary?

                            aha_1980A Offline
                            aha_1980A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on last edited by
                            #17

                            @James-Mark-Chan

                            The correct solution is to fix your code. Your build server already told you, that the code is relying on external includes to compile. Now you want to fix this by changing the external includes?!

                            This problem can come back anytime. Better fix it now.

                            Qt has to stay free or it will die.

                            1 Reply Last reply
                            1
                            • J Offline
                              J Offline
                              James Mark Chan
                              wrote on last edited by James Mark Chan
                              #18

                              @aha_1980 Thanks for the encouragement. I got this to build last evening by adding:

                              #include <stdint.h>
                              

                              to our db.h file. I'm not sure if that was the correct solution or if there was something wrong with the make file. Here is the make file for reference:

                              
                              MAJOR_VER=1
                              MINOR_VER=0
                              PATCH_VER=0
                              
                              DEB_MAINTAINER=
                              
                              ####### Sets include paths
                              FILTEC_BUILD="no"
                              
                              ####### Enable/Disable DEBUG build with "yes" or "no"
                              DEBUG="no"
                              
                              APP_BASE_NAME=historian
                              
                              BUILD_FILE = build.cpp
                              
                              SRCPP =	main.cpp db.cpp syslog.cpp log.cpp common.cpp pid.cpp $(BUILD_FILE)
                              SRCPP += mqtt_sub.cpp ve_util.cpp ve_mqtt.cpp udp_server.cpp moc_udp_server.cpp
                              
                              OBJDIR = ./obj
                              BINDIR = ./bin
                              RELDIR = ../release
                              MAKEOBJDIR := $(shell if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR) ; fi )
                              MAKEBINDIR := $(shell if [ ! -d $(BINDIR) ]; then mkdir $(BINDIR) ; fi )
                              MAKERELDIR := $(shell if [ ! -d $(RELDIR) ]; then mkdir $(RELDIR) ; fi )
                              
                              APPNAME	= $(BINDIR)/$(APP_BASE_NAME)
                              
                              OBJ = $(SRCPP:%.cpp=$(OBJDIR)/%.o)
                              
                              ifeq ($(FILTEC_BUILD),"yes")
                              QTPATH        = /home/filtec/Qt5.2.1/5.2.1/gcc_64
                              QTINCPATH     = $(QTPATH)/include
                              else
                              QTPATH        = /usr/include
                              QTINCPATH     = $(QTPATH)/x86_64-linux-gnu/qt5
                              endif
                              
                              #######################################
                              
                              INCLUDEPATH := -I./ -I$(QTINCPATH) -I$(QTINCPATH)/QtCore -I$(QTINCPATH)/QtNetwork -Ithirdparty/mosquitto/include -Ithirdparty/sqlite3/include
                              
                              CFLAGS = -Wall -Wno-trigraphs -pipe -fno-strict-aliasing -fno-common -fshort-enums
                              CFLAGS += $(INCLUDEPATH) -fPIC
                              CFLAGS += -Wformat-security
                              CFLAGS += -DLINUX
                              CFLAGS += -DMAJOR_VERSION=$(MAJOR_VER)
                              CFLAGS += -DMINOR_VERSION=$(MINOR_VER)
                              CFLAGS += -DPATCH_VERSION=$(PATCH_VER)
                              
                              LDLIBS = -lpthread -lQt5Core -lQt5Network
                              
                              LDLIBS += -lsqlite3
                              LDLIBS += -lmosquitto
                              
                              
                              ifeq (.version,$(wildcard .version))
                              BUILD_TMP := $(shell eval expr 0`cat .version` + 1 > .version)
                              else
                              BUILD_TMP := $(shell echo 0 > .version)
                              endif
                              BUILD_NUMBER := $(shell cat .version)
                              BUILD_DEB := $(shell eval expr 0`cat .version` + 1)
                              
                              ifeq ($(DEBUG),"yes")
                              CFLAGS += -O1
                              CFLAGS += -g -rdynamic -DDEBUG
                              DBG_SUFFIX=-dbg
                              else
                              CFLAGS += -O3
                              endif
                              
                              CC=g++
                              NM = $(CROSS)nm
                              STRIP = $(CROSS)strip
                              STRIPFLAGS = --strip-all --remove-section=.note --remove-section=.comment
                              
                              #######################################
                              
                              # FIL-3131 adding patch number to distinguish it from build number
                              #BASENAME = $(APPNAME)-$(MAJOR_VER).$(MINOR_VER).$(BUILD_NUMBER)$(DBG_SUFFIX)
                              BASENAME = $(APPNAME)-$(MAJOR_VER).$(MINOR_VER).$(PATCH_VER)+$(BUILD_NUMBER)$(DBG_SUFFIX)
                              
                              #######################################
                              
                              .PHONY: all clean do-it-all depend with-depends without-depends
                              
                              all: do-it-all
                              
                              ifeq (.depends,$(wildcard .depends))
                              include .depends
                              do-it-all: with-depends
                              else
                              do-it-all: without-depends
                              endif
                              
                              without-depends: depend with-depends
                              
                              depend: $(BUILD_FILE)
                              	rm -f .depends
                              	set -e; for F in $(SRC); do echo -n $(OBJDIR)/ >> .depends; $(CC) -MM $(CFLAGS) $$F >> .depends; done
                              
                              with-depends: $(OBJ) $(BASENAME)
                              
                              ## Compile
                              $(OBJDIR)/%o : %c
                              	$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
                              
                              $(OBJDIR)/%o : %cpp
                              	$(CXX) $(INCLUDES) $(CFLAGS) -c $< -o $@
                              
                              $(OBJ): ./Makefile
                              
                              $(BASENAME): $(OBJ)
                              	$(CC) $(CFLAGS) $^ -o $@ $(LDLIBS)
                              ifeq ($(DEBUG),"yes")
                              	$(NM) $(BASENAME) | sort > $(BASENAME).map
                              else
                              	$(STRIP) $(STRIPFLAGS) $@
                              endif
                              	cp $(BASENAME) $(BINDIR)/$(APP_BASE_NAME)
                              
                              $(BUILD_FILE): ./Makefile .version
                              	@echo \#include \"main.h\" > .ver
                              	@echo -n "const int BuildVersion = " >> .ver
                              	@cat .version >> .ver
                              	@echo ";" >> .ver
                              	@mv -f .ver $@
                              
                              # BEWARE the debian/changelog format is very, very picky!
                              # There must always be specific numbers of spaces in certain places.
                              # Change with extreme caution.
                              DEB_CHANGELOG=./debian/changelog
                              changelog: ./Makefile $(DEB_CHANGELOG)
                              	@echo "$(APP_BASE_NAME) ($(MAJOR_VER).$(MINOR_VER).$(PATCH_VER)-dev+$(BUILD_DEB)) stable; urgency=low\n"  > debian/changelog
                              	@echo "  * Initial Historian Release. See FIL-3131\n" >> debian/changelog
                              	@echo -n " -- maintainer $(DEB_MAINTAINER)  " >> debian/changelog
                              	@echo `date +"%a, %d %b %Y %H:%M:%S %z"` >> debian/changelog
                              
                              deb: changelog
                              	dpkg-buildpackage -b -uc
                              
                              debclean:
                              	/usr/bin/debclean
                              
                              tags: $(SRCPP) *h ./Makefile
                              	-ctags *cpp *h
                              
                              # reformat code with
                              CODE_STYLE=astyle
                              CODE_STYLE_PARMS=--style=linux --indent=tab --indent-col1-comments --indent-preproc-cond
                              style:
                              	set -e; for F in $(SRC) $(SRCPP) $(wildcard *.h) ; do $(CODE_STYLE) $(CODE_STYLE_PARMS) $$F ; done
                              
                              clean:
                              ifeq (.version,$(wildcard .version))
                              	$(shell eval expr 0`cat .version` - 1 > .version)
                              endif
                              	-rm -f .depends tags $(BUILD_FILE)
                              	-rm -fR $(OBJDIR)
                              	-rm -fR $(BINDIR)
                              
                              TARFILE=`date +"data-historian-%Y-%m-%d.tar"`
                              
                              distclean: clean debclean
                              	rm -f ../$(APP_BASE_NAME)_*.buildinfo
                              	rm -f ../$(APP_BASE_NAME)_*.changes
                              
                              distgz: distclean
                              	cd .. && tar cf $(TARFILE) data-historian/* && gzip -f $(TARFILE) && cd -
                              
                              # FIL-3174 Added to process Q_OBJECT directive for QObject slots.
                              moc_udp_server.cpp: udp_server.h
                              	moc udp_server.h > moc_udp_server.cpp
                              moc_udp_server.o: moc_udp_server.cpp
                              	g++ $(CFLAGS) moc_udp_server.cpp -o moc_udp_server.o
                              

                              I'm not the original author of this app but if there are things to cleanup I happy to hear about it.

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt
                              • Unsolved