Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

error: undefined symbol ... during make



  • I get this error during make process of my project.

    859a0f83-84ea-40de-a53b-be6a46423d48-grafik.png

    the symbols are well defined in the external header .h file.
    The .h files is well included in my main .cpp program (#include "... .h").
    I could chekc with some tests that the .h file is linked well.

    But still the make process brings those errors.

    I hope somebody has a good hint for it.


  • Moderators

    You've cut the crucial bit of information out - does it fail during compilation or linking stage? From this output my guess is that during linking. It can be caused by many things:

    • listed symbols are missing from library they come from
    • linked library is not included properly
    • symbols are declared in header but have no implementation (they are not present in library's .cpp file)


  • I hope, this is the missing part :-)

    a37b78f2-24dd-479a-82b5-56b6649582dd-grafik.png

    This is the header of the .ccp:

    36b487b3-c949-4cdf-9bd9-8b1e2b417141-grafik.png

    and used here:

    5b3460a3-17c9-4cdd-916a-402bb33d936a-grafik.png

    Any more idea?


  • Qt Champions 2019

    @elbnacht Just a tipp: post text instead of screen-shots. This way you allow to use the text to make changes to suggest you.


  • Qt Champions 2019

    @elbnacht Can you please post your pro file?



  • sorry, but I still fight with VNC settings of debian using the clipboard ... therefor the quick (and dirty) image pasting

    76d15c4d-0e17-42e1-b423-59662133d2ba-grafik.png


  • Moderators

    wdt_dio.h should not be in HEADERS. If it comes from a library (which is only included and linked, not compiled), all you need to do is to add it's parent directory to INCLUDEPATH.


  • Qt Champions 2019

    @elbnacht wdt_dio is the lib which implements DIReadLine?



  • @jsulm: Yes, wdt_dio has all the "missing symbols".

    @sierdzio: Ok, I understand. I actually added this later just assuming it might be missing. What means "to add it's parent directory to INCLUDEPATH" ? You mean /usr/lib? Which INCLUDEPATH?

    Just for information:
    The project itself compiles / works well as just an Qt program. My goal now is it to have it available too as web application.


  • Qt Champions 2019

    @elbnacht said in error: undefined symbol ... during make:

    /usr/lib?

    /usr/include probably (the one where the header file is located)


  • Moderators

    @elbnacht said in error: undefined symbol ... during make:

    @jsulm: Yes, wdt_dio has all the "missing symbols".

    @sierdzio: Ok, I understand. I actually added this later just assuming it might be missing. What means "to add it's parent directory to INCLUDEPATH" ? You mean /usr/lib? Which INCLUDEPATH?

    INCLUDEPATH variable in qmake. You should set it in your .pro file. It should point to the directory where the wdt_dio header is located.

    Just for information:
    The project itself compiles / works well as just an Qt program. My goal now is it to have it available too as web application.

    Is wdt_dio compiled for WebAssembly, too? It won't link otherwise.


  • Qt Champions 2019

    @elbnacht said in error: undefined symbol ... during make:

    My goal now is it to have it available too as web application

    That explains. I would say you have to compile that lib with em++ as well (if possible at all).



  • I didn't touch the wdt_dio ... thought the driver is running fine ...
    I read yesterday a lot at the emscription web site but came of no result solving my problem.

    What means exactly compiling it for WebAssembly? I have my dwt_dio driver .c and .h file.
    What do I do using the em++ compiler? I thought, this will be done automatically when qmake creates the makefile and make doues the job.


  • Qt Champions 2019

    @elbnacht said in error: undefined symbol ... during make:

    I thought, this will be done automatically when qmake creates the makefile and make doues the job

    No, why should it? The lib is already built.
    What I mean is: you need to get source code of that lib and compile it using the same tool chain you're using to compile your projects.



  • Sorry, but I'm lost now. Please corect me:

    The wdt_dio driver (its a hardware driver) is compiled using gcc ...
    The WebAssembly project is using emsdk qmake / make ... using em++.

    Should I create a make file for the wdt_dio using em++ and compile ... it again?


  • Qt Champions 2019

    @elbnacht said in error: undefined symbol ... during make:

    Should I create a make file for the wdt_dio using em++ and compile ... it again?

    You need to download the source code and then build it with em++. It should not be necessary to write makefile by yourself, but use whatever is used by wdt_dio project (check its source code).



  • Ok, found some more interesting websites about linking etc.

    I started with a simple emcc wdt_dio.c ... created the error 'linux/module.h' file not found, which is beside other included in the .c file.

    All linux sources are installed on my system ...
    Could not find any compiler flags avoiding it ...

    But also for my basic understanding:
    WebAssembly requires a different driver compiled with emcc/em++ for the emscription environment. Is that right?


  • Qt Champions 2019

    @elbnacht The libs you want to use with WebAssembly has to be compiled for WebAssembly. You can't use (as far as I know) libs compiled with GCC.
    "emcc wdt_dio.c ... created the error 'linux/module.h'" - tell emcc where the headers are.


  • Moderators

    @elbnacht said in error: undefined symbol ... during make:

    WebAssembly requires a different driver compiled with emcc/em++ for the emscription environment. Is that right?

    Very probably yes. And these can be missing at this point. WASM ecosystem is quite limited at this point.

    Think about WebAssembly as a different operating system: libraries are not compatible, your system headers/libs won't work, you are essentially cross-compiling. Similar to deploying for an embedded board, except here the system is not Linux but a sandboxed web browser environment.



  • Many thanks for your explanation. This sounds much clearer for me.

    I made a simple Makefile (to find the .h files). Output creates some errors:

    ===================================
    infratec@debian:~/Qt-Projekte/driver$ make
    make -C /lib/modules/4.19.0-8-amd64/build SUBDIRS=/home/infratec/Qt-Projekte/driver modules
    make[1]: Verzeichnis "/usr/src/linux-headers-4.19.0-8-amd64" wird betreten
    CC [M] /home/infratec/Qt-Projekte/driver/wdt_dio.o
    clang: error: unknown argument: '-mno-fp-ret-in-387'
    clang: error: unknown argument: '-mpreferred-stack-boundary=3'
    clang: error: unknown argument: '-mskip-rax-setup'
    clang: error: unknown argument: '-mindirect-branch=thunk-extern'
    clang: error: unknown argument: '-mindirect-branch-register'
    clang: error: unknown argument: '-fno-var-tracking-assignments'
    clang: error: unknown argument: '-mrecord-mcount'
    clang: error: unknown argument: '-fconserve-stack'
    clang: error: unknown argument: '-fmacro-prefix-map=/usr/src/linux-headers-4.19.0-8-common/='
    clang: error: unknown argument: '-fcf-protection=none'
    clang: warning: optimization flag '-falign-jumps=1' is not supported [-Wignored-optimization-argument]
    clang: warning: optimization flag '-falign-loops=1' is not supported [-Wignored-optimization-argument]
    clang: warning: optimization flag '-fno-delete-null-pointer-checks' is not supported [-Wignored-optimization-argument]
    clang: warning: optimization flag '-fmerge-constants' is not supported [-Wignored-optimization-argument]
    shared:ERROR: compiler frontend failed to generate LLVM bitcode, halting
    make[4]: *** [/usr/src/linux-headers-4.19.0-8-common/scripts/Makefile.build:315: /home/infratec/Qt-Projekte/driver/wdt_dio.o] Fehler 1
    make[3]: *** [/usr/src/linux-headers-4.19.0-8-common/Makefile:1537: module/home/infratec/Qt-Projekte/driver] Fehler 2
    make[2]: *** [Makefile:146: sub-make] Fehler 2
    make[1]: *** [Makefile:8: all] Fehler 2
    make[1]: Verzeichnis „/usr/src/linux-headers-4.19.0-8-amd64“ wird verlassen
    make: *** [Makefile:17: all] Fehler 2

    ===============================

    Any idea on this?


  • Qt Champions 2019

    @elbnacht Well, you're passing arguments to the compiler which it does not know



  • I thought the makefile is simple (without any arguments):

    # makefile for a wdt_dio kernel module
    #
    CC := emcc
    
    obj-m += wdt_dio.o
    
    KDIR := /lib/modules/$(shell uname -r)/build
    CDIR := $(shell pwd)
    
    all:
    	$(MAKE) -C $(KDIR) SUBDIRS=$(CDIR) modules
    clean:
    


  • Emscripten/wasm does not have access to the kernel, so trying to build kernel modules for wasm will not work. It lives in the web browser sandbox alongside javascript.


Log in to reply